Add a shutdown message.
[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 static PCH FamousLastWords[] =
35 {
36 "Oh my God, they killed Kenny! Those bastards!\n",
37 "So long, and thanks for all the fish\n",
38 "I think you ought to know I'm feeling very depressed\n",
39 "I'm not getting you down at all am I?\n",
40 "I'll be back\n",
41 "It's the same series of signal over and over again!\n",
42 "Pie Iesu Domine, dona eis requiem\n",
43 "Wandering stars, for whom it is reserved;\n"
44 "the blackness and darkness forever.\n",
45 "Your knees start shakin' and your fingers pop\n"
46 "Like a pinch on the neck from Mr. Spock!\n",
47 "It's worse than that ... He's dead, Jim\n",
48 "Don't Panic!\n",
49 "Et tu... Brute?\n",
50 "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee!\n",
51 "My Precious! O my Precious!\n",
52 "Sir, If you'll not be needing me for a while I'll turn down.\n",
53 "What are you doing, Dave...?\n",
54 };
55 LARGE_INTEGER Now;
56
57 if (Action > ShutdownPowerOff)
58 return STATUS_INVALID_PARAMETER;
59
60 ZwQuerySystemTime(&Now);
61 Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */
62
63 IoShutdownRegisteredDevices();
64 CmShutdownRegistry();
65 IoShutdownRegisteredFileSystems();
66
67 PiShutdownProcessManager();
68 MiShutdownMemoryManager();
69
70 if (Action == ShutdownNoReboot)
71 {
72 HalReleaseDisplayOwnership();
73 HalDisplayString(FamousLastWords[Now.u.LowPart % (sizeof(FamousLastWords) / sizeof(PCH))]);
74 #if 0
75 /* Switch off */
76 HalReturnToFirmware (FIRMWARE_OFF);
77 #else
78 PopSetSystemPowerState(PowerSystemShutdown);
79
80 while (TRUE)
81 {
82 Ke386DisableInterrupts();
83 Ke386HaltProcessor();
84 }
85 #endif
86 }
87 else if (Action == ShutdownReboot)
88 {
89 HalReturnToFirmware (FIRMWARE_REBOOT);
90 }
91 else
92 {
93 HalReturnToFirmware (FIRMWARE_HALT);
94 }
95
96 return STATUS_SUCCESS;
97 }
98
99 /* EOF */
100