WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 2/4]: QEMU interface for HVM virtual S3

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/4]: QEMU interface for HVM virtual S3
From: "Yu, Ke" <ke.yu@xxxxxxxxx>
Date: Thu, 17 May 2007 00:49:25 +0800
Delivery-date: Wed, 16 May 2007 09:48:12 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AceX2iknM0mETV5OQx2vQ1of3O0yPg==
Thread-topic: [PATCH 2/4]: QEMU interface for HVM virtual S3
[PATCH 2/4]: QEMU interface for 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
    * call HVMOP_s3_suspend hypercall to put HVM domain into S3 sleep
state.

Signed-off-by: Yu Ke <ke.yu@xxxxxxxxx>

diff -r 3453c027ddbe tools/ioemu/hw/pc.c
--- a/tools/ioemu/hw/pc.c       Tue May 15 15:11:40 2007 -0400
+++ b/tools/ioemu/hw/pc.c       Tue May 15 17:22:59 2007 -0400
@@ -822,6 +822,14 @@ static void pc_init_isa(uint64_t ram_siz
              initrd_filename, 0);
 }
 
+/* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE)
+   BIOS will read it and start S3 resume at POST*/
+void cmos_set_s3_resume(void){
+    if (rtc_state){
+        rtc_set_memory(rtc_state, 0xF, 0xFE);
+    }
+}
+
 QEMUMachine pc_machine = {
     "pc",
     "Standard PC",
diff -r 3453c027ddbe tools/ioemu/hw/piix4acpi.c
--- a/tools/ioemu/hw/piix4acpi.c        Tue May 15 15:11:40 2007 -0400
+++ b/tools/ioemu/hw/piix4acpi.c        Tue May 15 20:30:58 2007 -0400
@@ -33,6 +33,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_S3        (5 << 10)
 #define SLP_TYP_S5        (7 << 10)
 
 typedef struct AcpiDeviceState AcpiDeviceState;
@@ -86,6 +87,13 @@ static void acpiPm1ControlP1_writeb(void
     /* Check for power off request. */
     if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S5))
         qemu_system_shutdown_request();
+    else if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S3)){
+        /* check for S3 sleep request */
+        qemu_system_reset();
+        cmos_set_s3_resume();
+        xc_hvm_s3_suspend(xc_handle,domid);
+    }
+            
 }
 
 static uint32_t acpiPm1ControlP1_readb(void *opaque, uint32_t addr)
@@ -104,6 +112,12 @@ static void acpiPm1Control_writew(void *
     /* Check for power off request. */
     if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S5))
         qemu_system_shutdown_request();
+    else if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S3)){
+        /* check for S3 sleep request */
+        qemu_system_reset();
+        cmos_set_s3_resume();
+        xc_hvm_s3_suspend(xc_handle,domid);
+    }
 }
 
 static uint32_t acpiPm1Control_readw(void *opaque, uint32_t addr)
diff -r 3453c027ddbe tools/ioemu/target-i386-dm/helper2.c
--- a/tools/ioemu/target-i386-dm/helper2.c      Tue May 15 15:11:40 2007
-0400
+++ b/tools/ioemu/target-i386-dm/helper2.c      Tue May 15 17:22:59 2007
-0400
@@ -133,6 +133,7 @@ CPUX86State *cpu_x86_init(void)
 /* called from main_cpu_reset */
 void cpu_reset(CPUX86State *env)
 {
+#if 0    
     int xcHandle;
     int sts;
 
@@ -149,6 +150,7 @@ void cpu_reset(CPUX86State *env)
             fprintf(logfile, "Issued domain %d reboot\n", domid);
         xc_interface_close(xcHandle);
     }
+#endif    
 }
 
 void cpu_x86_close(CPUX86State *env)
diff -r 3453c027ddbe tools/ioemu/vl.h
--- a/tools/ioemu/vl.h  Tue May 15 15:11:40 2007 -0400
+++ b/tools/ioemu/vl.h  Tue May 15 17:22:59 2007 -0400
@@ -1123,6 +1123,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;
diff -r 3453c027ddbe tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Tue May 15 15:11:40 2007 -0400
+++ b/tools/libxc/xc_misc.c     Tue May 15 17:22:59 2007 -0400
@@ -198,6 +198,45 @@ int xc_hvm_set_pci_link_route(
     unlock_pages(&arg, sizeof(arg));
 
     return rc;
+}
+
+static int xc_hvm_s3_op(
+    int xc_handle, domid_t dom, HVMOP_S3_t op)
+{
+    DECLARE_HYPERCALL;
+    struct xen_hvm_s3 arg;
+    int rc;
+
+    hypercall.op     = __HYPERVISOR_hvm_op;
+    hypercall.arg[0] = HVMOP_S3;
+    hypercall.arg[1] = (unsigned long)&arg;
+
+    arg.domid   = dom;
+    arg.op      = op;
+
+    if ( (rc = lock_pages(&arg, sizeof(arg))) != 0 )
+    {
+        PERROR("Could not lock memory");
+        return rc;
+    }
+
+    rc = do_xen_hypercall(xc_handle, &hypercall);
+
+    unlock_pages(&arg, sizeof(arg));
+
+    return rc;
+}
+
+int xc_hvm_s3_suspend(
+    int xc_handle, domid_t dom)
+{
+    return xc_hvm_s3_op(xc_handle, dom, HVMOP_S3_suspend);
+}
+
+int xc_hvm_s3_resume(
+    int xc_handle, domid_t dom)
+{
+    return xc_hvm_s3_op(xc_handle, dom, HVMOP_S3_resume);
 }
 
 /*
diff -r 3453c027ddbe tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Tue May 15 15:11:40 2007 -0400
+++ b/tools/libxc/xenctrl.h     Tue May 15 17:22:59 2007 -0400
@@ -796,6 +796,11 @@ int xc_hvm_set_pci_link_route(
 int xc_hvm_set_pci_link_route(
     int xc_handle, domid_t dom, uint8_t link, uint8_t isa_irq);
 
+int xc_hvm_s3_suspend(
+    int xc_handle, domid_t dom);
+
+int xc_hvm_s3_resume(
+    int xc_handle, domid_t dom);
 
 typedef enum {
   XC_ERROR_NONE = 0,

Attachment: qemu.patch
Description: qemu.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/4]: QEMU interface for HVM virtual S3, Yu, Ke <=