PATH=/usr/bin:$PATH
-exec shutdown -x off
+exec shutdown -p
void
usage()
{
- fprintf(stderr, "Usage: %s [-hrRfd] [-x reboot-code]\n", prog);
+ fprintf(stderr, "Usage: %s [-hrRfpd] [-x reboot-code]\n", prog);
exit(1);
}
case 'r': flag = RBT_REBOOT; break;
case 'R': flag = RBT_RESET; break;
case 'd': flag = RBT_DEFAULT; break;
+ case 'p': flag = RBT_POWEROFF; break;
case 'f': fast = 1; break;
case 'x':
flag = RBT_MONITOR;
break;
case 'h':
case 'r':
+ case 'p':
case 'x':
case 'd':
reboot_flag = *opt;
void usage()
{
- fputs("Usage: shutdown [-hrRmkd] [-x code] [time [message]]\n", stderr);
+ fputs("Usage: shutdown [-hrRpmkd] [-x code] [time [message]]\n", stderr);
fputs(" -h -> halt system after shutdown\n", stderr);
fputs(" -r -> reboot system after shutdown\n", stderr);
fputs(" -R -> reset system after shutdown\n", stderr);
+ fputs(" -p -> power system off after shutdown\n", stderr);
fputs(" -x -> return to the monitor doing...\n", stderr);
fputs(" -d -> default CTRL-ALT-DEL shutdown for current bootloader\n", stderr);
fputs(" -m -> read a shutdown message from standard input\n", stderr);
#define RBT_MONITOR 3 /* let the monitor do this */
#define RBT_RESET 4 /* hard reset the system */
#define RBT_DEFAULT 5 /* return to monitor, reset if not possible */
-#define RBT_INVALID 6 /* first invalid reboot flag */
+#define RBT_POWEROFF 6 /* power off, reset if not possible */
+#define RBT_INVALID 7 /* first invalid reboot flag */
#endif
}
}
+void
+poweroff(void)
+{
+ const char *shutdown_str;
+
+ /* Bochs/QEMU poweroff */
+ shutdown_str = "Shutdown";
+ while (*shutdown_str) outb(0x8900, *(shutdown_str++));
+
+ /* fallback option: reset */
+ reset();
+}
+
__dead void arch_shutdown(int how)
{
unsigned char unused_ch;
/* Stop */
for (; ; ) halt_cpu();
NOT_REACHABLE;
+
+ case RBT_POWEROFF:
+ /* Power off if possible, reset otherwise */
+ poweroff();
+ NOT_REACHABLE;
default:
case RBT_REBOOT:
* the PM, will get a HARD_STOP notification. Await the
* notification in the main loop.
*/
- sys_abort(RBT_DEFAULT);
+ sys_abort(abort_flag);
return;
}