94b3159cfa896d3d75ef6c7ed293166a1022d949
[reactos.git] / ntoskrnl / ex / power.c
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS kernel
4  * FILE:            ntoskrnl/ex/power.c
5  * PURPOSE:         Power managment
6  * PROGRAMMER:      David Welch (welch@cwcom.net)
7  * UPDATE HISTORY:
8  *                  Created 22/05/98
9  *                  Added reboot support 30/01/99
10  */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <roscfg.h>
16 #include <internal/ps.h>
17 #include <internal/io.h>
18 #include <internal/mm.h>
19 #include <internal/po.h>
20 #include <internal/cc.h>
21
22 #include <internal/debug.h>
23
24 /* FUNCTIONS *****************************************************************/
25
26 NTSTATUS STDCALL 
27 NtSetSystemPowerState(IN POWER_ACTION SystemAction,
28                       IN SYSTEM_POWER_STATE MinSystemState,
29                       IN ULONG Flags)
30 {
31   /* Windows 2000 only */
32   return(STATUS_NOT_IMPLEMENTED);
33 }
34
35 NTSTATUS STDCALL 
36 NtShutdownSystem(IN SHUTDOWN_ACTION Action)
37 {
38    if (Action > ShutdownPowerOff)
39      return STATUS_INVALID_PARAMETER;
40
41    IoShutdownRegisteredDevices();
42    CmShutdownRegistry();
43    IoShutdownRegisteredFileSystems();
44
45    PiShutdownProcessManager();
46    MiShutdownMemoryManager();
47    
48    if (Action == ShutdownNoReboot)
49      {
50 #if 0
51         /* Switch off */
52         HalReturnToFirmware (FIRMWARE_OFF);
53 #else
54         PopSetSystemPowerState(PowerSystemShutdown);
55         __asm__("cli\n");
56         while (TRUE)
57           {
58             ;
59           }
60 #endif
61      }
62    else if (Action == ShutdownReboot)
63      {
64         HalReturnToFirmware (FIRMWARE_REBOOT);
65      }
66    else
67      {
68         HalReturnToFirmware (FIRMWARE_HALT);
69      }
70    
71    return STATUS_SUCCESS;
72 }
73
74 /* EOF */
75