[ros-diffs] [ros-arm-bringup] 33937: - We now implement a super-basic (and probably broken) context switching mechanism. - We completely ignore setting the thread to the right scheduler state, and don't do any APC delivery checking, or any other work. - We now implement a basic KiThreadStartup, which behaves properly (we believe). Doesn't handle user-mode threads yet, though. - This gets us through PspSystemThreadStartup, and.. - We now reach Phase1InitializationDiscard! A major step has been reached, now it's time to cleanup what has been done until now and verify it to be correct. - Then we move on... the next two things will be 1) Hal Initialization (setting up the timer) and 2) Displaying the boot logo. - Graphics will require using the PL-110 LCD Controller.

ros-arm-bringup at svn.reactos.org ros-arm-bringup at svn.reactos.org
Thu Jun 12 02:40:54 CEST 2008


Author: ros-arm-bringup
Date: Wed Jun 11 19:40:53 2008
New Revision: 33937

URL: http://svn.reactos.org/svn/reactos?rev=33937&view=rev
Log:
- We now implement a super-basic (and probably broken) context switching mechanism.
- We completely ignore setting the thread to the right scheduler state, and don't do any APC delivery checking, or any other work.
- We now implement a basic KiThreadStartup, which behaves properly (we believe). Doesn't handle user-mode threads yet, though.
- This gets us through PspSystemThreadStartup, and..
- We now reach Phase1InitializationDiscard! A major step has been reached, now it's time to cleanup what has been done until now and verify it to be correct.
- Then we move on... the next two things will be 1) Hal Initialization (setting up the timer) and 2) Displaying the boot logo.
- Graphics will require using the PL-110 LCD Controller.

Modified:
    trunk/reactos/include/ndk/arm/ketypes.h
    trunk/reactos/ntoskrnl/ex/init.c
    trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
    trunk/reactos/ntoskrnl/ke/arm/thrdini.c
    trunk/reactos/ntoskrnl/ke/arm/trapc.c

Modified: trunk/reactos/include/ndk/arm/ketypes.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/arm/ketypes.h?rev=33937&r1=33936&r2=33937&view=diff
==============================================================================
--- trunk/reactos/include/ndk/arm/ketypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/arm/ketypes.h [iso-8859-1] Wed Jun 11 19:40:53 2008
@@ -101,11 +101,11 @@
     ULONG R9;
     ULONG R10;
     ULONG R11;
-    ULONG R12;
+//    ULONG R12;
 //    ULONG Sp;
-//    ULONG Psr;
+    ULONG Psr;
     ULONG Lr;
-    ULONG SwapReturn;
+//    ULONG SwapReturn;
 } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
 
 //

Modified: trunk/reactos/ntoskrnl/ex/init.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=33937&r1=33936&r2=33937&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] Wed Jun 11 19:40:53 2008
@@ -1265,6 +1265,12 @@
     OBJECT_ATTRIBUTES ObjectAttributes;
     HANDLE KeyHandle, OptionHandle;
     PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
+#ifdef _ARM_
+    DPRINT1("*** Phase 1 Initialization Thread\n");
+    DPRINT1("Beginning consistency checks...\n");
+    // CHECK STACKS, IRQLS, DISPATCHER AND MAKE SURE WE ARE GOOD TO GO!
+    while (TRUE);
+#endif
 
     /* Allocate the initialization buffer */
     InitBuffer = ExAllocatePoolWithTag(NonPagedPool,

Modified: trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s?rev=33937&r1=33936&r2=33937&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s [iso-8859-1] Wed Jun 11 19:40:53 2008
@@ -21,6 +21,11 @@
     //
     // Save volatile registers for the OLD thread
     //
+    sub sp, sp, #(4*8)
+    mrs ip, spsr_all
+    stmia sp, {ip, lr}
+    sub sp, sp, #(4*2)
+    stmia sp, {r4-r11}
     
     //
     // Switch stacks
@@ -32,19 +37,46 @@
     // Call the C context switch code
     //
     bl KiSwapContextInternal
-    
+
     //
     // Restore volatile registers for the NEW thread
     //
+    ldmia sp, {r4-r11}
+    add sp, sp, #(4*8)
+    ldmia sp, {ip, lr}
+    msr spsr_all, ip
+    add sp, sp, #(4*2)
     
     //
     // Jump to saved restore address
     //
+    mov pc, lr
+
+    ENTRY_END KiSwapContext
+
+    NESTED_ENTRY KiThreadStartup
+    PROLOG_END KiThreadStartup
     
     //
-    // FIXME: TODO
+    // FIXME: Make space on stack and clean it up?
+    //
+    
+    //
+    // Lower to APC_LEVEL
+    //
+    mov a1, #1
+    bl KeLowerIrql
+    
+    //
+    // Set the start address and startup context
+    //
+    mov a1, r6
+    mov a2, r5
+    blx r7
+    
+    //
+    // Oh noes, we are back!
     //
     b .
     
-    ENTRY_END KiSwapContext
-
+    ENTRY_END KiThreadStartup

Modified: trunk/reactos/ntoskrnl/ke/arm/thrdini.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/thrdini.c?rev=33937&r1=33936&r2=33937&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/thrdini.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/thrdini.c [iso-8859-1] Wed Jun 11 19:40:53 2008
@@ -30,15 +30,7 @@
 
 VOID
 NTAPI
-KiThreadStartup(IN PKSYSTEM_ROUTINE SystemRoutine,
-                IN PKSTART_ROUTINE StartRoutine,
-                IN PVOID StartContext,
-                IN BOOLEAN UserThread,
-                IN KTRAP_FRAME TrapFrame)
-{
-    UNIMPLEMENTED;
-    return;
-}
+KiThreadStartup(VOID);
 
 VOID
 NTAPI
@@ -112,7 +104,7 @@
         //
         // Set the previous mode as kernel
         //
-        //Thread->PreviousMode = KernelMode;
+        Thread->PreviousMode = KernelMode;
         
         //
         // Context switch frame to setup below
@@ -123,7 +115,7 @@
     //
     // Now setup the context switch frame
     //
-    CtxSwitchFrame->SwapReturn = (ULONG)KiThreadStartup;
+    CtxSwitchFrame->Lr = (ULONG)KiThreadStartup;
     CtxSwitchFrame->R11 = (ULONG)(ExceptionFrame ? ExceptionFrame : CtxSwitchFrame);
 
     //
@@ -138,4 +130,5 @@
     // Save back the new value of the kernel stack
     //
     Thread->KernelStack = (PVOID)CtxSwitchFrame;
+    DPRINT1("NEW THREAD %p WITH EX FRAME AT: %p\n", Thread, Thread->KernelStack);
 }

Modified: trunk/reactos/ntoskrnl/ke/arm/trapc.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/trapc.c?rev=33937&r1=33936&r2=33937&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] Wed Jun 11 19:40:53 2008
@@ -37,12 +37,34 @@
 KiSwapContextInternal(IN PKTHREAD OldThread,
                       IN PKTHREAD NewThread)
 {
-    //
-    // FIXME: TODO
-    //
+    PKEXCEPTION_FRAME ExFrame = NewThread->KernelStack;
     DPRINT1("Switching from: %p to %p\n", OldThread, NewThread);
     DPRINT1("Stacks: %p %p\n", OldThread->KernelStack, NewThread->KernelStack);
-    while (TRUE);
+    DPRINT1("Thread Registers:\n"
+            "R4: %lx\n"
+            "R5: %lx\n"
+            "R6: %lx\n"
+            "R7: %lx\n"
+            "R8: %lx\n"
+            "R9: %lx\n"
+            "R10: %lx\n"
+            "R11: %lx\n"
+            "Psr: %lx\n"
+            "Lr: %lx\n",
+            ExFrame->R4,
+            ExFrame->R5,
+            ExFrame->R6,
+            ExFrame->R7,
+            ExFrame->R8,
+            ExFrame->R9,
+            ExFrame->R10,
+            ExFrame->R11,
+            ExFrame->Psr,
+            ExFrame->Lr);
+    
+    //
+    // FIXME: Todo
+    //
 }
 
 VOID



More information about the Ros-diffs mailing list