/* INCLUDES *****************************************************************/
-#include <ddk/ntddk.h>
-#include <internal/hal/io.h>
-
+#include <ntoskrnl.h>
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
-NTSTATUS STDCALL NtSetSystemPowerState(VOID)
-{
- UNIMPLEMENTED;
-}
-
-
-static void kb_wait(void)
+NTSTATUS STDCALL
+NtSetSystemPowerState(IN POWER_ACTION SystemAction,
+ IN SYSTEM_POWER_STATE MinSystemState,
+ IN ULONG Flags)
{
- int i;
-
- for (i=0; i<10000; i++)
- {
- if ((inb_p(0x64) & 0x02) == 0)
- {
- return;
- }
- }
+ /* Windows 2000 only */
+ return(STATUS_NOT_IMPLEMENTED);
}
-NTSTATUS
-STDCALL
-NtShutdownSystem (
- IN SHUTDOWN_ACTION Action
- )
/*
- * FIXME: Does a reboot only
+ * @implemented
*/
+NTSTATUS STDCALL
+NtShutdownSystem(IN SHUTDOWN_ACTION Action)
{
- int i, j;
+ static PCH FamousLastWords[] =
+ {
+ "Oh my God, they killed Kenny! Those bastards!\n",
+ "So long, and thanks for all the fish\n",
+ "I think you ought to know I'm feeling very depressed\n",
+ "I'm not getting you down at all am I?\n",
+ "I'll be back\n",
+ "It's the same series of signal over and over again!\n",
+ "Pie Iesu Domine, dona eis requiem\n",
+ "Wandering stars, for whom it is reserved;\n"
+ "the blackness and darkness forever.\n",
+ "Your knees start shakin' and your fingers pop\n"
+ "Like a pinch on the neck from Mr. Spock!\n",
+ "It's worse than that ... He's dead, Jim\n",
+ "Don't Panic!\n",
+ "Et tu... Brute?\n",
+ "Dog of a Saxon! Take thy lance, and prepare for the death thou hast drawn upon thee!\n",
+ "My Precious! O my Precious!\n",
+ "Sir, If you'll not be needing me for a while I'll turn down.\n",
+ "What are you doing, Dave...?\n",
+ "I feel a great disturbance in the Force\n",
+ "Gone fishing\n",
+ "Do you want me to sit in the corner and rust, or just fall apart where I'm standing?\n",
+ };
+ LARGE_INTEGER Now;
+
+ if (Action > ShutdownPowerOff)
+ return STATUS_INVALID_PARAMETER;
+
+ ZwQuerySystemTime(&Now);
+ Now.u.LowPart = Now.u.LowPart >> 8; /* Seems to give a somewhat better "random" number */
+
+ IoShutdownRegisteredDevices();
+ CmShutdownRegistry();
+ IoShutdownRegisteredFileSystems();
+
+ PiShutdownProcessManager();
+ MiShutdownMemoryManager();
- for (;;)
+ if (Action == ShutdownNoReboot)
{
- for (i=0; i<100; i++)
+ HalReleaseDisplayOwnership();
+ HalDisplayString("\nYou can switch off your computer now\n\n");
+ HalDisplayString(FamousLastWords[Now.u.LowPart % (sizeof(FamousLastWords) / sizeof(PCH))]);
+#if 0
+ /* Switch off */
+ HalReturnToFirmware (FIRMWARE_OFF);
+#else
+ PopSetSystemPowerState(PowerSystemShutdown);
+
+ while (TRUE)
{
- kb_wait();
- for (j=0; j<500; j++);
- outb(0xfe, 0x64);
- for (j=0; j<500; j++);
+ Ke386DisableInterrupts();
+ Ke386HaltProcessor();
}
+#endif
+ }
+ else if (Action == ShutdownReboot)
+ {
+ HalReturnToFirmware (FIRMWARE_REBOOT);
}
+ else
+ {
+ HalReturnToFirmware (FIRMWARE_HALT);
+ }
+
+ return STATUS_SUCCESS;
}
+
+/* EOF */
+