2004-08-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / 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 <ntoskrnl.h>
15 #include <internal/debug.h>
16
17 /* FUNCTIONS *****************************************************************/
18
19 NTSTATUS STDCALL
20 NtSetSystemPowerState(IN POWER_ACTION SystemAction,
21 IN SYSTEM_POWER_STATE MinSystemState,
22 IN ULONG Flags)
23 {
24 /* Windows 2000 only */
25 return(STATUS_NOT_IMPLEMENTED);
26 }
27
28 /*
29 * @implemented
30 */
31 NTSTATUS STDCALL
32 NtShutdownSystem(IN SHUTDOWN_ACTION Action)
33 {
34 if (Action > ShutdownPowerOff)
35 return STATUS_INVALID_PARAMETER;
36
37 IoShutdownRegisteredDevices();
38 CmShutdownRegistry();
39 IoShutdownRegisteredFileSystems();
40
41 PiShutdownProcessManager();
42 MiShutdownMemoryManager();
43
44 if (Action == ShutdownNoReboot)
45 {
46 #if 0
47 /* Switch off */
48 HalReturnToFirmware (FIRMWARE_OFF);
49 #else
50 PopSetSystemPowerState(PowerSystemShutdown);
51
52 Ke386DisableInterrupts();
53
54 while (TRUE)
55 {
56 ;
57 }
58 #endif
59 }
60 else if (Action == ShutdownReboot)
61 {
62 HalReturnToFirmware (FIRMWARE_REBOOT);
63 }
64 else
65 {
66 HalReturnToFirmware (FIRMWARE_HALT);
67 }
68
69 return STATUS_SUCCESS;
70 }
71
72 /* EOF */
73