Restore poweroff to some of it's former glory (on QEMU, at least)

This commit is contained in:
Erik van der Kouwe 2012-11-21 20:28:37 +01:00
parent 0181ec6beb
commit 22fa466268
6 changed files with 27 additions and 5 deletions

View file

@ -10,4 +10,4 @@ fi
PATH=/usr/bin:$PATH
exec shutdown -x off
exec shutdown -p

View file

@ -34,7 +34,7 @@ char *reboot_code = "delay; boot";
void
usage()
{
fprintf(stderr, "Usage: %s [-hrRfd] [-x reboot-code]\n", prog);
fprintf(stderr, "Usage: %s [-hrRfpd] [-x reboot-code]\n", prog);
exit(1);
}
@ -66,6 +66,7 @@ char **argv;
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;

View file

@ -148,6 +148,7 @@ char *argv[];
break;
case 'h':
case 'r':
case 'p':
case 'x':
case 'd':
reboot_flag = *opt;
@ -273,10 +274,11 @@ char *argv[];
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);

View file

@ -8,6 +8,7 @@
#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

View file

@ -80,6 +80,19 @@ reset(void)
}
}
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;
@ -114,6 +127,11 @@ __dead void arch_shutdown(int how)
/* Stop */
for (; ; ) halt_cpu();
NOT_REACHABLE;
case RBT_POWEROFF:
/* Power off if possible, reset otherwise */
poweroff();
NOT_REACHABLE;
default:
case RBT_REBOOT:

View file

@ -398,7 +398,7 @@ static void handle_vfs_reply()
* the PM, will get a HARD_STOP notification. Await the
* notification in the main loop.
*/
sys_abort(RBT_DEFAULT);
sys_abort(abort_flag);
return;
}