- Re-merge 24062+24063, with a minor difference, they work now.
authorAlex Ionescu <aionescu@gmail.com>
Tue, 12 Sep 2006 13:54:52 +0000 (13:54 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Tue, 12 Sep 2006 13:54:52 +0000 (13:54 +0000)
svn path=/trunk/; revision=24080

reactos/ntoskrnl/ke/i386/ctxswitch.S
reactos/ntoskrnl/ntoskrnl.rbuild
reactos/ntoskrnl/ps/idle.c [deleted file]
reactos/ntoskrnl/ps/psmgr.c

index 6cfa4f9..04a16d1 100644 (file)
@@ -544,10 +544,19 @@ MainLoop:
 #endif
     jz CheckSchedule
 
+    /* Raise to DISPATCH_LEVEL */
+    mov ecx, DISPATCH_LEVEL
+    call @KfRaiseIrql@4
+    mov edi, eax
+
     /* Handle the above */
     lea ecx, [ebx+KPCR_PRCB_DATA]
     call @KiRetireDpcList@4
 
+    /* Lower IRQL */
+    mov ecx, edi
+    call @KfLowerIrql@4
+
 CheckSchedule:
     /* Check if a next thread is queued */
     cmp dword ptr [ebx+KPCR_PRCB_NEXT_THREAD], 0
index 30f4e23..ce34147 100644 (file)
        </directory>
        <directory name="ps">
                        <file>debug.c</file>
-                       <file>idle.c</file>
                        <file>job.c</file>
                        <file>kill.c</file>
                        <file>notify.c</file>
diff --git a/reactos/ntoskrnl/ps/idle.c b/reactos/ntoskrnl/ps/idle.c
deleted file mode 100644 (file)
index e46a744..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/ps/idle.c
- * PURPOSE:         Using idle time
- *
- * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
- *                  David Welch (welch@cwcom.net)
- */
-
-/* INCLUDES *****************************************************************/
-
-#include <ntoskrnl.h>
-#define NDEBUG
-#include <internal/debug.h>
-
-#if defined (ALLOC_PRAGMA)
-#pragma alloc_text(INIT, PsInitIdleThread)
-#endif
-
-/* FUNCTIONS *****************************************************************/
-
-/** System idle thread procedure
- *
- */
-VOID STDCALL
-PsIdleThreadMain(PVOID Context)
-{
-   KIRQL oldlvl;
-
-   PKPRCB Prcb = KeGetCurrentPrcb();
-
-   for(;;)
-     {
-       if (Prcb->DpcData[0].DpcQueueDepth > 0)
-        {
-          KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
-          KiDispatchInterrupt();
-          KeLowerIrql(oldlvl);
-        }
-
-       NtYieldExecution();
-
-       Ke386HaltProcessor();
-     }
-}
-
-/*
- * HACK-O-RAMA
- * Antique vestigial code left alive for the sole purpose of First/Idle Thread
- * creation until I can merge my fix for properly creating them.
- */
-NTSTATUS
-NTAPI
-PsInitializeIdleOrFirstThread(PEPROCESS Process,
-                              PETHREAD* ThreadPtr,
-                              PKSTART_ROUTINE StartRoutine,
-                              KPROCESSOR_MODE AccessMode,
-                              BOOLEAN First)
-{
-    PETHREAD Thread;
-    PVOID KernelStack;
-
-    Thread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
-    RtlZeroMemory(Thread, sizeof(ETHREAD));
-    Thread->ThreadsProcess = Process;
-    if (First)
-    {
-        KernelStack = P0BootStack;
-    }
-    else
-    {
-        KernelStack = (PVOID)((ULONG_PTR)MmCreateKernelStack(FALSE) +
-                              KERNEL_STACK_SIZE);
-    }
-    KeInitializeThread(&Process->Pcb,
-                       &Thread->Tcb,
-                       PspSystemThreadStartup,
-                       StartRoutine,
-                       NULL,
-                       NULL,
-                       NULL,
-                       KernelStack);
-    InitializeListHead(&Thread->IrpList);
-    *ThreadPtr = Thread;
-    return STATUS_SUCCESS;
-}
-
-/*
- * HACK-O-RAMA
- * Antique vestigial code left alive for the sole purpose of First/Idle Thread
- * creation until I can merge my fix for properly creating them.
- */
-VOID
-INIT_FUNCTION
-NTAPI
-PsInitIdleThread(VOID)
-{
-    PETHREAD IdleThread;
-    KIRQL oldIrql;
-
-    PsInitializeIdleOrFirstThread(PsIdleProcess,
-                                  &IdleThread,
-                                  PsIdleThreadMain,
-                                  KernelMode,
-                                  FALSE);
-
-    oldIrql = KiAcquireDispatcherLock ();
-    KiReadyThread(&IdleThread->Tcb);
-    KiReleaseDispatcherLock(oldIrql);
-
-    KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
-    KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
-    KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
-}
index df6d3c2..1346d98 100644 (file)
@@ -64,6 +64,75 @@ NTSTATUS STDCALL INIT_FUNCTION PspLookupKernelUserEntryPoints(VOID);
 
 /* FUNCTIONS ***************************************************************/
 
+VOID
+FASTCALL
+KiIdleLoop(VOID);
+
+/* FUNCTIONS *****************************************************************/
+
+/*
+ * HACK-O-RAMA
+ * Antique vestigial code left alive for the sole purpose of First/Idle Thread
+ * creation until I can merge my fix for properly creating them.
+ */
+VOID
+INIT_FUNCTION
+NTAPI
+PsInitHackThread(VOID)
+{
+    PETHREAD IdleThread;
+    KIRQL oldIrql;
+
+    IdleThread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
+    RtlZeroMemory(IdleThread, sizeof(ETHREAD));
+    IdleThread->ThreadsProcess = PsIdleProcess;
+    KeInitializeThread(&PsIdleProcess->Pcb,
+                       &IdleThread->Tcb,
+                       PspSystemThreadStartup,
+                       (PVOID)KiIdleLoop,
+                       NULL,
+                       NULL,
+                       NULL,
+                       (PVOID)((ULONG_PTR)MmCreateKernelStack(FALSE) +
+                              KERNEL_STACK_SIZE));
+    InitializeListHead(&IdleThread->IrpList);
+
+    oldIrql = KiAcquireDispatcherLock ();
+    KiReadyThread(&IdleThread->Tcb);
+    KiReleaseDispatcherLock(oldIrql);
+
+    KeGetCurrentPrcb()->IdleThread = &IdleThread->Tcb;
+    KeSetPriorityThread(&IdleThread->Tcb, LOW_PRIORITY);
+    KeSetAffinityThread(&IdleThread->Tcb, 1 << 0);
+}
+
+/*
+ * HACK-O-RAMA
+ * Antique vestigial code left alive for the sole purpose of First/Idle Thread
+ * creation until I can merge my fix for properly creating them.
+ */
+VOID
+INIT_FUNCTION
+NTAPI
+PsInitHackThread2(IN PETHREAD *Hack)
+{
+    PETHREAD IdleThread;
+
+    IdleThread = ExAllocatePool(NonPagedPool, sizeof(ETHREAD));
+    RtlZeroMemory(IdleThread, sizeof(ETHREAD));
+    IdleThread->ThreadsProcess = PsInitialSystemProcess;
+    KeInitializeThread(&PsInitialSystemProcess->Pcb,
+                       &IdleThread->Tcb,
+                       PspSystemThreadStartup,
+                       NULL,
+                       NULL,
+                       NULL,
+                       NULL,
+                       P0BootStack);
+    InitializeListHead(&IdleThread->IrpList);
+    *Hack = IdleThread;
+}
+
 VOID
 INIT_FUNCTION
 NTAPI
@@ -72,7 +141,7 @@ PiInitProcessManager(VOID)
    PsInitJobManagment();
    PsInitProcessManagment();
    PsInitThreadManagment();
-   PsInitIdleThread();
+   PsInitHackThread();
 }
 
 VOID
@@ -115,7 +184,7 @@ PsInitThreadManagment(VOID)
     ObjectTypeInitializer.DeleteProcedure = PspDeleteThread;
     ObCreateObjectType(&Name, &ObjectTypeInitializer, NULL, &PsThreadType);
 
-   PsInitializeIdleOrFirstThread(PsInitialSystemProcess, &FirstThread, NULL, KernelMode, TRUE);
+   PsInitHackThread2(&FirstThread);
    FirstThread->Tcb.State = Running;
    FirstThread->Tcb.FreezeCount = 0;
    FirstThread->Tcb.UserAffinity = (1 << 0);   /* Set the affinity of the first thread to the boot processor */