Author: ion
Date: Fri Sep 1 17:13:08 2006
New Revision: 23866
URL:
http://svn.reactos.org/svn/reactos?rev=23866&view=rev
Log:
- More initialization cleanup.
Modified:
trunk/reactos/ntoskrnl/include/internal/ke.h
trunk/reactos/ntoskrnl/ke/i386/kernel.c
trunk/reactos/ntoskrnl/ke/i386/main_asm.S
trunk/reactos/ntoskrnl/ke/main.c
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h Fri Sep 1 17:13:08 2006
@@ -611,8 +611,9 @@
VOID
NTAPI
-KeInit1(
- VOID
+KiSystemStartup(
+ IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG DriverBase // FIXME: hackhack
);
VOID
Modified: trunk/reactos/ntoskrnl/ke/i386/kernel.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kernel.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kernel.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kernel.c Fri Sep 1 17:13:08 2006
@@ -149,12 +149,14 @@
VOID
NTAPI
-KeInit1(VOID)
+KiSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
+ IN ULONG DriverBase) // FIXME: hackhack
{
PKIPCR KPCR;
PKPRCB Prcb;
BOOLEAN NpxPresent;
ULONG FeatureBits;
+ ULONG DriverSize;
extern USHORT KiBootGdt[];
extern KTSS KiBootTss;
@@ -187,6 +189,12 @@
KeInitExceptions();
KeInitInterrupts();
+ /* Load the Kernel with the PE Loader */
+ LdrSafePEProcessModule((PVOID)KERNEL_BASE,
+ (PVOID)KERNEL_BASE,
+ (PVOID)DriverBase,
+ &DriverSize);
+
/* Detect and set the CPU Type */
KiSetProcessorType();
@@ -246,40 +254,79 @@
}
}
- if (KeFeatureBits & KF_GLOBAL_PAGE)
- {
- ULONG Flags;
- /* Enable global pages */
- Ke386GlobalPagesEnabled = TRUE;
- Ke386SaveFlags(Flags);
- Ke386DisableInterrupts();
- Ke386SetCr4(Ke386GetCr4() | X86_CR4_PGE);
- Ke386RestoreFlags(Flags);
- }
-
- if (KeFeatureBits & KF_FAST_SYSCALL)
- {
- extern void KiFastCallEntry(void);
-
- /* CS Selector of the target segment. */
- Ke386Wrmsr(0x174, KGDT_R0_CODE, 0);
- /* Target ESP. */
- Ke386Wrmsr(0x175, 0, 0);
- /* Target EIP. */
- Ke386Wrmsr(0x176, (ULONG_PTR)KiFastCallEntry, 0);
- }
-
- /* Does the CPU Support 'prefetchnta' (SSE) */
- if(KeFeatureBits & KF_XMMI)
- {
- ULONG Protect;
-
- Protect = MmGetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal);
- MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect |
PAGE_IS_WRITABLE);
- /* Replace the ret by a nop */
- *(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
- MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect);
- }
+ if (KeFeatureBits & KF_GLOBAL_PAGE)
+ {
+ ULONG Flags;
+ /* Enable global pages */
+ Ke386GlobalPagesEnabled = TRUE;
+ Ke386SaveFlags(Flags);
+ Ke386DisableInterrupts();
+ Ke386SetCr4(Ke386GetCr4() | X86_CR4_PGE);
+ Ke386RestoreFlags(Flags);
+ }
+
+ if (KeFeatureBits & KF_FAST_SYSCALL)
+ {
+ extern void KiFastCallEntry(void);
+
+ /* CS Selector of the target segment. */
+ Ke386Wrmsr(0x174, KGDT_R0_CODE, 0);
+ /* Target ESP. */
+ Ke386Wrmsr(0x175, 0, 0);
+ /* Target EIP. */
+ Ke386Wrmsr(0x176, (ULONG_PTR)KiFastCallEntry, 0);
+ }
+
+ /* Does the CPU Support 'prefetchnta' (SSE) */
+ if(KeFeatureBits & KF_XMMI)
+ {
+ ULONG Protect;
+
+ Protect = MmGetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal);
+ MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect |
PAGE_IS_WRITABLE);
+ /* Replace the ret by a nop */
+ *(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
+ MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect);
+ }
+
+ /* Initialize the Debugger */
+ KdInitSystem (0, &KeLoaderBlock);
+
+ /* Initialize HAL */
+ HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+
+ /* Initialize the Processor with HAL */
+ HalInitializeProcessor(KeNumberProcessors,
(PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
+
+ /* Initialize the Kernel Executive */
+ ExpInitializeExecutive();
+
+ /* Create the IOPM Save Area */
+ Ki386IopmSaveArea = ExAllocatePoolWithTag(NonPagedPool,
+ PAGE_SIZE * 2,
+ TAG('K', 'e', ' ',
' '));
+
+ /* Free Initial Memory */
+ MiFreeInitMemory();
+
+ /* Never returns */
+#if 0
+ /* FIXME:
+ * The initial thread isn't a real ETHREAD object, we cannot call
PspExitThread.
+ */
+ PspExitThread(STATUS_SUCCESS);
+#else
+ while (1)
+ {
+ LARGE_INTEGER Timeout;
+ Timeout.QuadPart = 0x7fffffffffffffffLL;
+ KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
+ }
+#endif
+
+ /* Bug Check and loop forever if anything failed */
+ KEBUGCHECK(0);
+ for(;;);
}
VOID
@@ -287,41 +334,13 @@
NTAPI
KeInit2(VOID)
{
- ULONG Protect;
- PKIPCR Pcr = (PKIPCR)KeGetPcr();
- PKPRCB Prcb = Pcr->Prcb;
-
- KiInitializeBugCheck();
- KeInitializeDispatcher();
- KiInitializeSystemClock();
-
- DPRINT1("CPU Detection Complete.\n"
- "CPUID: %lx\n"
- "Step : %lx\n"
- "Type : %lx\n"
- "ID : %s\n"
- "FPU : %lx\n"
- "XMMI : %lx\n"
- "Fxsr : %lx\n"
- "Feat : %lx\n"
- "Ftrs : %lx\n"
- "Cache: %lx\n"
- "CR0 : %lx\n"
- "CR4 : %lx\n",
- Prcb->CpuID,
- Prcb->CpuStep,
- Prcb->CpuType,
- Prcb->VendorString,
- KeI386NpxPresent,
- KeI386XMMIPresent,
- KeI386FxsrPresent,
- Prcb->FeatureBits,
- KeFeatureBits,
- Pcr->SecondLevelCacheSize,
- Ke386GetCr0(),
- Ke386GetCr4());
-
- /* Set IDT to writable */
- Protect = MmGetPageProtect(NULL, (PVOID)KiIdt);
- MmSetPageProtect(NULL, (PVOID)KiIdt, Protect | PAGE_IS_WRITABLE);
+ ULONG Protect;
+
+ KiInitializeBugCheck();
+ KeInitializeDispatcher();
+ KiInitializeSystemClock();
+
+ /* Set IDT to writable */
+ Protect = MmGetPageProtect(NULL, (PVOID)KiIdt);
+ MmSetPageProtect(NULL, (PVOID)KiIdt, Protect | PAGE_IS_WRITABLE);
}
Modified: trunk/reactos/ntoskrnl/ke/i386/main_asm.S
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/main_asm.…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/main_asm.S (original)
+++ trunk/reactos/ntoskrnl/ke/i386/main_asm.S Fri Sep 1 17:13:08 2006
@@ -49,29 +49,11 @@
mov es, ax
.att_syntax
- cmpl $AP_MAGIC, %ecx
- jne .m1
-
- pushl $0
- popfl
-
- /*
- * Reserve space for the floating point save area.
- */
- subl $SIZEOF_FX_SAVE_AREA, %esp
-
- /*
- * Call the application processor initialization code
- */
- pushl $0
- call _KiSystemStartup@4
-
-.m1:
/* Load the initial kernel stack */
lea _kernel_stack_top, %eax
sub $(SIZEOF_FX_SAVE_AREA), %eax
movl %eax, %esp
-
+
/* Call the main kernel initialization */
pushl %edx
call _KiRosPrepareForSystemStartup@4
Modified: trunk/reactos/ntoskrnl/ke/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/main.c?rev=238…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/main.c (original)
+++ trunk/reactos/ntoskrnl/ke/main.c Fri Sep 1 17:13:08 2006
@@ -86,53 +86,7 @@
VOID
NTAPI
-KiSystemStartup(BOOLEAN BootProcessor)
-{
- DPRINT("KiSystemStartup(%d)\n", BootProcessor);
-
- /* Initialize the Debugger */
- KdInitSystem (0, &KeLoaderBlock);
-
- /* Initialize HAL */
- HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
-
- /* Initialize the Processor with HAL */
- HalInitializeProcessor(KeNumberProcessors,
(PLOADER_PARAMETER_BLOCK)&KeLoaderBlock);
-
- /* Initialize the Kernel Executive */
- ExpInitializeExecutive();
-
- /* Create the IOPM Save Area */
- Ki386IopmSaveArea = ExAllocatePoolWithTag(NonPagedPool,
- PAGE_SIZE * 2,
- TAG('K', 'e', ' ',
' '));
-
- /* Free Initial Memory */
- MiFreeInitMemory();
-
- /* Never returns */
-#if 0
- /* FIXME:
- * The initial thread isn't a real ETHREAD object, we cannot call
PspExitThread.
- */
- PspExitThread(STATUS_SUCCESS);
-#else
- while (1)
- {
- LARGE_INTEGER Timeout;
- Timeout.QuadPart = 0x7fffffffffffffffLL;
- KeDelayExecutionThread(KernelMode, FALSE, &Timeout);
- }
-#endif
-
- /* Bug Check and loop forever if anything failed */
- KEBUGCHECK(0);
- for(;;);
-}
-
-VOID
-NTAPI
-KiRosPrepareForSystemStartup(PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
+KiRosPrepareForSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
{
ULONG i;
ULONG size;
@@ -266,21 +220,12 @@
/* Increase the last kernel address with the size of HAL */
LastKernelAddress += PAGE_ROUND_UP(DriverSize);
- /* FIXME: We need to do this in KiSystemStartup! */
- KeInit1();
-
- /* Load the Kernel with the PE Loader */
- LdrSafePEProcessModule((PVOID)KERNEL_BASE,
- (PVOID)KERNEL_BASE,
- (PVOID)DriverBase,
- &DriverSize);
-
/* Now select the final beginning and ending Kernel Addresses */
FirstKrnlPhysAddr = KeLoaderModules[0].ModStart - KERNEL_BASE + 0x200000;
LastKrnlPhysAddr = LastKernelAddress - KERNEL_BASE + 0x200000;
/* Do general System Startup */
- KiSystemStartup(1);
+ KiSystemStartup(LoaderBlock, DriverBase);
}
/* EOF */