qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Handle suspend in qemu.


From: Gleb Natapov
Subject: [Qemu-devel] [PATCH] Handle suspend in qemu.
Date: Sun, 26 Oct 2008 16:43:34 +0200
User-agent: StGIT/0.14.2

Reset PC and tell to BIOS that resume from ram is required when OS does
ACPI S3 suspend.
Signed-off-by: Gleb Natapov <address@hidden>
---

 hw/acpi.c |   10 ++++++++++
 hw/pc.c   |    8 ++++++++
 hw/pc.h   |    1 +
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index 45963d3..39c22a7 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -52,6 +52,8 @@ typedef struct PIIX4PMState {
     qemu_irq irq;
 } PIIX4PMState;
 
+#define RSM_STS (1 << 15)
+#define PWRBTN_STS (1 << 8)
 #define RTC_EN (1 << 10)
 #define PWRBTN_EN (1 << 8)
 #define GBL_EN (1 << 5)
@@ -150,6 +152,14 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, 
uint32_t val)
                 case 0: /* soft power off */
                     qemu_system_shutdown_request();
                     break;
+                case 1:
+                    /* RSM_STS should be set on resume. Pretend that resume
+                       was caused by power button */
+                    s->pmsts |= (RSM_STS | PWRBTN_STS);
+                    qemu_system_reset_request();
+#if defined(TARGET_I386)
+                    cmos_set_s3_resume();
+#endif
                 default:
                     break;
                 }
diff --git a/hw/pc.c b/hw/pc.c
index 167d628..f09a573 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1090,6 +1090,14 @@ static void pc_init_isa(ram_addr_t ram_size, int 
vga_ram_size,
              initrd_filename, 0, cpu_model);
 }
 
+/* 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 = {
     .name = "pc",
     .desc = "Standard PC",
diff --git a/hw/pc.h b/hw/pc.h
index e2da853..3924622 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -81,6 +81,7 @@ RTCState *rtc_init(int base, qemu_irq irq);
 RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq);
 void rtc_set_memory(RTCState *s, int addr, int val);
 void rtc_set_date(RTCState *s, const struct tm *tm);
+void cmos_set_s3_resume(void);
 
 /* pc.c */
 extern int fd_bootchk;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]