:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[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
21 #include <internal/debug.h>
22
23 /* FUNCTIONS *****************************************************************/
24
25 NTSTATUS STDCALL 
26 NtSetSystemPowerState(IN POWER_ACTION SystemAction,
27                       IN SYSTEM_POWER_STATE MinSystemState,
28                       IN ULONG Flags)
29 {
30   /* Windows 2000 only */
31   return(STATUS_NOT_IMPLEMENTED);
32 }
33
34 NTSTATUS STDCALL 
35 NtShutdownSystem(IN SHUTDOWN_ACTION Action)
36 {
37    if (Action > ShutdownPowerOff)
38      return STATUS_INVALID_PARAMETER;
39
40    IoShutdownRegisteredDevices();
41    CmShutdownRegistry();
42    IoShutdownRegisteredFileSystems();
43    PiShutdownProcessManager();
44    MiShutdownMemoryManager();
45    
46    if (Action == ShutdownNoReboot)
47      {
48 #if 0
49         /* Switch off */
50         HalReturnToFirmware (FIRMWARE_OFF);
51 #else
52         PopSetSystemPowerState(PowerSystemShutdown);
53 #endif
54      }
55    else if (Action == ShutdownReboot)
56      {
57         HalReturnToFirmware (FIRMWARE_REBOOT);
58      }
59    else
60      {
61         HalReturnToFirmware (FIRMWARE_HALT);
62      }
63    
64    return STATUS_SUCCESS;
65 }
66
67 /* EOF */
68