ia64/xen-unstable

changeset 17684:34ac0d3b5bfb

ioemu: HVM virtual S3
- add S3 suspend logic in PM1A control register. when guest write
specific value to this register,
QEMU will trigger S3 sleep by
* reset all qemu device
* set CMOS shutdown status as S3 resume, so that rombios will do
S3 resume later
* request Xen to S3-suspend the guest

Signed-off-by: Yu Ke <ke.yu@intel.com>
Signed-off-by: Liping Ke <liping.ke@intel.com?
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 20 14:28:19 2008 +0100 (2008-05-20)
parents 4b4b829e34a2
children 7c752689b0ea
files tools/ioemu/hw/pc.c tools/ioemu/hw/piix4acpi.c tools/ioemu/target-i386-dm/helper2.c tools/ioemu/vl.h
line diff
     1.1 --- a/tools/ioemu/hw/pc.c	Tue May 20 14:18:32 2008 +0100
     1.2 +++ b/tools/ioemu/hw/pc.c	Tue May 20 14:28:19 2008 +0100
     1.3 @@ -1121,6 +1121,14 @@ static void pc_init_isa(uint64_t ram_siz
     1.4               initrd_filename, 0, NULL);
     1.5  }
     1.6  
     1.7 +/* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE)
     1.8 +   BIOS will read it and start S3 resume at POST Entry*/
     1.9 +void cmos_set_s3_resume(void)
    1.10 +{
    1.11 +    if (rtc_state)
    1.12 +        rtc_set_memory(rtc_state, 0xF, 0xFE);
    1.13 +}
    1.14 +
    1.15  QEMUMachine pc_machine = {
    1.16      "pc",
    1.17      "Standard PC",
     2.1 --- a/tools/ioemu/hw/piix4acpi.c	Tue May 20 14:18:32 2008 +0100
     2.2 +++ b/tools/ioemu/hw/piix4acpi.c	Tue May 20 14:28:19 2008 +0100
     2.3 @@ -25,6 +25,7 @@
     2.4  
     2.5  #include "vl.h"
     2.6  #include <xen/hvm/ioreq.h>
     2.7 +#include <xen/hvm/params.h>
     2.8  
     2.9  /* PM1a_CNT bits, as defined in the ACPI specification. */
    2.10  #define SCI_EN            (1 <<  0)
    2.11 @@ -35,6 +36,7 @@
    2.12  /* Sleep state type codes as defined by the \_Sx objects in the DSDT. */
    2.13  /* These must be kept in sync with the DSDT (hvmloader/acpi/dsdt.asl) */
    2.14  #define SLP_TYP_S4        (6 << 10)
    2.15 +#define SLP_TYP_S3        (5 << 10)
    2.16  #define SLP_TYP_S5        (7 << 10)
    2.17  
    2.18  #define ACPI_DBG_IO_ADDR  0xb044
    2.19 @@ -79,6 +81,8 @@ typedef struct PHPSlots {
    2.20  
    2.21  PHPSlots php_slots;
    2.22  
    2.23 +int s3_shutdown_flag;
    2.24 +
    2.25  static void piix4acpi_save(QEMUFile *f, void *opaque)
    2.26  {
    2.27      PCIAcpiState *s = opaque;
    2.28 @@ -118,6 +122,13 @@ static void acpi_shutdown(uint32_t val)
    2.29          return;
    2.30  
    2.31      switch (val & SLP_TYP_Sx) {
    2.32 +    case SLP_TYP_S3:
    2.33 +        s3_shutdown_flag = 1;
    2.34 +        qemu_system_reset();
    2.35 +        s3_shutdown_flag = 0;
    2.36 +        cmos_set_s3_resume();
    2.37 +        xc_set_hvm_param(xc_handle, domid, HVM_PARAM_ACPI_S_STATE, 3);
    2.38 +        break;
    2.39      case SLP_TYP_S4:
    2.40      case SLP_TYP_S5:
    2.41          qemu_system_shutdown_request();
     3.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Tue May 20 14:18:32 2008 +0100
     3.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Tue May 20 14:28:19 2008 +0100
     3.3 @@ -133,8 +133,12 @@ CPUX86State *cpu_x86_init(void)
     3.4  /* called from main_cpu_reset */
     3.5  void cpu_reset(CPUX86State *env)
     3.6  {
     3.7 +    extern int s3_shutdown_flag;
     3.8      int xcHandle;
     3.9      int sts;
    3.10 + 
    3.11 +    if (s3_shutdown_flag)
    3.12 +        return;
    3.13  
    3.14      xcHandle = xc_interface_open();
    3.15      if (xcHandle < 0)
     4.1 --- a/tools/ioemu/vl.h	Tue May 20 14:18:32 2008 +0100
     4.2 +++ b/tools/ioemu/vl.h	Tue May 20 14:28:19 2008 +0100
     4.3 @@ -1181,6 +1181,7 @@ extern int fd_bootchk;
     4.4  
     4.5  void ioport_set_a20(int enable);
     4.6  int ioport_get_a20(void);
     4.7 +void cmos_set_s3_resume(void);
     4.8  
     4.9  /* ppc.c */
    4.10  extern QEMUMachine prep_machine;