Author: ion
Date: Sat Sep 30 11:04:49 2006
New Revision: 24308
URL: http://svn.reactos.org/svn/reactos?rev=24308&view=rev
Log:
- Save processor state in the PKPRCB in KiInitializeKernel.
- Set the booting CPU as idle if no next thread was scheduled.
- Raise IRQL to HIGH_LEVEL upon exiting KiInitializeKernel to match the re-lowering to DISPATCH_LEVEL in KiSystemStartup (and subsequent interrupt flush).
Modified:
trunk/reactos/ntoskrnl/include/internal/i386/ke.h
trunk/reactos/ntoskrnl/ke/i386/kiinit.c
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h Sat Sep 30 11:04:49 2006
@@ -65,6 +65,16 @@
);
VOID
+NTAPI
+KiSaveProcessorControlState(
+ IN PKPROCESSOR_STATE ProcessorState
+);
+
+VOID
+FASTCALL
+KiIdleLoop(VOID);
+
+VOID
KiGdtPrepareForApplicationProcessorInit(ULONG Id);
VOID
Ki386InitializeLdt(VOID);
Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Sat Sep 30 11:04:49 2006
@@ -14,10 +14,6 @@
#include <intrin.h>
/* GLOBALS *******************************************************************/
-
-VOID
-FASTCALL
-KiIdleLoop(VOID);
/* Spinlocks used only on X86 */
KSPIN_LOCK KiFreezeExecutionLock;
@@ -111,6 +107,9 @@
/* Save feature bits */
Prcb->FeatureBits = FeatureBits;
+ /* Save CPU state */
+ KiSaveProcessorControlState(&Prcb->ProcessorState);
+
/* Get cache line information for this CPU */
KiGetCacheInformation();
@@ -226,10 +225,17 @@
/* Set the Idle Priority to 0. This will jump into Phase 1 */
KeSetPriorityThread(InitThread, 0);
+
+ /* If there's no thread scheduled, put this CPU in the Idle summary */
+ if (!Prcb->NextThread) KiIdleSummary |= 1 << Number;
+
+ /* Raise back to HIGH_LEVEL and clear the PRCB for the loader block */
+ KfRaiseIrql(HIGH_LEVEL);
+ LoaderBlock->Prcb = 0;
}
VOID
-NTAPI
+FASTCALL
KiGetMachineBootPointers(IN PKGDTENTRY *Gdt,
IN PKIDTENTRY *Idt,
IN PKIPCR *Pcr,
Author: ion
Date: Sat Sep 30 10:18:45 2006
New Revision: 24307
URL: http://svn.reactos.org/svn/reactos?rev=24307&view=rev
Log:
- Add loop around the KiFreezeExecutionLock before continuing OS boot.
- Only check for break-in on the Boot CPU.
- Set priority to 0 *Before* lowering to DISPATCH_LEVEL.
- Also force interrupts to be enabled before lowering IRQL.
- Also set the idle thread's wait irql to DISPATCH_LEVEL (might fix some odd crashes) and set it as Running on UP builds (on SMP builds this is done in other code).
Modified:
trunk/reactos/ntoskrnl/ke/i386/kiinit.c
Modified: trunk/reactos/ntoskrnl/ke/i386/kiinit.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kiinit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kiinit.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kiinit.c Sat Sep 30 10:18:45 2006
@@ -335,8 +335,15 @@
Ke386SetDs(KGDT_R3_DATA | RPL_MASK);
Ke386SetEs(KGDT_R3_DATA | RPL_MASK);
+AppCpuInit:
+ /* Loop until we can release the freeze lock */
+ do
+ {
+ /* Loop until execution can continue */
+ while (KiFreezeExecutionLock == 1);
+ } while(InterlockedBitTestAndSet(&KiFreezeExecutionLock, 0));
+
/* Setup CPU-related fields */
-AppCpuInit:
__writefsdword(KPCR_NUMBER, Cpu);
__writefsdword(KPCR_SET_MEMBER, 1 << Cpu);
__writefsdword(KPCR_SET_MEMBER_COPY, 1 << Cpu);
@@ -349,11 +356,15 @@
KeActiveProcessors |= Pcr->SetMember;
KeNumberProcessors++;
- /* Initialize the Debugger for the Boot CPU */
- if (!Cpu) KdInitSystem (0, KeLoaderBlock);
-
- /* Check for break-in */
- if (KdPollBreakIn()) DbgBreakPointWithStatus(1);
+ /* Check if this is the boot CPU */
+ if (!Cpu)
+ {
+ /* Initialize debugging system */
+ KdInitSystem (0, KeLoaderBlock);
+
+ /* Check for break-in */
+ if (KdPollBreakIn()) DbgBreakPointWithStatus(1);
+ }
/* Raise to HIGH_LEVEL */
KfRaiseIrql(HIGH_LEVEL);
@@ -366,11 +377,20 @@
Cpu,
LoaderBlock);
- /* Lower IRQL back to DISPATCH_LEVEL */
- KfLowerIrql(DISPATCH_LEVEL);
-
/* Set the priority of this thread to 0 */
KeGetCurrentThread()->Priority = 0;
+
+ /* Force interrupts enabled and lower IRQL back to DISPATCH_LEVEL */
+ _enable();
+ KfLowerIrql(DISPATCH_LEVEL);
+
+ /* Set the right wait IRQL */
+ KeGetCurrentThread()->WaitIrql = DISPATCH_LEVEL;
+
+ /* Set idle thread as running on UP builds */
+#ifndef CONFIG_SMP
+ KeGetCurrentThread()->State = Running;
+#endif
/* Jump into the idle loop */
KiIdleLoop();