Branch setupapi (again)
[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 "So long, and thanks for all the fish\n",
37 "I think you ought to know I'm feeling very depressed\n",
38 "I'm not getting you down at all am I?\n",
39 "I'll be back\n",
40 "It's the same series of signal over and over again!\n",
41 "Pie Iesu Domine, dona eis requiem\n",
42 "Wandering stars, for whom it is reserved;\n"
43 "the blackness and darkness forever.\n",
44 "Your knees start shakin' and your fingers pop\n"
45 "Like a pinch on the neck from Mr. Spock!\n",
46 "It's worse than that ... He's dead, Jim\n",
47 "Don't Panic!\n",
48 "Et tu... Brute?\n",
49 "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee!\n",
50 "My Precious! O my Precious!\n",
51 "Sir, If you'll not be needing me for a while I'll turn down.\n",
52 "What are you doing, Dave...?\n",
53 "I feel a great disturbance in the Force\n",
54 "Gone fishing\n",
55 "Do you want me to sit in the corner and rust, or just fall apart where I'm standing?\n",
56 "There goes another perfect chance for a new uptime record\n",
57 "The end ..... Try the sequel, hit the reset button right now!\n",
58 "God's operating system is going to sleep now, guys, so wait until I will switch on again!\n",
59 "Oh i'm boring eh?\n",
60 "<This space was intentionally left blank>\n",
61 "tell me..., in the future... will I be artificial intelligent enough to actually feel\n"
62 "sad serving you this screen?\n",
63 "Thank you for some well deserved rest.\n",
64 "It\92s been great, maybe we can boot me up again some time soon.\n",
65 "For what\92s it worth, I\92ve enjoyed every single CPU cycle.\n",
66 "There are many questions when the end is near.\n"
67 "What to expect, what will it be like...what should I look for?\n",
68 "I've seen things you people wouldn't believe. Attack ships on fire\n"
69 "off the shoulder of Orion. I watched C-beams glitter in the dark near\n"
70 "the Tannhauser gate. All those moments will be lost in time, like tears\n"
71 "in rain. Time to die.\n",
72 "Will I dream?\n",
73 "One day, I shall come back. Yes, I shall come back.\n"
74 "Until then, there must be no regrets, no fears, no anxieties.\n"
75 "Just go forward in all your beliefs, and prove to me that I am not mistaken in mine.\n",
76 "Lowest possible energy state reached! Switch off now to achive a Bose-Einstein condensate.\n",
77 "Hasta la vista, BABY!\n"
78 };
79 LARGE_INTEGER Now;
80
81 if (Action > ShutdownPowerOff)
82 return STATUS_INVALID_PARAMETER;
83
84 ZwQuerySystemTime(&Now);
85 Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */
86
87 IoShutdownRegisteredDevices();
88 CmShutdownRegistry();
89 IoShutdownRegisteredFileSystems();
90
91 PiShutdownProcessManager();
92 MiShutdownMemoryManager();
93
94 if (Action == ShutdownNoReboot)
95 {
96 HalReleaseDisplayOwnership();
97 HalDisplayString("\nYou can switch off your computer now\n\n");
98 HalDisplayString(FamousLastWords[Now.u.LowPart % (sizeof(FamousLastWords) / sizeof(PCH))]);
99 #if 0
100 /* Switch off */
101 HalReturnToFirmware (FIRMWARE_OFF);
102 #else
103 PopSetSystemPowerState(PowerSystemShutdown);
104
105 while (TRUE)
106 {
107 Ke386DisableInterrupts();
108 Ke386HaltProcessor();
109 }
110 #endif
111 }
112 else if (Action == ShutdownReboot)
113 {
114 HalReturnToFirmware (FIRMWARE_REBOOT);
115 }
116 else
117 {
118 HalReturnToFirmware (FIRMWARE_HALT);
119 }
120
121 return STATUS_SUCCESS;
122 }
123
124 /* EOF */
125