diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-05-20 14:28:19 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-05-20 14:28:19 +0100 |
commit | 367722ab70c62591fe2fad263c9be56bfd425c8b (patch) | |
tree | 7a301c1121e44dd4e293e8395c69f443c3fceeff | |
parent | 4f050d52f57ce5681f535fb924e4cea6c41df1b0 (diff) | |
download | xen-367722ab70c62591fe2fad263c9be56bfd425c8b.tar.gz xen-367722ab70c62591fe2fad263c9be56bfd425c8b.tar.bz2 xen-367722ab70c62591fe2fad263c9be56bfd425c8b.zip |
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>
-rw-r--r-- | tools/ioemu/hw/pc.c | 8 | ||||
-rw-r--r-- | tools/ioemu/hw/piix4acpi.c | 11 | ||||
-rw-r--r-- | tools/ioemu/target-i386-dm/helper2.c | 4 | ||||
-rw-r--r-- | tools/ioemu/vl.h | 1 |
4 files changed, 24 insertions, 0 deletions
diff --git a/tools/ioemu/hw/pc.c b/tools/ioemu/hw/pc.c index 9731ef0aac..3835191ac1 100644 --- a/tools/ioemu/hw/pc.c +++ b/tools/ioemu/hw/pc.c @@ -1121,6 +1121,14 @@ static void pc_init_isa(uint64_t ram_size, int vga_ram_size, char *boot_device, initrd_filename, 0, NULL); } +/* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE) + BIOS will read it and start S3 resume at POST Entry*/ +void cmos_set_s3_resume(void) +{ + if (rtc_state) + rtc_set_memory(rtc_state, 0xF, 0xFE); +} + QEMUMachine pc_machine = { "pc", "Standard PC", diff --git a/tools/ioemu/hw/piix4acpi.c b/tools/ioemu/hw/piix4acpi.c index a4ebfc4163..f084c8ec65 100644 --- a/tools/ioemu/hw/piix4acpi.c +++ b/tools/ioemu/hw/piix4acpi.c @@ -25,6 +25,7 @@ #include "vl.h" #include <xen/hvm/ioreq.h> +#include <xen/hvm/params.h> /* PM1a_CNT bits, as defined in the ACPI specification. */ #define SCI_EN (1 << 0) @@ -35,6 +36,7 @@ /* Sleep state type codes as defined by the \_Sx objects in the DSDT. */ /* These must be kept in sync with the DSDT (hvmloader/acpi/dsdt.asl) */ #define SLP_TYP_S4 (6 << 10) +#define SLP_TYP_S3 (5 << 10) #define SLP_TYP_S5 (7 << 10) #define ACPI_DBG_IO_ADDR 0xb044 @@ -79,6 +81,8 @@ typedef struct PHPSlots { PHPSlots php_slots; +int s3_shutdown_flag; + static void piix4acpi_save(QEMUFile *f, void *opaque) { PCIAcpiState *s = opaque; @@ -118,6 +122,13 @@ static void acpi_shutdown(uint32_t val) return; switch (val & SLP_TYP_Sx) { + case SLP_TYP_S3: + s3_shutdown_flag = 1; + qemu_system_reset(); + s3_shutdown_flag = 0; + cmos_set_s3_resume(); + xc_set_hvm_param(xc_handle, domid, HVM_PARAM_ACPI_S_STATE, 3); + break; case SLP_TYP_S4: case SLP_TYP_S5: qemu_system_shutdown_request(); diff --git a/tools/ioemu/target-i386-dm/helper2.c b/tools/ioemu/target-i386-dm/helper2.c index 16623e90b3..c7b0820ed8 100644 --- a/tools/ioemu/target-i386-dm/helper2.c +++ b/tools/ioemu/target-i386-dm/helper2.c @@ -133,8 +133,12 @@ CPUX86State *cpu_x86_init(void) /* called from main_cpu_reset */ void cpu_reset(CPUX86State *env) { + extern int s3_shutdown_flag; int xcHandle; int sts; + + if (s3_shutdown_flag) + return; xcHandle = xc_interface_open(); if (xcHandle < 0) diff --git a/tools/ioemu/vl.h b/tools/ioemu/vl.h index 705878cba2..1c7ff42fc6 100644 --- a/tools/ioemu/vl.h +++ b/tools/ioemu/vl.h @@ -1181,6 +1181,7 @@ extern int fd_bootchk; void ioport_set_a20(int enable); int ioport_get_a20(void); +void cmos_set_s3_resume(void); /* ppc.c */ extern QEMUMachine prep_machine; |