Refactor kernel startup code
This commit is contained in:
parent
eeeb9d6ed7
commit
3d08be4fac
@ -20,42 +20,6 @@ XTAPI
|
|||||||
VOID
|
VOID
|
||||||
KepInitializeKernel(VOID)
|
KepInitializeKernel(VOID)
|
||||||
{
|
{
|
||||||
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
|
||||||
ULONG_PTR PageDirectory[2];
|
|
||||||
PKPROCESS CurrentProcess;
|
|
||||||
PKTHREAD CurrentThread;
|
|
||||||
|
|
||||||
/* Get processor control block and current thread */
|
|
||||||
Prcb = KeGetCurrentProcessorControlBlock();
|
|
||||||
CurrentThread = KeGetCurrentThread();
|
|
||||||
|
|
||||||
/* Get current process */
|
|
||||||
CurrentProcess = CurrentThread->ApcState.Process;
|
|
||||||
|
|
||||||
/* Initialize CPU power state structures */
|
|
||||||
PoInitializeProcessorControlBlock(Prcb);
|
|
||||||
|
|
||||||
/* Save processor state */
|
|
||||||
KepSaveProcessorState(&Prcb->ProcessorState);
|
|
||||||
|
|
||||||
/* Lower to APC runlevel */
|
|
||||||
KeLowerRunLevel(APC_LEVEL);
|
|
||||||
|
|
||||||
/* Initialize Idle process */
|
|
||||||
RtlInitializeListHead(&KepProcessListHead);
|
|
||||||
PageDirectory[0] = 0;
|
|
||||||
PageDirectory[1] = 0;
|
|
||||||
KeInitializeProcess(CurrentProcess, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
|
||||||
CurrentProcess->Quantum = MAXCHAR;
|
|
||||||
|
|
||||||
/* Initialize Idle thread */
|
|
||||||
KeInitializeThread(CurrentProcess, CurrentThread, NULL, NULL, NULL, NULL, NULL, ArKernelBootStack, TRUE);
|
|
||||||
CurrentThread->NextProcessor = Prcb->CpuNumber;
|
|
||||||
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
|
||||||
CurrentThread->State = Running;
|
|
||||||
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->CpuNumber;
|
|
||||||
CurrentThread->WaitRunLevel = DISPATCH_LEVEL;
|
|
||||||
CurrentProcess->ActiveProcessors |= (ULONG_PTR)1 << Prcb->CpuNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,9 +55,46 @@ XTAPI
|
|||||||
VOID
|
VOID
|
||||||
KepStartKernel(VOID)
|
KepStartKernel(VOID)
|
||||||
{
|
{
|
||||||
|
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
||||||
|
ULONG_PTR PageDirectory[2];
|
||||||
|
PKPROCESS CurrentProcess;
|
||||||
|
PKTHREAD CurrentThread;
|
||||||
|
|
||||||
|
/* Get processor control block and current thread */
|
||||||
|
Prcb = KeGetCurrentProcessorControlBlock();
|
||||||
|
CurrentThread = KeGetCurrentThread();
|
||||||
|
|
||||||
|
/* Get current process */
|
||||||
|
CurrentProcess = CurrentThread->ApcState.Process;
|
||||||
|
|
||||||
|
/* Initialize CPU power state structures */
|
||||||
|
PoInitializeProcessorControlBlock(Prcb);
|
||||||
|
|
||||||
|
/* Save processor state */
|
||||||
|
KepSaveProcessorState(&Prcb->ProcessorState);
|
||||||
|
|
||||||
|
/* Lower to APC runlevel */
|
||||||
|
KeLowerRunLevel(APC_LEVEL);
|
||||||
|
|
||||||
/* Initialize XTOS kernel */
|
/* Initialize XTOS kernel */
|
||||||
KepInitializeKernel();
|
KepInitializeKernel();
|
||||||
|
|
||||||
|
/* Initialize Idle process */
|
||||||
|
RtlInitializeListHead(&KepProcessListHead);
|
||||||
|
PageDirectory[0] = 0;
|
||||||
|
PageDirectory[1] = 0;
|
||||||
|
KeInitializeProcess(CurrentProcess, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
||||||
|
CurrentProcess->Quantum = MAXCHAR;
|
||||||
|
|
||||||
|
/* Initialize Idle thread */
|
||||||
|
KeInitializeThread(CurrentProcess, CurrentThread, NULL, NULL, NULL, NULL, NULL, ArKernelBootStack, TRUE);
|
||||||
|
CurrentThread->NextProcessor = Prcb->CpuNumber;
|
||||||
|
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
||||||
|
CurrentThread->State = Running;
|
||||||
|
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->CpuNumber;
|
||||||
|
CurrentThread->WaitRunLevel = DISPATCH_LEVEL;
|
||||||
|
CurrentProcess->ActiveProcessors |= (ULONG_PTR)1 << Prcb->CpuNumber;
|
||||||
|
|
||||||
/* Enter infinite loop */
|
/* Enter infinite loop */
|
||||||
DebugPrint(L"KepStartKernel() finished. Entering infinite loop.\n");
|
DebugPrint(L"KepStartKernel() finished. Entering infinite loop.\n");
|
||||||
for(;;);
|
for(;;);
|
||||||
|
@ -20,42 +20,6 @@ XTAPI
|
|||||||
VOID
|
VOID
|
||||||
KepInitializeKernel(VOID)
|
KepInitializeKernel(VOID)
|
||||||
{
|
{
|
||||||
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
|
||||||
ULONG_PTR PageDirectory[2];
|
|
||||||
PKPROCESS CurrentProcess;
|
|
||||||
PKTHREAD CurrentThread;
|
|
||||||
|
|
||||||
/* Get processor control block and current thread */
|
|
||||||
Prcb = KeGetCurrentProcessorControlBlock();
|
|
||||||
CurrentThread = KeGetCurrentThread();
|
|
||||||
|
|
||||||
/* Get current process */
|
|
||||||
CurrentProcess = CurrentThread->ApcState.Process;
|
|
||||||
|
|
||||||
/* Initialize CPU power state structures */
|
|
||||||
PoInitializeProcessorControlBlock(Prcb);
|
|
||||||
|
|
||||||
/* Save processor state */
|
|
||||||
KepSaveProcessorState(&Prcb->ProcessorState);
|
|
||||||
|
|
||||||
/* Lower to APC runlevel */
|
|
||||||
KeLowerRunLevel(APC_LEVEL);
|
|
||||||
|
|
||||||
/* Initialize Idle process */
|
|
||||||
RtlInitializeListHead(&KepProcessListHead);
|
|
||||||
PageDirectory[0] = 0;
|
|
||||||
PageDirectory[1] = 0;
|
|
||||||
KeInitializeProcess(CurrentProcess, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
|
||||||
CurrentProcess->Quantum = MAXCHAR;
|
|
||||||
|
|
||||||
/* Initialize Idle thread */
|
|
||||||
KeInitializeThread(CurrentProcess, CurrentThread, NULL, NULL, NULL, NULL, NULL, ArKernelBootStack, TRUE);
|
|
||||||
CurrentThread->NextProcessor = Prcb->CpuNumber;
|
|
||||||
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
|
||||||
CurrentThread->State = Running;
|
|
||||||
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->CpuNumber;
|
|
||||||
CurrentThread->WaitRunLevel = DISPATCH_LEVEL;
|
|
||||||
CurrentProcess->ActiveProcessors |= (ULONG_PTR)1 << Prcb->CpuNumber;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,9 +55,46 @@ XTAPI
|
|||||||
VOID
|
VOID
|
||||||
KepStartKernel(VOID)
|
KepStartKernel(VOID)
|
||||||
{
|
{
|
||||||
|
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
||||||
|
ULONG_PTR PageDirectory[2];
|
||||||
|
PKPROCESS CurrentProcess;
|
||||||
|
PKTHREAD CurrentThread;
|
||||||
|
|
||||||
|
/* Get processor control block and current thread */
|
||||||
|
Prcb = KeGetCurrentProcessorControlBlock();
|
||||||
|
CurrentThread = KeGetCurrentThread();
|
||||||
|
|
||||||
|
/* Get current process */
|
||||||
|
CurrentProcess = CurrentThread->ApcState.Process;
|
||||||
|
|
||||||
|
/* Initialize CPU power state structures */
|
||||||
|
PoInitializeProcessorControlBlock(Prcb);
|
||||||
|
|
||||||
|
/* Save processor state */
|
||||||
|
KepSaveProcessorState(&Prcb->ProcessorState);
|
||||||
|
|
||||||
|
/* Lower to APC runlevel */
|
||||||
|
KeLowerRunLevel(APC_LEVEL);
|
||||||
|
|
||||||
/* Initialize XTOS kernel */
|
/* Initialize XTOS kernel */
|
||||||
KepInitializeKernel();
|
KepInitializeKernel();
|
||||||
|
|
||||||
|
/* Initialize Idle process */
|
||||||
|
RtlInitializeListHead(&KepProcessListHead);
|
||||||
|
PageDirectory[0] = 0;
|
||||||
|
PageDirectory[1] = 0;
|
||||||
|
KeInitializeProcess(CurrentProcess, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
||||||
|
CurrentProcess->Quantum = MAXCHAR;
|
||||||
|
|
||||||
|
/* Initialize Idle thread */
|
||||||
|
KeInitializeThread(CurrentProcess, CurrentThread, NULL, NULL, NULL, NULL, NULL, ArKernelBootStack, TRUE);
|
||||||
|
CurrentThread->NextProcessor = Prcb->CpuNumber;
|
||||||
|
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
||||||
|
CurrentThread->State = Running;
|
||||||
|
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->CpuNumber;
|
||||||
|
CurrentThread->WaitRunLevel = DISPATCH_LEVEL;
|
||||||
|
CurrentProcess->ActiveProcessors |= (ULONG_PTR)1 << Prcb->CpuNumber;
|
||||||
|
|
||||||
/* Enter infinite loop */
|
/* Enter infinite loop */
|
||||||
DebugPrint(L"KepStartKernel() finished. Entering infinite loop.\n");
|
DebugPrint(L"KepStartKernel() finished. Entering infinite loop.\n");
|
||||||
for(;;);
|
for(;;);
|
||||||
|
Loading…
Reference in New Issue
Block a user