1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: ReactOS kernel 4 * FILE: ntoskrnl/ex/shutdown.c 5 * PURPOSE: Power management 6 * 7 * PROGRAMMERS: David Welch (welch@cwcom.net) 8 */ 9 10 /* INCLUDES *****************************************************************/ 11 12 #include <ntoskrnl.h> 13 14 #define NDEBUG 15 #include <debug.h> 16 17 /* PRIVATE FUNCTIONS *********************************************************/ 18 19 VOID 20 NTAPI 21 ExShutdownSystem(VOID) 22 { 23 /* Dereference the hard-error port and process objects */ 24 if (ExpDefaultErrorPort) 25 { 26 ObDereferenceObject(ExpDefaultErrorPort); 27 ExpDefaultErrorPort = NULL; 28 } 29 if (ExpDefaultErrorPortProcess) 30 { 31 ObDereferenceObject(ExpDefaultErrorPortProcess); 32 ExpDefaultErrorPortProcess = NULL; 33 } 34 } 35 36 /* FUNCTIONS *****************************************************************/ 37 38 /* 39 * @implemented 40 */ 41 NTSTATUS 42 NTAPI 43 NtShutdownSystem(IN SHUTDOWN_ACTION Action) 44 { 45 POWER_ACTION PowerAction; 46 47 /* Convert to power action */ 48 if (Action == ShutdownNoReboot) 49 { 50 PowerAction = PowerActionShutdown; 51 } 52 else if (Action == ShutdownReboot) 53 { 54 PowerAction = PowerActionShutdownReset; 55 } 56 else if (Action == ShutdownPowerOff) 57 { 58 PowerAction = PowerActionShutdownOff; 59 } 60 else 61 { 62 return STATUS_INVALID_PARAMETER; 63 } 64 65 /* Now call the power manager */ 66 DPRINT("Setting state to: %lx\n", PowerAction); 67 return NtSetSystemPowerState(PowerAction, 68 PowerSystemSleeping3, 69 POWER_ACTION_OVERRIDE_APPS | 70 POWER_ACTION_DISABLE_WAKES | 71 POWER_ACTION_CRITICAL); 72 } 73 74 /* EOF */ 75