mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 09:41:23 +00:00
- More initialization cleanup.
svn path=/trunk/; revision=23866
This commit is contained in:
parent
562f8391e8
commit
a85e942346
4 changed files with 91 additions and 144 deletions
|
@ -611,8 +611,9 @@ Phase1Initialization(PVOID Context);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KeInit1(
|
KiSystemStartup(
|
||||||
VOID
|
IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
|
IN ULONG DriverBase // FIXME: hackhack
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -149,12 +149,14 @@ KiInitSpinLocks(IN PKPRCB Prcb,
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KeInit1(VOID)
|
KiSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
|
IN ULONG DriverBase) // FIXME: hackhack
|
||||||
{
|
{
|
||||||
PKIPCR KPCR;
|
PKIPCR KPCR;
|
||||||
PKPRCB Prcb;
|
PKPRCB Prcb;
|
||||||
BOOLEAN NpxPresent;
|
BOOLEAN NpxPresent;
|
||||||
ULONG FeatureBits;
|
ULONG FeatureBits;
|
||||||
|
ULONG DriverSize;
|
||||||
extern USHORT KiBootGdt[];
|
extern USHORT KiBootGdt[];
|
||||||
extern KTSS KiBootTss;
|
extern KTSS KiBootTss;
|
||||||
|
|
||||||
|
@ -187,6 +189,12 @@ KeInit1(VOID)
|
||||||
KeInitExceptions();
|
KeInitExceptions();
|
||||||
KeInitInterrupts();
|
KeInitInterrupts();
|
||||||
|
|
||||||
|
/* Load the Kernel with the PE Loader */
|
||||||
|
LdrSafePEProcessModule((PVOID)KERNEL_BASE,
|
||||||
|
(PVOID)KERNEL_BASE,
|
||||||
|
(PVOID)DriverBase,
|
||||||
|
&DriverSize);
|
||||||
|
|
||||||
/* Detect and set the CPU Type */
|
/* Detect and set the CPU Type */
|
||||||
KiSetProcessorType();
|
KiSetProcessorType();
|
||||||
|
|
||||||
|
@ -280,6 +288,45 @@ KeInit1(VOID)
|
||||||
*(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
|
*(PCHAR)RtlPrefetchMemoryNonTemporal = 0x90;
|
||||||
MmSetPageProtect(NULL, (PVOID)RtlPrefetchMemoryNonTemporal, Protect);
|
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
|
VOID
|
||||||
|
@ -288,39 +335,11 @@ NTAPI
|
||||||
KeInit2(VOID)
|
KeInit2(VOID)
|
||||||
{
|
{
|
||||||
ULONG Protect;
|
ULONG Protect;
|
||||||
PKIPCR Pcr = (PKIPCR)KeGetPcr();
|
|
||||||
PKPRCB Prcb = Pcr->Prcb;
|
|
||||||
|
|
||||||
KiInitializeBugCheck();
|
KiInitializeBugCheck();
|
||||||
KeInitializeDispatcher();
|
KeInitializeDispatcher();
|
||||||
KiInitializeSystemClock();
|
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 */
|
/* Set IDT to writable */
|
||||||
Protect = MmGetPageProtect(NULL, (PVOID)KiIdt);
|
Protect = MmGetPageProtect(NULL, (PVOID)KiIdt);
|
||||||
MmSetPageProtect(NULL, (PVOID)KiIdt, Protect | PAGE_IS_WRITABLE);
|
MmSetPageProtect(NULL, (PVOID)KiIdt, Protect | PAGE_IS_WRITABLE);
|
||||||
|
|
|
@ -49,24 +49,6 @@ _NtProcessStartup:
|
||||||
mov es, ax
|
mov es, ax
|
||||||
.att_syntax
|
.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 */
|
/* Load the initial kernel stack */
|
||||||
lea _kernel_stack_top, %eax
|
lea _kernel_stack_top, %eax
|
||||||
sub $(SIZEOF_FX_SAVE_AREA), %eax
|
sub $(SIZEOF_FX_SAVE_AREA), %eax
|
||||||
|
|
|
@ -86,53 +86,7 @@ KeGetRecommendedSharedDataAlignment(VOID)
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KiSystemStartup(BOOLEAN BootProcessor)
|
KiRosPrepareForSystemStartup(IN PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
ULONG size;
|
ULONG size;
|
||||||
|
@ -266,21 +220,12 @@ KiRosPrepareForSystemStartup(PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
/* Increase the last kernel address with the size of HAL */
|
/* Increase the last kernel address with the size of HAL */
|
||||||
LastKernelAddress += PAGE_ROUND_UP(DriverSize);
|
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 */
|
/* Now select the final beginning and ending Kernel Addresses */
|
||||||
FirstKrnlPhysAddr = KeLoaderModules[0].ModStart - KERNEL_BASE + 0x200000;
|
FirstKrnlPhysAddr = KeLoaderModules[0].ModStart - KERNEL_BASE + 0x200000;
|
||||||
LastKrnlPhysAddr = LastKernelAddress - KERNEL_BASE + 0x200000;
|
LastKrnlPhysAddr = LastKernelAddress - KERNEL_BASE + 0x200000;
|
||||||
|
|
||||||
/* Do general System Startup */
|
/* Do general System Startup */
|
||||||
KiSystemStartup(1);
|
KiSystemStartup(LoaderBlock, DriverBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue