mirror of
https://github.com/reactos/reactos.git
synced 2025-07-12 20:44:16 +00:00
- More kernel initialization changes and cleanups.
- Start support for an initial boot thread. svn path=/trunk/; revision=23879
This commit is contained in:
parent
dbf97f3b50
commit
deed4ed0d6
3 changed files with 92 additions and 26 deletions
|
@ -503,9 +503,6 @@ ExpInitializeExecutive(VOID)
|
||||||
/* Check if the structures match the ASM offset constants */
|
/* Check if the structures match the ASM offset constants */
|
||||||
ExecuteRuntimeAsserts();
|
ExecuteRuntimeAsserts();
|
||||||
|
|
||||||
/* Set 1 CPU for now, we'll increment this later */
|
|
||||||
KeNumberProcessors = 1;
|
|
||||||
|
|
||||||
/* Sets up the Text Sections of the Kernel and HAL for debugging */
|
/* Sets up the Text Sections of the Kernel and HAL for debugging */
|
||||||
LdrInit1();
|
LdrInit1();
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ KNODE KiNode0;
|
||||||
PKNODE KeNodeBlock[1];
|
PKNODE KeNodeBlock[1];
|
||||||
UCHAR KeNumberNodes = 1;
|
UCHAR KeNumberNodes = 1;
|
||||||
UCHAR KeProcessNodeSeed;
|
UCHAR KeProcessNodeSeed;
|
||||||
ULONG KiPcrInitDone = 0;
|
PKPRCB KiProcessorBlock[MAXIMUM_PROCESSORS];
|
||||||
|
ETHREAD KiInitialThread;
|
||||||
|
EPROCESS KiInitialProcess;
|
||||||
extern ULONG Ke386GlobalPagesEnabled;
|
extern ULONG Ke386GlobalPagesEnabled;
|
||||||
|
|
||||||
/* System-defined Spinlocks */
|
/* System-defined Spinlocks */
|
||||||
|
@ -147,36 +149,90 @@ KiInitSpinLocks(IN PKPRCB Prcb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
KiInitializePcr(IN ULONG ProcessorNumber,
|
||||||
|
IN PKIPCR Pcr,
|
||||||
|
IN PKIDTENTRY Idt,
|
||||||
|
IN PKGDTENTRY Gdt,
|
||||||
|
IN PKTSS Tss,
|
||||||
|
IN PKTHREAD IdleThread,
|
||||||
|
IN PVOID DpcStack)
|
||||||
|
{
|
||||||
|
/* Setup the TIB */
|
||||||
|
Pcr->NtTib.ExceptionList = EXCEPTION_CHAIN_END;
|
||||||
|
Pcr->NtTib.StackBase = 0;
|
||||||
|
Pcr->NtTib.StackLimit = 0;
|
||||||
|
Pcr->NtTib.Self = 0;
|
||||||
|
|
||||||
|
/* Set the Current Thread */
|
||||||
|
//Pcr->PrcbData.CurrentThread = IdleThread;
|
||||||
|
|
||||||
|
/* Set pointers to ourselves */
|
||||||
|
Pcr->Self = (PKPCR)Pcr;
|
||||||
|
Pcr->Prcb = &(Pcr->PrcbData);
|
||||||
|
|
||||||
|
/* Set the PCR Version */
|
||||||
|
Pcr->MajorVersion = PCR_MAJOR_VERSION;
|
||||||
|
Pcr->MinorVersion = PCR_MINOR_VERSION;
|
||||||
|
|
||||||
|
/* Set the PCRB Version */
|
||||||
|
Pcr->PrcbData.MajorVersion = 1;
|
||||||
|
Pcr->PrcbData.MinorVersion = 1;
|
||||||
|
|
||||||
|
/* Set the Build Type */
|
||||||
|
Pcr->PrcbData.BuildType = 0;
|
||||||
|
|
||||||
|
/* Set the Processor Number and current Processor Mask */
|
||||||
|
Pcr->PrcbData.Number = (UCHAR)ProcessorNumber;
|
||||||
|
Pcr->PrcbData.SetMember = 1 << ProcessorNumber;
|
||||||
|
|
||||||
|
/* Set the PRCB for this Processor */
|
||||||
|
KiProcessorBlock[ProcessorNumber] = Pcr->Prcb;
|
||||||
|
|
||||||
|
/* Start us out at PASSIVE_LEVEL */
|
||||||
|
Pcr->Irql = PASSIVE_LEVEL;
|
||||||
|
|
||||||
|
/* Set the GDI, IDT, TSS and DPC Stack */
|
||||||
|
Pcr->GDT = (PVOID)Gdt;
|
||||||
|
Pcr->IDT = Idt;
|
||||||
|
Pcr->TSS = Tss;
|
||||||
|
Pcr->PrcbData.DpcStack = DpcStack;
|
||||||
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KiSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
KiSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
IN ULONG DriverBase) // FIXME: hackhack
|
IN ULONG DriverBase) // FIXME: hackhack
|
||||||
{
|
{
|
||||||
PKIPCR KPCR;
|
/* Currently hacked for CPU 0 only */
|
||||||
|
ULONG Cpu = 0;
|
||||||
|
PKIPCR Pcr = (PKIPCR)KPCR_BASE;
|
||||||
PKPRCB Prcb;
|
PKPRCB Prcb;
|
||||||
BOOLEAN NpxPresent;
|
BOOLEAN NpxPresent;
|
||||||
ULONG FeatureBits;
|
ULONG FeatureBits;
|
||||||
ULONG DriverSize;
|
ULONG DriverSize;
|
||||||
extern USHORT KiBootGdt[];
|
extern KGDTENTRY KiBootGdt[];
|
||||||
|
extern PVOID trap_stack;
|
||||||
extern KTSS KiBootTss;
|
extern KTSS KiBootTss;
|
||||||
|
|
||||||
/* Initialize the PCR */
|
/* Initialize the PCR */
|
||||||
KPCR = (PKIPCR)KPCR_BASE;
|
RtlZeroMemory(Pcr, PAGE_SIZE);
|
||||||
Prcb = &KPCR->PrcbData;
|
KiInitializePcr(Cpu,
|
||||||
memset(KPCR, 0, PAGE_SIZE);
|
Pcr,
|
||||||
KPCR->Self = (PKPCR)KPCR;
|
KiIdt,
|
||||||
KPCR->Prcb = &KPCR->PrcbData;
|
KiBootGdt,
|
||||||
KPCR->Irql = SYNCH_LEVEL;
|
&KiBootTss,
|
||||||
KPCR->NtTib.Self = &KPCR->NtTib;
|
&KiInitialThread.Tcb,
|
||||||
KPCR->NtTib.ExceptionList = (PVOID)-1;
|
trap_stack);
|
||||||
KPCR->GDT = KiBootGdt;
|
Prcb = Pcr->Prcb;
|
||||||
KPCR->IDT = KiIdt;
|
|
||||||
KPCR->TSS = &KiBootTss;
|
/* Set us as the current process */
|
||||||
KPCR->Number = 0;
|
KiInitialThread.Tcb.ApcState.Process = &KiInitialProcess.Pcb;
|
||||||
KPCR->SetMember = 1 << 0;
|
|
||||||
KeActiveProcessors = 1 << 0;
|
/* Clear DR6/7 to cleanup bootloader debugging */
|
||||||
KPCR->PrcbData.SetMember = 1 << 0;
|
Pcr->PrcbData.ProcessorState.SpecialRegisters.KernelDr6 = 0;
|
||||||
KiPcrInitDone = 1;
|
Pcr->PrcbData.ProcessorState.SpecialRegisters.KernelDr7 = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Low-level GDT, TSS and LDT Setup, most of which Freeldr should have done
|
* Low-level GDT, TSS and LDT Setup, most of which Freeldr should have done
|
||||||
|
@ -195,6 +251,22 @@ KiSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
(PVOID)DriverBase,
|
(PVOID)DriverBase,
|
||||||
&DriverSize);
|
&DriverSize);
|
||||||
|
|
||||||
|
/* Setup CPU-related fields */
|
||||||
|
Pcr->Number = Cpu;
|
||||||
|
Pcr->SetMember = 1 << Cpu;
|
||||||
|
Pcr->SetMemberCopy = 1 << Cpu;
|
||||||
|
Prcb->SetMember = 1 << Cpu;
|
||||||
|
|
||||||
|
/* Initialize the Processor with HAL */
|
||||||
|
HalInitializeProcessor(Cpu, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
|
||||||
|
|
||||||
|
/* Set active processors */
|
||||||
|
KeActiveProcessors |= Pcr->SetMember;
|
||||||
|
KeNumberProcessors++;
|
||||||
|
|
||||||
|
/* Raise to HIGH_LEVEL */
|
||||||
|
KfRaiseIrql(HIGH_LEVEL);
|
||||||
|
|
||||||
/* Detect and set the CPU Type */
|
/* Detect and set the CPU Type */
|
||||||
KiSetProcessorType();
|
KiSetProcessorType();
|
||||||
|
|
||||||
|
@ -295,9 +367,6 @@ KiSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
/* Initialize HAL */
|
/* Initialize HAL */
|
||||||
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
|
HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
|
||||||
|
|
||||||
/* Initialize the Processor with HAL */
|
|
||||||
HalInitializeProcessor(KeNumberProcessors, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
|
|
||||||
|
|
||||||
/* Initialize the Kernel Executive */
|
/* Initialize the Kernel Executive */
|
||||||
ExpInitializeExecutive();
|
ExpInitializeExecutive();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ ULONG NtMinorVersion = 0;
|
||||||
ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(4, 0);
|
ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(4, 0);
|
||||||
ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
|
ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
|
||||||
ULONG NtGlobalFlag = 0;
|
ULONG NtGlobalFlag = 0;
|
||||||
CHAR KeNumberProcessors;
|
CHAR KeNumberProcessors;
|
||||||
KAFFINITY KeActiveProcessors = 1;
|
KAFFINITY KeActiveProcessors = 1;
|
||||||
ROS_LOADER_PARAMETER_BLOCK KeLoaderBlock;
|
ROS_LOADER_PARAMETER_BLOCK KeLoaderBlock;
|
||||||
ULONG KeDcacheFlushCount = 0;
|
ULONG KeDcacheFlushCount = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue