diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index 5fa707d5726..11570bf5a59 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -40,6 +40,7 @@ VOID KeSetGdtSelector(ULONG Entry, ULONG Value1, ULONG Value2); struct _KTHREAD; struct _KIRQ_TRAPFRAME; +struct _KPCR; VOID STDCALL DbgBreakPointNoBugCheck(VOID); @@ -100,7 +101,7 @@ extern LARGE_INTEGER SystemBootTime; VOID KeInitExceptions(VOID); VOID KeInitInterrupts(VOID); VOID KeInitTimer(VOID); -VOID KeInitDpc(VOID); +VOID KeInitDpc(struct _KPCR* Pcr); VOID KeInitDispatcher(VOID); VOID KeInitializeDispatcher(VOID); VOID KeInitializeTimerImpl(VOID); diff --git a/reactos/ntoskrnl/ke/dpc.c b/reactos/ntoskrnl/ke/dpc.c index 1b9de455636..f2284655051 100644 --- a/reactos/ntoskrnl/ke/dpc.c +++ b/reactos/ntoskrnl/ke/dpc.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dpc.c,v 1.41 2004/10/30 23:48:56 navaraf Exp $ +/* $Id: dpc.c,v 1.42 2004/10/31 13:20:58 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -288,13 +288,11 @@ KeSetTargetProcessorDpc (IN PKDPC Dpc, } VOID INIT_FUNCTION -KeInitDpc(VOID) +KeInitDpc(PKPCR Pcr) /* * FUNCTION: Initialize DPC handling */ { - PKPCR Pcr; - Pcr = KeGetCurrentKPCR(); InitializeListHead(&Pcr->PrcbData.DpcData[0].DpcListHead); KeInitializeSpinLock(&Pcr->PrcbData.DpcData[0].DpcLock); Pcr->PrcbData.MaximumDpcQueueDepth = 0; diff --git a/reactos/ntoskrnl/ke/i386/kernel.c b/reactos/ntoskrnl/ke/i386/kernel.c index 0360b3df2f6..40b94f68ea0 100644 --- a/reactos/ntoskrnl/ke/i386/kernel.c +++ b/reactos/ntoskrnl/ke/i386/kernel.c @@ -35,7 +35,6 @@ ULONG KiPcrInitDone = 0; static ULONG PcrsAllocated = 0; -static PFN_TYPE PcrPages[MAXIMUM_PROCESSORS]; ULONG Ke386CpuidFlags, Ke386CpuidFlags2, Ke386CpuidExFlags; ULONG Ke386Cpuid = 0x300; ULONG Ke386CacheAlignment; @@ -128,15 +127,42 @@ Ki386GetCpuId(VOID) VOID INIT_FUNCTION KePrepareForApplicationProcessorInit(ULONG Id) { - MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &PcrPages[Id]); + DPRINT("KePrepareForApplicationProcessorInit(Id %d)\n", Id); + PFN_TYPE PrcPfn; + PKPCR Pcr; + + Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Id * PAGE_SIZE); + + MmRequestPageMemoryConsumer(MC_NPPOOL, TRUE, &PrcPfn); + MmCreateVirtualMappingForKernel((PVOID)Pcr, + PAGE_READWRITE, + &PrcPfn, + 1); + /* + * Create a PCR for this processor + */ + memset(Pcr, 0, PAGE_SIZE); + Pcr->ProcessorNumber = Id; + Pcr->Tib.Self = &Pcr->Tib; + Pcr->Self = Pcr; + Pcr->Irql = HIGH_LEVEL; + + /* Mark the end of the exception handler list */ + Pcr->Tib.ExceptionList = (PVOID)-1; + + KeInitDpc(Pcr); + + KiGdtPrepareForApplicationProcessorInit(Id); } VOID KeApplicationProcessorInit(VOID) { - PKPCR KPCR; ULONG Offset; + PKPCR Pcr; + + DPRINT("KeApplicationProcessorInit()\n"); if (Ke386CpuidFlags & X86_FEATURE_PGE) { @@ -150,30 +176,14 @@ KeApplicationProcessorInit(VOID) MiEnablePAE(NULL); } - /* - * Create a PCR for this processor - */ - Offset = InterlockedIncrement((LONG *)&PcrsAllocated) - 1; - KPCR = (PKPCR)(KPCR_BASE + (Offset * PAGE_SIZE)); - MmCreateVirtualMappingForKernel((PVOID)KPCR, - PAGE_READWRITE, - &PcrPages[Offset], - 1); - memset(KPCR, 0, PAGE_SIZE); - KPCR->ProcessorNumber = (UCHAR)Offset; - KPCR->Tib.Self = &KPCR->Tib; - KPCR->Self = KPCR; - KPCR->Irql = HIGH_LEVEL; - - /* Mark the end of the exception handler list */ - KPCR->Tib.ExceptionList = (PVOID)-1; + Offset = InterlockedIncrement(&PcrsAllocated) - 1; + Pcr = (PKPCR)((ULONG_PTR)KPCR_BASE + Offset * PAGE_SIZE); /* * Initialize the GDT */ - KiInitializeGdt(KPCR); - - KeInitDpc(); + KiInitializeGdt(Pcr); + /* * It is now safe to process interrupts @@ -228,6 +238,8 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) KiPcrInitDone = 1; PcrsAllocated++; + KeInitDpc(KPCR); + /* Mark the end of the exception handler list */ KPCR->Tib.ExceptionList = (PVOID)-1; @@ -307,7 +319,6 @@ KeInit1(PCHAR CommandLine, PULONG LastKernelAddress) VOID INIT_FUNCTION KeInit2(VOID) { - KeInitDpc(); KeInitializeBugCheck(); KeInitializeDispatcher(); KeInitializeTimerImpl();