diff --git a/reactos/ntoskrnl/ke/i386/kernel.c b/reactos/ntoskrnl/ke/i386/kernel.c index 7348ccc6611..20d07553bfb 100644 --- a/reactos/ntoskrnl/ke/i386/kernel.c +++ b/reactos/ntoskrnl/ke/i386/kernel.c @@ -132,7 +132,9 @@ KePrepareForApplicationProcessorInit(ULONG Id) DPRINT("KePrepareForApplicationProcessorInit(Id %d)\n", Id); PFN_TYPE PrcPfn; PKPCR Pcr; + PKPCR BootPcr; + BootPcr = (PKPCR)KPCR_BASE; Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Id * PAGE_SIZE); MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &PrcPfn); @@ -147,14 +149,14 @@ KePrepareForApplicationProcessorInit(ULONG Id) Pcr->ProcessorNumber = Id; Pcr->Tib.Self = &Pcr->Tib; Pcr->Self = Pcr; - Pcr->Irql = HIGH_LEVEL; + Pcr->Irql = SYNCH_LEVEL; + + Pcr->PrcbData.MHz = BootPcr->PrcbData.MHz; + Pcr->StallScaleFactor = BootPcr->StallScaleFactor; /* Mark the end of the exception handler list */ Pcr->Tib.ExceptionList = (PVOID)-1; - KeInitDpc(Pcr); - - KiGdtPrepareForApplicationProcessorInit(Id); } @@ -172,11 +174,6 @@ KeApplicationProcessorInit(VOID) Ke386SetCr4(Ke386GetCr4() | X86_CR4_PGE); } - /* Enable PAE mode */ - if (Ke386PaeEnabled) - { - MiEnablePAE(NULL); - } Offset = InterlockedIncrement(&PcrsAllocated) - 1; Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Offset * PAGE_SIZE); @@ -192,6 +189,8 @@ KeApplicationProcessorInit(VOID) /* Check FPU/MMX/SSE support. */ KiCheckFPU(); + KeInitDpc(Pcr); + /* * It is now safe to process interrupts */ @@ -221,26 +220,16 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) extern USHORT KiBootGdt[]; extern KTSS KiBootTss; - /* Get processor information. */ - Ki386GetCpuId(); - - /* Check FPU/MMX/SSE support. */ - KiCheckFPU(); - - KiInitializeGdt (NULL); - Ki386BootInitializeTSS(); - KeInitExceptions (); - KeInitInterrupts (); - /* * Initialize the initial PCR region. We can't allocate a page * with MmAllocPage() here because MmInit1() has not yet been * called, so we use a predefined page in low memory */ + KPCR = (PKPCR)KPCR_BASE; memset(KPCR, 0, PAGE_SIZE); KPCR->Self = KPCR; - KPCR->Irql = HIGH_LEVEL; + KPCR->Irql = SYNCH_LEVEL; KPCR->Tib.Self = &KPCR->Tib; KPCR->GDT = KiBootGdt; KPCR->IDT = (PUSHORT)KiIdt; @@ -249,13 +238,24 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) KiPcrInitDone = 1; PcrsAllocated++; - KeInitDpc(KPCR); + KiInitializeGdt (NULL); + Ki386BootInitializeTSS(); + Ki386InitializeLdt(); + + /* Get processor information. */ + Ki386GetCpuId(); + + /* Check FPU/MMX/SSE support. */ + KiCheckFPU(); /* Mark the end of the exception handler list */ KPCR->Tib.ExceptionList = (PVOID)-1; - Ki386InitializeLdt(); - + KeInitDpc(KPCR); + + KeInitExceptions (); + KeInitInterrupts (); + if (KPCR->PrcbData.FeatureBits & X86_FEATURE_PGE) { ULONG Flags; diff --git a/reactos/ntoskrnl/ke/i386/multiboot.S b/reactos/ntoskrnl/ke/i386/multiboot.S index 9d7439e614a..c1529c0ba02 100644 --- a/reactos/ntoskrnl/ke/i386/multiboot.S +++ b/reactos/ntoskrnl/ke/i386/multiboot.S @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -188,6 +189,30 @@ _multiboot_entry: #ifdef MP .m1: + /* + * Check for pae mode (only possible for an application processor) + */ + + movl $(V2P(_Ke386Pae)), %eax + cmpb $0, (%eax) + je .m3 + + /* + * Set up the PDBR + */ + movl $(V2P(_pae_pagedirtable)), %eax + movl %eax, %cr3 + + /* + * Enable pae mode + */ + movl %cr4, %eax + orl $X86_CR4_PAE, %eax + movl %eax, %cr4 + + jmp .m4 + +.m3: #endif /* MP */ @@ -196,6 +221,10 @@ _multiboot_entry: */ movl $(V2P(startup_pagedirectory)), %eax movl %eax, %cr3 + +#ifdef MP +.m4: +#endif /* * Enable paging and set write protect @@ -245,6 +274,11 @@ _multiboot_entry: */ pushl $0 popfl + + /* + * Reserve space for the floating point save area. + */ + subl $SIZEOF_FX_SAVE_AREA, %esp /* * Call the application processor initialization code diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 03a4ad0043a..adb1f341733 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: main.c,v 1.208 2004/11/27 11:42:56 ekohl Exp $ +/* $Id: main.c,v 1.209 2004/11/28 01:31:08 hbirr Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/main.c @@ -509,24 +509,23 @@ ExpInitializeExecutive(VOID) } /* Initialize all processors */ - KeNumberProcessors = 0; + KeNumberProcessors = 1; while (!HalAllProcessorsStarted()) { PVOID ProcessorStack; - if (KeNumberProcessors != 0) - { - KePrepareForApplicationProcessorInit(KeNumberProcessors); - PsPrepareForApplicationProcessorInit(KeNumberProcessors); - } + KePrepareForApplicationProcessorInit(KeNumberProcessors); + PsPrepareForApplicationProcessorInit(KeNumberProcessors); + /* Allocate a stack for use when booting the processor */ /* FIXME: The nonpaged memory for the stack is not released after use */ ProcessorStack = (char*)ExAllocatePool(NonPagedPool, MM_STACK_SIZE) + MM_STACK_SIZE; Ki386InitialStackArray[((int)KeNumberProcessors)] = (PVOID)((char*)ProcessorStack - MM_STACK_SIZE); - HalInitializeProcessor(KeNumberProcessors, ProcessorStack); + + HalStartNextProcessor(0, (ULONG)ProcessorStack - 2*sizeof(FX_SAVE_AREA)); KeNumberProcessors++; } @@ -848,21 +847,30 @@ ExpInitializeExecutive(VOID) VOID __attribute((noinline)) KiSystemStartup(BOOLEAN BootProcessor) { - HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); + if (BootProcessor) + { + } + else + { + KeApplicationProcessorInit(); + } + + HalInitializeProcessor(KeNumberProcessors, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); if (BootProcessor) - { - ExpInitializeExecutive(); - MiFreeInitMemory(); - /* Never returns */ - PsTerminateSystemThread(STATUS_SUCCESS); - KEBUGCHECK(0); - } - /* Do application processor initialization */ - KeApplicationProcessorInit(); - PsApplicationProcessorInit(); - KeLowerIrql(PASSIVE_LEVEL); - PsIdleThreadMain(NULL); + { + ExpInitializeExecutive(); + MiFreeInitMemory(); + /* Never returns */ + PsTerminateSystemThread(STATUS_SUCCESS); + } + else + { + /* Do application processor initialization */ + PsApplicationProcessorInit(); + KeLowerIrql(PASSIVE_LEVEL); + PsIdleThreadMain(NULL); + } KEBUGCHECK(0); for(;;); } @@ -989,10 +997,6 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) /* Low level architecture specific initialization */ KeInit1((PCHAR)KeLoaderBlock.CommandLine, &LastKernelAddress); -#ifdef HAL_DBG - HalnInitializeDisplay((PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); -#endif - HalBase = KeLoaderModules[1].ModStart; DriverBase = LastKernelAddress; LdrHalBase = (ULONG_PTR)DriverBase; @@ -1036,8 +1040,17 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) KeMemoryMapRangeCount++; i += size; } + KeLoaderBlock.MmapLength = KeMemoryMapRangeCount * sizeof(ADDRESS_RANGE); + KeLoaderBlock.MmapAddr = (ULONG)KeMemoryMap; } - + else + { + KeLoaderBlock.MmapLength = 0; + KeLoaderBlock.MmapAddr = (ULONG)KeMemoryMap; + } + + HalInitSystem (0, (PLOADER_PARAMETER_BLOCK)&KeLoaderBlock); + KiSystemStartup(1); }