- Sync to trunk 36919.
[reactos.git] / reactos / ntoskrnl / ex / shutdown.c
index f6dcc20..db8a92d 100644 (file)
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ex/power.c
 /* INCLUDES *****************************************************************/
 
 #include <ntoskrnl.h>
-#include <internal/debug.h>
+#include <debug.h>
 
 /* FUNCTIONS *****************************************************************/
 
-/* ROS Internal. Please deprecate */
-NTHALAPI
-VOID
-NTAPI
-HalReleaseDisplayOwnership(
-    VOID
-);
-
 VOID STDCALL
 KiHaltProcessorDpcRoutine(IN PKDPC Dpc,
                          IN PVOID DeferredContext,
                          IN PVOID SystemArgument1,
                          IN PVOID SystemArgument2)
 {
+   KIRQL OldIrql;
    if (DeferredContext)
      {
        ExFreePool(DeferredContext);
      }
    while (TRUE)
      {
-       KfRaiseIrql(SYNCH_LEVEL);
+       KeRaiseIrql(SYNCH_LEVEL, &OldIrql);
+#if defined(_M_X86)
        Ke386HaltProcessor();
+#else
+       HalProcessorIdle();
+#endif
      }
 }
 
@@ -44,7 +40,6 @@ VOID STDCALL
 ShutdownThreadMain(PVOID Context)
 {
    SHUTDOWN_ACTION Action = (SHUTDOWN_ACTION)Context;
-   LARGE_INTEGER Waittime;
 
    static PCH FamousLastWords[] =
      {
@@ -92,7 +87,7 @@ ShutdownThreadMain(PVOID Context)
        "Until then, there must be no regrets, no fears, no anxieties.\n"
        "Just go forward in all your beliefs, and prove to me that I am not mistaken in\n"
        "mine.\n",
-       "Lowest possible energy state reached! Switch off now to achive a Bose-Einstein\n"
+       "Lowest possible energy state reached! Switch off now to achieve a Bose-Einstein\n"
        "condensate.\n",
        "Hasta la vista, BABY!\n",
        "They live, we sleep!\n",
@@ -163,16 +158,12 @@ ShutdownThreadMain(PVOID Context)
      }
 
    PspShutdownProcessManager();
-   Waittime.QuadPart = (LONGLONG)-10000000; /* 1sec */
-   KeDelayExecutionThread(KernelMode, FALSE, &Waittime);
 
-   CmShutdownRegistry();
+   CmShutdownSystem();
+   MiShutdownMemoryManager();
    IoShutdownRegisteredFileSystems();
    IoShutdownRegisteredDevices();
 
-   MiShutdownMemoryManager();
-
-
    if (Action == ShutdownNoReboot)
      {
         HalDisplayString("\nYou can switch off your computer now\n");
@@ -194,7 +185,7 @@ ShutdownThreadMain(PVOID Context)
                PKDPC Dpc = ExAllocatePool(NonPagedPool, sizeof(KDPC));
                if (Dpc == NULL)
                  {
-                    KEBUGCHECK(0);
+                    ASSERT(FALSE);
                  }
                KeInitializeDpc(Dpc, KiHaltProcessorDpcRoutine, (PVOID)Dpc);
                KeSetTargetProcessorDpc(Dpc, i);
@@ -206,7 +197,7 @@ ShutdownThreadMain(PVOID Context)
 #endif /* CONFIG_SMP */
         PopSetSystemPowerState(PowerSystemShutdown);
 
-       CHECKPOINT1;
+       DPRINT1("Shutting down\n");
 
        KiHaltProcessorDpcRoutine(NULL, NULL, NULL, NULL);
        /* KiHaltProcessor does never return */
@@ -254,7 +245,7 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action)
                                  (PVOID)Action);
    if (!NT_SUCCESS(Status))
    {
-      KEBUGCHECK(0);
+      ASSERT(FALSE);
    }
    Status = ObReferenceObjectByHandle(ThreadHandle,
                                      THREAD_ALL_ACCESS,
@@ -265,7 +256,7 @@ NtShutdownSystem(IN SHUTDOWN_ACTION Action)
    NtClose(ThreadHandle);
    if (!NT_SUCCESS(Status))
      {
-        KEBUGCHECK(0);
+        ASSERT(FALSE);
      }
 
    KeSetPriorityThread(&ShutdownThread->Tcb, LOW_REALTIME_PRIORITY + 1);