ia64/xen-unstable

changeset 10468:58b374f76a71

[HVM] ACPI support patch 4 of 4: shutdown.
The patch is incorporated from Ben's Virtual Iron's ACPI shutdown patch
in changeset 9989:f8d20c3e4225
The patch support guest ACPI Windows shutdown, as well as ACPI guest
Linux "halt -p" and "shutdown -h now".

Signed-off-by: Ben Thomas <ben@virtualiron.com>
Signed-off-by: Winston Wang <winston.l.wang@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Jun 17 09:08:14 2006 +0100 (2006-06-17)
parents e1c8212d78c3
children b025491f0ba8
files tools/ioemu/hw/piix4acpi.c
line diff
     1.1 --- a/tools/ioemu/hw/piix4acpi.c	Sat Jun 17 09:06:46 2006 +0100
     1.2 +++ b/tools/ioemu/hw/piix4acpi.c	Sat Jun 17 09:08:14 2006 +0100
     1.3 @@ -44,6 +44,10 @@
     1.4  #define GBL_RLS           (1 << 2)
     1.5  #define SLP_EN   	  (1 << 13)
     1.6  
     1.7 +/* Bits of PM1a register define here  */ 
     1.8 +#define SLP_TYP_MASK    0x1C00
     1.9 +#define SLP_VAL         0x1C00
    1.10 +
    1.11  typedef struct AcpiDeviceState AcpiDeviceState;
    1.12  AcpiDeviceState *acpi_device_table;
    1.13  
    1.14 @@ -94,7 +98,7 @@ static int pmtimer_load(QEMUFile *f, voi
    1.15           qemu_get_be64s(f, &s->next_pm_time);
    1.16           qemu_get_timer(f, s->pm_timer);
    1.17           return 0;
    1.18 -           
    1.19 +        
    1.20  }
    1.21  
    1.22  static inline void acpi_set_irq(PCIAcpiState *s)
    1.23 @@ -277,6 +281,13 @@ static void acpiPm1ControlP1_writeb(void
    1.24      s->pm1_control = (val<<8)||(s->pm1_control); 
    1.25  /*    printf("acpiPm1ControlP1_writeb \n addr %x val:%x\n", addr, val); */
    1.26  
    1.27 +    // Check for power off request
    1.28 +
    1.29 +    if ( ( (val & SLP_EN) != 0) &&
    1.30 +         ( (val & SLP_TYP_MASK) == SLP_VAL) ) {
    1.31 +         s->pm1_timer=0x0; //clear ACPI timer
    1.32 +         qemu_system_shutdown_request();
    1.33 +      }
    1.34  } 
    1.35  
    1.36  static uint32_t acpiPm1ControlP1_readb(void *opaque, uint32_t addr)
    1.37 @@ -304,7 +315,6 @@ static void acpiPm1Status_writew(void *o
    1.38      
    1.39  /*    printf("acpiPm1Status_writew \n addr %x val:%x pm1_status:%x \n", addr, val,s->pm1_status); */
    1.40  
    1.41 -
    1.42  } 
    1.43  
    1.44  static uint32_t acpiPm1Status_readw(void *opaque, uint32_t addr)
    1.45 @@ -345,6 +355,13 @@ static void acpiPm1Control_writew(void *
    1.46      s->pm1_control = val; 
    1.47  /*    printf("acpiPm1Control_writew \n addr %x val:%x\n", addr, val); */
    1.48  
    1.49 +    // Check for power off request
    1.50 +
    1.51 +    if ( ( (val & SLP_EN) != 0) &&
    1.52 +        ( (val & SLP_TYP_MASK) == SLP_VAL) ) {
    1.53 +         qemu_system_shutdown_request();
    1.54 +      }
    1.55 +
    1.56  } 
    1.57  
    1.58  static uint32_t acpiPm1Control_readw(void *opaque, uint32_t addr)
    1.59 @@ -403,9 +420,9 @@ static uint32_t acpiPm1Timer_readl(void 
    1.60  static void acpi_map(PCIDevice *pci_dev, int region_num, 
    1.61                      uint32_t addr, uint32_t size, int type)
    1.62  {
    1.63 -      PCIAcpiState *d = (PCIAcpiState *)pci_dev;
    1.64 -      printf("register acpi io \n ");
    1.65 -   /*Byte access		*/
    1.66 +       PCIAcpiState *d = (PCIAcpiState *)pci_dev;
    1.67 +       printf("register acpi io \n ");
    1.68 +       /*Byte access		*/
    1.69         register_ioport_write(addr, 1, 1, acpiPm1Status_writeb, d);
    1.70         register_ioport_read(addr, 1, 1, acpiPm1Status_readb, d);
    1.71         register_ioport_write(addr+1, 1, 1, acpiPm1StatusP1_writeb, d);
    1.72 @@ -431,7 +448,7 @@ static void acpi_map(PCIDevice *pci_dev,
    1.73          register_ioport_write(addr + 4, 2, 2, acpiPm1Control_writew, d);
    1.74          register_ioport_read(addr + 4, 2, 2, acpiPm1Control_readw, d);
    1.75  
    1.76 -   /* dword access */
    1.77 +       /* dword access */
    1.78          register_ioport_write(addr, 4, 4, acpiPm1Event_writel, d);
    1.79          register_ioport_read(addr, 4, 4, acpiPm1Event_readl, d);
    1.80