Initialize CPU power structures, idle process and idle thread
This commit is contained in:
parent
e11ef2f008
commit
63f8dbc59b
@ -25,6 +25,10 @@ XTAPI
|
||||
PKTHREAD
|
||||
KeGetCurrentThread(VOID);
|
||||
|
||||
XTAPI
|
||||
VOID
|
||||
KepInitializeKernel(VOID);
|
||||
|
||||
XTAPI
|
||||
VOID
|
||||
KepInitializeMachine(VOID);
|
||||
|
@ -30,4 +30,7 @@ EXTERN ETHREAD KeInitialThread;
|
||||
/* Kernel service descriptor table */
|
||||
EXTERN KSERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTable[KSERVICE_TABLES_COUNT];
|
||||
|
||||
/* Kernel process list */
|
||||
EXTERN LIST_ENTRY KepProcessListHead;
|
||||
|
||||
#endif /* __XTOSKRNL_GLOBALS_H */
|
||||
|
@ -25,6 +25,10 @@ XTAPI
|
||||
PKTHREAD
|
||||
KeGetCurrentThread(VOID);
|
||||
|
||||
XTAPI
|
||||
VOID
|
||||
KepInitializeKernel(VOID);
|
||||
|
||||
XTAPI
|
||||
VOID
|
||||
KepInitializeMachine(VOID);
|
||||
|
@ -9,6 +9,45 @@
|
||||
#include <xtos.h>
|
||||
|
||||
|
||||
/**
|
||||
* This routine initializes XT kernel.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KepInitializeKernel(VOID)
|
||||
{
|
||||
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
||||
ULONG_PTR PageDirectory[2];
|
||||
PKTHREAD CurrentThread;
|
||||
|
||||
/* Get processor control block and current thread */
|
||||
Prcb = KeGetCurrentProcessorControlBlock();
|
||||
CurrentThread = KeGetCurrentThread();
|
||||
|
||||
/* Initialize CPU power state structures */
|
||||
PoInitializeProcessorControlBlock(Prcb);
|
||||
|
||||
/* Initialize Idle process */
|
||||
RtlInitializeListHead(&KepProcessListHead);
|
||||
PageDirectory[0] = 0;
|
||||
PageDirectory[1] = 0;
|
||||
KeInitializeProcess(CurrentThread->ApcState.Process, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
||||
CurrentThread->ApcState.Process->Quantum = MAXCHAR;
|
||||
|
||||
/* Initialize Idle thread */
|
||||
KeInitializeThread(CurrentThread->ApcState.Process, CurrentThread, NULL, NULL, NULL, NULL, NULL, Prcb->DpcStack);
|
||||
CurrentThread->NextProcessor = Prcb->Number;
|
||||
CurrentThread->Priority = THREAD_HIGH_PRIORITY;
|
||||
CurrentThread->State = Running;
|
||||
CurrentThread->Affinity = (ULONG_PTR)1 << Prcb->Number;
|
||||
CurrentThread->WaitIrql = DISPATCH_LEVEL;
|
||||
CurrentThread->ApcState.Process->ActiveProcessors |= (ULONG_PTR)1 << Prcb->Number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs architecture-specific initialization for the kernel executive.
|
||||
*
|
||||
@ -39,6 +78,11 @@ KepStartKernel(VOID)
|
||||
/* Print debug message */
|
||||
DebugPrint(L"Starting ExectOS ...\n");
|
||||
|
||||
/* Initialize XTOS kernel */
|
||||
KepInitializeKernel();
|
||||
|
||||
/* Enter infinite loop */
|
||||
DebugPrint(L"KepStartKernel() finished. Entering infinite loop.\n");
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
@ -23,3 +23,6 @@ ETHREAD KeInitialThread;
|
||||
|
||||
/* Kernel service descriptor table */
|
||||
KSERVICE_DESCRIPTOR_TABLE KeServiceDescriptorTable[KSERVICE_TABLES_COUNT];
|
||||
|
||||
/* Kernel process list */
|
||||
LIST_ENTRY KepProcessListHead;
|
||||
|
@ -9,6 +9,36 @@
|
||||
#include <xtos.h>
|
||||
|
||||
|
||||
/**
|
||||
* This routine initializes XT kernel.
|
||||
*
|
||||
* @return This routine does not return any value.
|
||||
*
|
||||
* @since XT 1.0
|
||||
*/
|
||||
XTAPI
|
||||
VOID
|
||||
KepInitializeKernel(VOID)
|
||||
{
|
||||
PKPROCESSOR_CONTROL_BLOCK Prcb;
|
||||
ULONG_PTR PageDirectory[2];
|
||||
PKTHREAD CurrentThread;
|
||||
|
||||
/* Get processor control block and current thread */
|
||||
Prcb = KeGetCurrentProcessorControlBlock();
|
||||
CurrentThread = KeGetCurrentThread();
|
||||
|
||||
/* Initialize CPU power state structures */
|
||||
PoInitializeProcessorControlBlock(Prcb);
|
||||
|
||||
/* Initialize Idle process */
|
||||
RtlInitializeListHead(&KepProcessListHead);
|
||||
PageDirectory[0] = 0;
|
||||
PageDirectory[1] = 0;
|
||||
KeInitializeProcess(CurrentThread->ApcState.Process, 0, 0xFFFFFFFF, PageDirectory, FALSE);
|
||||
CurrentThread->ApcState.Process->Quantum = MAXCHAR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs architecture-specific initialization for the kernel executive.
|
||||
*
|
||||
@ -39,6 +69,11 @@ KepStartKernel(VOID)
|
||||
/* Print debug message */
|
||||
DebugPrint(L"Starting ExectOS ...\n");
|
||||
|
||||
/* Initialize XTOS kernel */
|
||||
KepInitializeKernel();
|
||||
|
||||
/* Enter infinite loop */
|
||||
DebugPrint(L"KepStartKernel() finished. Entering infinite loop.\n");
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user