- 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.

svn path=/trunk/; revision=33937
This commit is contained in:
ReactOS Portable Systems Group 2008-06-12 00:40:53 +00:00
parent c84fd405bf
commit 0bcdd3cdcc
5 changed files with 75 additions and 22 deletions

View file

@ -101,11 +101,11 @@ typedef struct _KEXCEPTION_FRAME
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;
//

View file

@ -1265,6 +1265,12 @@ Phase1InitializationDiscard(IN PVOID Context)
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,

View file

@ -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

View file

@ -30,15 +30,7 @@ typedef struct _KKINIT_FRAME
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 @@ KeArmInitThreadWithContext(IN PKTHREAD Thread,
//
// Set the previous mode as kernel
//
//Thread->PreviousMode = KernelMode;
Thread->PreviousMode = KernelMode;
//
// Context switch frame to setup below
@ -123,7 +115,7 @@ KeArmInitThreadWithContext(IN PKTHREAD Thread,
//
// Now setup the context switch frame
//
CtxSwitchFrame->SwapReturn = (ULONG)KiThreadStartup;
CtxSwitchFrame->Lr = (ULONG)KiThreadStartup;
CtxSwitchFrame->R11 = (ULONG)(ExceptionFrame ? ExceptionFrame : CtxSwitchFrame);
//
@ -138,4 +130,5 @@ KeArmInitThreadWithContext(IN PKTHREAD Thread,
// 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);
}

View file

@ -37,12 +37,34 @@ VOID
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