new reset API - shutdown support
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 20 Jun 2004 13:00:26 +0000 (13:00 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Sun, 20 Jun 2004 13:00:26 +0000 (13:00 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@939 c046a42c-6fe2-441c-8c8c-71466251a162

hw/pc.c

diff --git a/hw/pc.c b/hw/pc.c
index a40e1d0..4e2be25 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -217,6 +217,9 @@ static uint32_t ioport92_read(void *opaque, uint32_t addr)
 
 void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
 {
+    static const char shutdown_str[8] = "Shutdown";
+    static int shutdown_index = 0;
+    
     switch(addr) {
         /* Bochs BIOS messages */
     case 0x400:
@@ -229,6 +232,18 @@ void bochs_bios_write(void *opaque, uint32_t addr, uint32_t val)
         fprintf(stderr, "%c", val);
 #endif
         break;
+    case 0x8900:
+        /* same as Bochs power off */
+        if (val == shutdown_str[shutdown_index]) {
+            shutdown_index++;
+            if (shutdown_index == 8) {
+                shutdown_index = 0;
+                qemu_system_shutdown_request();
+            }
+        } else {
+            shutdown_index = 0;
+        }
+        break;
 
         /* LGPL'ed VGA BIOS messages */
     case 0x501:
@@ -250,6 +265,7 @@ void bochs_bios_init(void)
     register_ioport_write(0x401, 1, 2, bochs_bios_write, NULL);
     register_ioport_write(0x402, 1, 1, bochs_bios_write, NULL);
     register_ioport_write(0x403, 1, 1, bochs_bios_write, NULL);
+    register_ioport_write(0x8900, 1, 1, bochs_bios_write, NULL);
 
     register_ioport_write(0x501, 1, 2, bochs_bios_write, NULL);
     register_ioport_write(0x502, 1, 2, bochs_bios_write, NULL);