[ros-diffs] [ros-arm-bringup] 34481: - Okay so we've got a basic KiDispatchException, we now need KiTrapFrameToContext and KiContextToTrapFrame. - We aren't really sure where the hell we are since we can't printf anything otherwise we'll trap again and end up in an infinite loop. - So we're debugging with while (TRUE).

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Mon Jul 14 01:46:51 CEST 2008


Author: ros-arm-bringup
Date: Sun Jul 13 18:46:50 2008
New Revision: 34481

URL: http://svn.reactos.org/svn/reactos?rev=34481&view=rev
Log:
- Okay so we've got a basic KiDispatchException, we now need KiTrapFrameToContext and KiContextToTrapFrame.
- We aren't really sure where the hell we are since we can't printf anything otherwise we'll trap again and end up in an infinite loop.
- So we're debugging with while (TRUE).


Modified:
    trunk/reactos/ntoskrnl/ke/arm/exp.c
    trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s

Modified: trunk/reactos/ntoskrnl/ke/arm/exp.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/exp.c?rev=34481&r1=34480&r2=34481&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/exp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/exp.c [iso-8859-1] Sun Jul 13 18:46:50 2008
@@ -25,6 +25,149 @@
                      IN ULONG ContextFlags,
                      IN KPROCESSOR_MODE PreviousMode)
 {
-    UNIMPLEMENTED;
+    while (TRUE);
     return;
 }
+
+VOID
+NTAPI
+KeTrapFrameToContext(IN PKTRAP_FRAME TrapFrame,
+                     IN PKEXCEPTION_FRAME ExceptionFrame,
+                     IN OUT PCONTEXT Context)
+{
+    while (TRUE);
+    return; 
+}
+
+VOID
+NTAPI
+KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
+                    IN PKEXCEPTION_FRAME ExceptionFrame,
+                    IN PKTRAP_FRAME TrapFrame,
+                    IN KPROCESSOR_MODE PreviousMode,
+                    IN BOOLEAN FirstChance)
+{
+    CONTEXT Context;
+    
+    //
+    // Increase number of Exception Dispatches
+    //
+    KeGetCurrentPrcb()->KeExceptionDispatchCount++;
+    
+    //
+    // Set the context flags
+    //
+    Context.ContextFlags = CONTEXT_FULL;
+    
+    //
+    // FIXME: Fuck floating point
+    //
+    
+    //
+    // Get a Context
+    //
+    KeTrapFrameToContext(TrapFrame, ExceptionFrame, &Context);
+    
+    //
+    // Look at our exception code
+    //
+    switch (ExceptionRecord->ExceptionCode)
+    {
+        //
+        // Breakpoint
+        //
+        case STATUS_BREAKPOINT:
+            
+            //
+            // Decrement PC by one
+            //
+            Context.Pc--;
+            break;
+            
+        //
+        // Internal exception
+        //
+        case KI_EXCEPTION_ACCESS_VIOLATION:
+            
+            //
+            // Set correct code
+            //
+            ExceptionRecord->ExceptionCode = STATUS_ACCESS_VIOLATION;
+            break;
+    }
+       
+    //
+    // Handle kernel-mode first, it's simpler
+    //
+    if (PreviousMode == KernelMode)
+    {
+        //
+        // Check if this is a first-chance exception
+        //
+        if (FirstChance == TRUE)
+        {
+            //
+            // Break into the debugger for the first time
+            //
+            if (KiDebugRoutine(TrapFrame,
+                               ExceptionFrame,
+                               ExceptionRecord,
+                               &Context,
+                               PreviousMode,
+                               FALSE))
+            {
+                //
+                // Exception was handled
+                //
+                goto Handled;
+            }
+            
+            //
+            // If the Debugger couldn't handle it, dispatch the exception
+            //
+            if (RtlDispatchException(ExceptionRecord, &Context)) goto Handled;
+        }
+        
+        //
+        // This is a second-chance exception, only for the debugger
+        //
+        if (KiDebugRoutine(TrapFrame,
+                           ExceptionFrame,
+                           ExceptionRecord,
+                           &Context,
+                           PreviousMode,
+                           TRUE))
+        {
+            //
+            // Exception was handled
+            //
+            goto Handled;
+        }
+        
+        //
+        // Third strike; you're out
+        //
+        KeBugCheckEx(KMODE_EXCEPTION_NOT_HANDLED,
+                     ExceptionRecord->ExceptionCode,
+                     (ULONG_PTR)ExceptionRecord->ExceptionAddress,
+                     (ULONG_PTR)TrapFrame,
+                     0);
+    }
+    else
+    {
+        //
+        // FIXME: User mode
+        //
+        ASSERT(FALSE);
+    }
+    
+Handled:
+    //
+    // Convert the context back into Trap/Exception Frames
+    //
+    KeContextToTrapFrame(&Context,
+                         ExceptionFrame,
+                         TrapFrame,
+                         Context.ContextFlags,
+                         PreviousMode);
+}

Modified: trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s?rev=34481&r1=34480&r2=34481&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/stubs_asm.s [iso-8859-1] Sun Jul 13 18:46:50 2008
@@ -39,7 +39,6 @@
 //
 GENERATE_ARM_STUB KiInitializeUserApc
 GENERATE_ARM_STUB KeDisableInterrupts
-GENERATE_ARM_STUB KiDispatchException
 GENERATE_ARM_STUB KiSwapProcess
 GENERATE_ARM_STUB KeSwitchKernelStack
 



More information about the Ros-diffs mailing list