Author: tkreuzer
Date: Tue Jan 27 16:14:06 2009
New Revision: 39155
URL:
http://svn.reactos.org/svn/reactos?rev=39155&view=rev
Log:
Ke: Remove unused KiInitializeMachineType and Ki486CompatibilityLock. Remove a bunch of
FrLdrDbgPrints. Resort KiSystemStartupReal, initialize the LoaderBlocks Process and Prcb
field for Cpu0, get the Pcr from the LoaderBlock.
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c
branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/cpu.c [iso-8859-1] Tue Jan 27
16:14:06 2009
@@ -506,15 +506,6 @@
ProcessorState->SpecialRegisters.MsrSyscallMask = __readmsr(X86_MSR_SFMASK);
}
-
-VOID
-NTAPI
-KiInitializeMachineType(VOID)
-{
- /* Set the Machine Type we got from NTLDR */
- KeI386MachineType = KeLoaderBlock->u.I386.MachineType & 0x000FF;
-}
-
VOID
NTAPI
KeFlushEntireTb(IN BOOLEAN Invalid,
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/ke/amd64/kiinit.c [iso-8859-1] Tue Jan 27
16:14:06 2009
@@ -20,7 +20,6 @@
/* Spinlocks used only on X86 */
KSPIN_LOCK KiFreezeExecutionLock;
-KSPIN_LOCK Ki486CompatibilityLock;
/* BIOS Memory Map. Not NTLDR-compliant yet */
extern ULONG KeMemoryMapRangeCount;
@@ -337,6 +336,8 @@
IN PKTHREAD IdleThread,
IN PVOID DpcStack)
{
+ RtlZeroMemory(Pcr, PAGE_SIZE);
+
/* Set the Current Thread */
Pcr->Prcb.CurrentThread = IdleThread;
@@ -491,7 +492,6 @@
/* Initialize some spinlocks */
KeInitializeSpinLock(&KiFreezeExecutionLock);
- KeInitializeSpinLock(&Ki486CompatibilityLock);
/* Initialize portable parts of the OS */
KiInitSystem();
@@ -512,7 +512,6 @@
/* FIXME */
DPRINT1("SMP Boot support not yet present\n");
}
-FrLdrDbgPrint("before KeInitializeThread\n");
/* Setup the Idle Thread */
KeInitializeThread(InitProcess,
@@ -523,7 +522,7 @@
NULL,
NULL,
IdleStack);
-FrLdrDbgPrint("after KeInitializeThread\n");
+
InitThread->NextProcessor = Number;
InitThread->Priority = HIGH_PRIORITY;
InitThread->State = Running;
@@ -557,7 +556,7 @@
ExpInitializeExecutive(Number, LoaderBlock);
/* Only do this on the boot CPU */
- if (!Number)
+ if (Number == 0)
{
/* Calculate the time reciprocal */
KiTimeIncrementReciprocal =
@@ -650,8 +649,6 @@
NTAPI
KiSystemStartupReal(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
- FrLdrDbgPrint("Enter KiSystemStartupReal()\n");
-
ULONG Cpu;
PKTHREAD InitialThread;
ULONG64 InitialStack;
@@ -664,85 +661,98 @@
/* Save the loader block and get the current CPU */
KeLoaderBlock = LoaderBlock;
- /* Get Pcr from loader block */
-// Pcr = CONTAINING_RECORD(LoaderBlock->Prcb, KIPCR, Prcb);
- Pcr = &KiInitialPcr;
-
+ /* Get the current CPU number */
Cpu = KeNumberProcessors;
+
+ /* Set active processors */
+ KeActiveProcessors |= 1 << Cpu;
+ KeNumberProcessors++;
+
+ /* LoaderBlock initialization for Cpu 0 */
if (Cpu == 0)
{
- /* If this is the boot CPU, set GS base and the CPU Number*/
- __writemsr(X86_MSR_GSBASE, (ULONG64)Pcr);
- __writemsr(X86_MSR_KERNEL_GSBASE, (ULONG64)Pcr);
- Pcr->Prcb.Number = Cpu;
-
- /* Set the initial stack and idle thread as well */
+ /* Set the initial stack, idle thread and process */
LoaderBlock->KernelStack = (ULONG_PTR)P0BootStack;
LoaderBlock->Thread = (ULONG_PTR)&KiInitialThread;
- }
+ LoaderBlock->Process = (ULONG_PTR)&KiInitialProcess.Pcb;
+ LoaderBlock->Prcb = (ULONG_PTR)&KiInitialPcr.Prcb;
+ }
+
+ /* Get Pcr from loader block */
+ Pcr = CONTAINING_RECORD(LoaderBlock->Prcb, KIPCR, Prcb);
+
+ /* Set GS base */
+ __writemsr(X86_MSR_GSBASE, (ULONG64)Pcr);
+ __writemsr(X86_MSR_KERNEL_GSBASE, (ULONG64)Pcr);
+
+ /* Load Ring 3 selectors for DS/ES/FS */
+ Ke386SetDs(KGDT_64_DATA | RPL_MASK);
+ Ke386SetEs(KGDT_64_DATA | RPL_MASK);
+ Ke386SetFs(KGDT_32_R3_TEB | RPL_MASK);
+
+ /* LDT is unused */
+ __sldt(0);
+
+ /* Align stack to 16 bytes */
+ LoaderBlock->KernelStack &= ~(16 - 1);
/* Save the initial thread and stack */
- InitialStack = LoaderBlock->KernelStack; // Chekme
+ InitialStack = LoaderBlock->KernelStack; // Checkme
InitialThread = (PKTHREAD)LoaderBlock->Thread;
-
- /* Align stack to 16 bytes */
- InitialStack &= ~(16 - 1);
/* Clean the APC List Head */
InitializeListHead(&InitialThread->ApcState.ApcListHead[KernelMode]);
- /* Initialize the machine type */
- KiInitializeMachineType();
+ /* Set us as the current process */
+ InitialThread->ApcState.Process = (PVOID)LoaderBlock->Process;
+
+ /* Get GDT, IDT, PCR and TSS pointers */
+ KiGetMachineBootPointers(&Gdt, &Idt, &Pcr, &Tss);
+
+ /* Initialize the PCR */
+ KiInitializePcr(Cpu,
+ Pcr,
+ Idt,
+ Gdt,
+ Tss,
+ InitialThread,
+ KiDoubleFaultStack);
/* Skip initial setup if this isn't the Boot CPU */
if (Cpu == 0)
{
- /* Get GDT, IDT, PCR and TSS pointers */
- KiGetMachineBootPointers(&Gdt, &Idt, &Pcr, &Tss);
-
-FrLdrDbgPrint("Gdt = %p, Idt = %p, Pcr = %p, Tss = %p\n", Gdt, Idt, Pcr, Tss);
-
/* Setup the TSS descriptors and entries */
Ki386InitializeTss(Tss, Idt, Gdt, InitialStack);
- /* Initialize the PCR */
- RtlZeroMemory(Pcr, PAGE_SIZE);
- KiInitializePcr(Cpu,
- Pcr,
- Idt,
- Gdt,
- Tss,
- InitialThread,
- KiDoubleFaultStack);
-
- /* Set us as the current process */
- InitialThread->ApcState.Process = &KiInitialProcess.Pcb;
-
/* Setup the IDT */
KeInitExceptions();
- /* Load Ring 3 selectors for DS/ES/FS */
- Ke386SetDs(KGDT_64_DATA | RPL_MASK);
- Ke386SetEs(KGDT_64_DATA | RPL_MASK);
- Ke386SetFs(KGDT_32_R3_TEB | RPL_MASK);
-
- /* LDT is unused */
- __sldt(0);
-
- /* Save NMI and double fault traps */
-// RtlCopyMemory(&NmiEntry, &Idt[2], sizeof(KIDTENTRY));
-// RtlCopyMemory(&DoubleFaultEntry, &Idt[8], sizeof(KIDTENTRY));
-
- /* Copy kernel's trap handlers */
-// RtlCopyMemory(Idt,
-// (PVOID)KiIdtDescriptor.Base,
-// KiIdtDescriptor.Limit + 1);
-
- /* Restore NMI and double fault */
-// RtlCopyMemory(&Idt[2], &NmiEntry, sizeof(KIDTENTRY));
-// RtlCopyMemory(&Idt[8], &DoubleFaultEntry, sizeof(KIDTENTRY));
- }
-
+ /* Initialize debugging system */
+ KdInitSystem(0, KeLoaderBlock);
+
+ /* Check for break-in */
+// if (KdPollBreakIn()) DbgBreakPointWithStatus(1);
+
+ /* HACK: misuse this function to pass a function pointer to kdcom */
+ KdDebuggerInitialize1((PVOID)FrLdrDbgPrint);
+
+ /* Hack! Wait for the debugger! */
+ while (!KdPollBreakIn());
+
+ /* Display separator + ReactOS version at start of the debug log */
+ DPRINT1("-----------------------------------------------------\n");
+ DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build
"KERNEL_VERSION_BUILD_STR")\n");
+ DPRINT1("Command Line: %s\n", LoaderBlock->LoadOptions);
+ DPRINT1("ARC Paths: %s %s %s %s\n", LoaderBlock->ArcBootDeviceName,
+ LoaderBlock->NtHalPathName,
+ LoaderBlock->ArcHalDeviceName,
+ LoaderBlock->NtBootPathName);
+ }
+
+ DPRINT1("Gdt = %p, Idt = %p, Pcr = %p, Tss = %p\n", Gdt, Idt, Pcr, Tss);
+
+ /* Initialize the Processor with HAL */
+ HalInitializeProcessor(Cpu, KeLoaderBlock);
/* Loop until we can release the freeze lock */
do
@@ -750,44 +760,6 @@
/* Loop until execution can continue */
while (*(volatile PKSPIN_LOCK*)&KiFreezeExecutionLock == (PVOID)1);
} while(InterlockedBitTestAndSet64((PLONG64)&KiFreezeExecutionLock, 0));
-
- /* Setup CPU-related fields */
- Pcr->Prcb.Number = Cpu;
- Pcr->Prcb.SetMember = 1 << Cpu;
-
- /* Initialize the Processor with HAL */
- HalInitializeProcessor(Cpu, KeLoaderBlock);
-
- /* Set active processors */
- KeActiveProcessors |= 1 << Cpu;
- KeNumberProcessors++;
-
- /* Check if this is the boot CPU */
- if (Cpu == 0)
- {
- /* Initialize debugging system */
- KdInitSystem(0, KeLoaderBlock);
-
- /* Check for break-in */
-// if (KdPollBreakIn()) DbgBreakPointWithStatus(1);
- }
-
- /* HACK: misuse this function to pass a function pointer to kdcom */
- KdDebuggerInitialize1((PVOID)FrLdrDbgPrint);
-
- /* Hack! Wait for the debugger! */
- while (!KdPollBreakIn());
-
- DbgBreakPointWithStatus(0);
-
- /* Display separator + ReactOS version at start of the debug log */
- DPRINT1("-----------------------------------------------------\n");
- DPRINT1("ReactOS "KERNEL_VERSION_STR" (Build
"KERNEL_VERSION_BUILD_STR")\n");
- DPRINT1("Command Line: %s\n", LoaderBlock->LoadOptions);
- DPRINT1("ARC Paths: %s %s %s %s\n", LoaderBlock->ArcBootDeviceName,
- LoaderBlock->NtHalPathName,
- LoaderBlock->ArcHalDeviceName,
- LoaderBlock->NtBootPathName);
/* Raise to HIGH_LEVEL */
KfRaiseIrql(HIGH_LEVEL);
@@ -811,6 +783,8 @@
IN CCHAR Number,
IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
+// DbgBreakPointWithStatus(0);
+
/* Initialize kernel */
KiInitializeKernel(InitProcess,
InitThread,