summaryrefslogtreecommitdiffstats
path: root/src/threads/init.c
diff options
context:
space:
mode:
authorFelipe Boeira <felipe.boeira@liu.se>2019-01-21 13:22:57 +0100
committerFelipe Boeira <felipe.boeira@liu.se>2019-01-21 13:22:57 +0100
commitb257cc57cf50704c785d1a3b02badcb166a19ebe (patch)
treef527ca4c959b7c7969a18110c4b8d053e29dff6d /src/threads/init.c
parentd4522b8e9854178473adcea0fbb84f23f6e744bd (diff)
downloadpintos-b257cc57cf50704c785d1a3b02badcb166a19ebe.tar.gz
Fixed bugs for execution on newer software
Diffstat (limited to 'src/threads/init.c')
-rw-r--r--src/threads/init.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/threads/init.c b/src/threads/init.c
index 0e97c39..3ad3f07 100644
--- a/src/threads/init.c
+++ b/src/threads/init.c
@@ -374,6 +374,15 @@ power_off (void)
printf ("Powering off...\n");
serial_flush ();
outw(0xB004, 0x2000);
+ outb(0xF4, 0x30);
+
+ /* For newer versions of qemu, you must run with -device
+ * isa-debug-exit, which exits on any write to an IO port (by
+ * default 0x501). Qemu's exit code is double the value plus one,
+ * so there is no way to exit cleanly. We use 0x31 which should
+ * result in a qemu exit code of 0x63. */
+ outb (0x501, 0x31);
+
for (p = s; *p != '\0'; p++)
outb (0x8900, *p);
asm volatile ("cli; hlt" : : : "memory");