From c19a362969b799e0af19a624f52de258041c7f1b Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 11 Sep 2006 06:50:19 +0000 Subject: [PATCH] - Implement HalProcessorIdle. - Fix KiIdleLoop to actuall load the PCR in EBX. It was using a completely random value. - Call the Processor Idle Routine now, isntead of hard-coding STI+HLT. This routine had already been setup during bootup by PoInitailizePrcb. - Implemented PopIdle0 and made it call HalProcessorIdle. No performance/throttling is done yet. svn path=/trunk/; revision=24063 --- reactos/hal/halx86/generic/misc.c | 12 ------------ reactos/hal/halx86/generic/processor.c | 8 ++++++++ reactos/include/ndk/asm.h | 1 + reactos/include/ndk/halfuncs.h | 10 ++++++++++ reactos/ntoskrnl/ke/i386/ctxswitch.S | 8 +++----- reactos/ntoskrnl/po/power.c | 7 ++++--- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/reactos/hal/halx86/generic/misc.c b/reactos/hal/halx86/generic/misc.c index a2378eed7d5..b5ecdfa7909 100644 --- a/reactos/hal/halx86/generic/misc.c +++ b/reactos/hal/halx86/generic/misc.c @@ -45,18 +45,6 @@ HalHandleNMI(PVOID NmiInfo) KeEnterKernelDebugger (); } - -VOID STDCALL -HalProcessorIdle(VOID) -{ -#if 1 - Ki386EnableInterrupts(); - Ki386HaltProcessor(); -#else - -#endif -} - ULONG FASTCALL HalSystemVectorDispatchEntry ( ULONG Unknown1, diff --git a/reactos/hal/halx86/generic/processor.c b/reactos/hal/halx86/generic/processor.c index d9c6a8d82ed..f2b3a60d892 100644 --- a/reactos/hal/halx86/generic/processor.c +++ b/reactos/hal/halx86/generic/processor.c @@ -47,4 +47,12 @@ HalStartNextProcessor(ULONG Unknown1, return TRUE; } +VOID +NTAPI +HalProcessorIdle(VOID) +{ + Ki386EnableInterrupts(); + Ki386HaltProcessor(); +} + /* EOF */ diff --git a/reactos/include/ndk/asm.h b/reactos/include/ndk/asm.h index 802b2d6582f..5d90b39a8c4 100644 --- a/reactos/include/ndk/asm.h +++ b/reactos/include/ndk/asm.h @@ -176,6 +176,7 @@ Author: #define KPCR_PRCB_TIMER_REQUEST 0xA88 #define KPCR_PRCB_QUANTUM_END 0xAA1 #define KPCR_PRCB_DEFERRED_READY_LIST_HEAD 0xC10 +#define KPCR_PRCB_POWER_STATE_IDLE_FUNCTION 0xEC0 // // KINTERRUPT Offsets diff --git a/reactos/include/ndk/halfuncs.h b/reactos/include/ndk/halfuncs.h index 2544e9de306..358f6255454 100644 --- a/reactos/include/ndk/halfuncs.h +++ b/reactos/include/ndk/halfuncs.h @@ -88,6 +88,16 @@ HalStartNextProcessor( ULONG Unknown2 ); +// +// CPU Routines +// +NTHALAPI +VOID +NTAPI +HalProcessorIdle( + VOID +); + // // Interrupt Functions // diff --git a/reactos/ntoskrnl/ke/i386/ctxswitch.S b/reactos/ntoskrnl/ke/i386/ctxswitch.S index 4f0fc71b9c2..6cfa4f9b5f0 100644 --- a/reactos/ntoskrnl/ke/i386/ctxswitch.S +++ b/reactos/ntoskrnl/ke/i386/ctxswitch.S @@ -518,18 +518,16 @@ BugCheckDpc: .func @KiIdleLoop@0, @KiIdleLoop@0 @KiIdleLoop@0: + /* Set EBX */ + mov ebx, fs:[KPCR_SELF] + /* Jump into mainline code */ jmp MainLoop CpuIdle: /* Call the CPU's idle function */ -#if 0 lea ecx, [ebx+KPCR_PRCB_POWER_STATE_IDLE_FUNCTION] call [ecx] -#else - sti - hlt -#endif MainLoop: /* Cycle interrupts for 1 cycle */ diff --git a/reactos/ntoskrnl/po/power.c b/reactos/ntoskrnl/po/power.c index 684b4a4189b..4589cba3c18 100644 --- a/reactos/ntoskrnl/po/power.c +++ b/reactos/ntoskrnl/po/power.c @@ -340,9 +340,10 @@ PopPerfIdleDpc(IN PKDPC Dpc, VOID FASTCALL -PopIdle0(IN PKPRCB Prcb) +PopIdle0(IN PPROCESSOR_POWER_STATE PowerState) { - DPRINT1("Idle function: %p\n", Prcb); + /* FIXME: Extremly naive implementation */ + HalProcessorIdle(); } VOID @@ -358,7 +359,7 @@ PoInitializePrcb(IN PKPRCB Prcb) /* Initialize the Perf DPC and Timer */ KeInitializeDpc(&Prcb->PowerState.PerfDpc, PopPerfIdleDpc, Prcb); - //KeSetTargetProcessorDpc(&Prcb->PowerState.PerfDpc, Prcb->Number); + KeSetTargetProcessorDpc(&Prcb->PowerState.PerfDpc, Prcb->Number); KeInitializeTimerEx(&Prcb->PowerState.PerfTimer, SynchronizationTimer); }