Updates for new version of qemu
[pintos-anon] / src / devices / shutdown.c
index 42b67df57bc533b1681d1afb964dc1634e3b0930..da94c5294f339c1d81eb0950f83e53f9f703b1dc 100644 (file)
@@ -10,7 +10,7 @@
 #include "userprog/exception.h"
 #endif
 #ifdef FILESYS
-#include "devices/disk.h"
+#include "devices/block.h"
 #include "filesys/filesys.h"
 #endif
 
@@ -99,11 +99,21 @@ shutdown_power_off (void)
   printf ("Powering off...\n");
   serial_flush ();
 
+  /* ACPI power-off */
+  outw (0xB004, 0x2000);
+
   /* This is a special power-off sequence supported by Bochs and
      QEMU, but not by physical hardware. */
   for (p = s; *p != '\0'; p++)
     outb (0x8900, *p);
 
+  /* 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);
+
   /* This will power off a VMware VM if "gui.exitOnCLIHLT = TRUE"
      is set in its configuration file.  (The "pintos" script does
      that automatically.)  */
@@ -121,7 +131,7 @@ print_stats (void)
   timer_print_stats ();
   thread_print_stats ();
 #ifdef FILESYS
-  disk_print_stats ();
+  block_print_stats ();
 #endif
   console_print_stats ();
   kbd_print_stats ();