* [Qemu-devel] [PATCH] Handle suspend in qemu.
@ 2008-10-26 14:43 Gleb Natapov
0 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2008-10-26 14:43 UTC (permalink / raw)
To: qemu-devel
Reset PC and tell to BIOS that resume from ram is required when OS does
ACPI S3 suspend.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
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;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] Handle suspend in qemu.
@ 2008-10-27 9:30 Gleb Natapov
0 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2008-10-27 9:30 UTC (permalink / raw)
To: qemu-devel
Reset PC and tell to BIOS that resume from ram is required when OS does
ACPI S3 suspend.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
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;
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] Handle suspend in qemu.
@ 2008-12-11 14:53 Gleb Natapov
2008-12-16 5:46 ` Kevin O'Connor
2008-12-17 22:32 ` Anthony Liguori
0 siblings, 2 replies; 6+ messages in thread
From: Gleb Natapov @ 2008-12-11 14:53 UTC (permalink / raw)
To: qemu-devel
BIOS changes are already upstream.
Reset a PC and tell BIOS that resume from ram is required on the next
boot.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/hw/acpi.c b/hw/acpi.c
index 66a5faa..dd9100a 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -53,6 +53,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)
@@ -151,6 +153,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;
}
@@ -471,6 +481,17 @@ static int pm_load(QEMUFile* f,void* opaque,int version_id)
return 0;
}
+static void piix4_reset(void *opaque)
+{
+ PIIX4PMState *s = opaque;
+ uint8_t *pci_conf = s->dev.config;
+
+ pci_conf[0x58] = 0;
+ pci_conf[0x59] = 0;
+ pci_conf[0x5a] = 0;
+ pci_conf[0x5b] = 0;
+}
+
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq)
{
@@ -527,6 +548,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
s->smbus = i2c_init_bus();
s->irq = sci_irq;
+ qemu_register_reset(piix4_reset, s);
+
return s->smbus;
}
diff --git a/hw/pc.c b/hw/pc.c
index 20827f2..bcacf3a 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1136,6 +1136,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 39b220f..b0b8970 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -82,6 +82,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;
--
Gleb.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Handle suspend in qemu.
2008-12-11 14:53 [Qemu-devel] [PATCH] Handle suspend in qemu Gleb Natapov
@ 2008-12-16 5:46 ` Kevin O'Connor
2008-12-16 6:50 ` Gleb Natapov
2008-12-17 22:32 ` Anthony Liguori
1 sibling, 1 reply; 6+ messages in thread
From: Kevin O'Connor @ 2008-12-16 5:46 UTC (permalink / raw)
To: Gleb Natapov; +Cc: qemu-devel
On Thu, Dec 11, 2008 at 04:53:32PM +0200, Gleb Natapov wrote:
> BIOS changes are already upstream.
>
> Reset a PC and tell BIOS that resume from ram is required on the next
> boot.
Hi Gleb,
How can I test this?
I grabbed the latest bochs from CVS and compiled the BIOS. I then
tried it on qemu with Fedora8, Ubuntu-8.04, and winxp images - they
all seem to say they can suspend, but none actually work when told to.
The linux images both appear to support standby (cat /sys/power/state
shows "mem"), but trying suspend (echo -n mem > /sys/power/state)
returns "Resource temporarily unavailable" and a series of messages in
/var/log/messages starting with: Freezing of tasks failed after 20.00
second (1 tasks refusing to freeze)
The winxp image shows "suspend" in the shutdown menu. However, when I
click on it I get a dialog that says:
The device driver for the "Default Monitor" device is preventing the
machine from entering standby. Please close all applications and try
again. If the problem persists, you may need to update this driver.
Any ideas?
Thanks,
-Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Handle suspend in qemu.
2008-12-16 5:46 ` Kevin O'Connor
@ 2008-12-16 6:50 ` Gleb Natapov
0 siblings, 0 replies; 6+ messages in thread
From: Gleb Natapov @ 2008-12-16 6:50 UTC (permalink / raw)
To: qemu-devel
On Tue, Dec 16, 2008 at 12:46:41AM -0500, Kevin O'Connor wrote:
> On Thu, Dec 11, 2008 at 04:53:32PM +0200, Gleb Natapov wrote:
> > BIOS changes are already upstream.
> >
> > Reset a PC and tell BIOS that resume from ram is required on the next
> > boot.
>
> Hi Gleb,
>
> How can I test this?
>
> I grabbed the latest bochs from CVS and compiled the BIOS. I then
> tried it on qemu with Fedora8, Ubuntu-8.04, and winxp images - they
> all seem to say they can suspend, but none actually work when told to.
>
> The linux images both appear to support standby (cat /sys/power/state
> shows "mem"), but trying suspend (echo -n mem > /sys/power/state)
> returns "Resource temporarily unavailable" and a series of messages in
> /var/log/messages starting with: Freezing of tasks failed after 20.00
> second (1 tasks refusing to freeze)
>
Never saw that one. What is you qemu command line? Can you try latest
kernel. Searching internet for the "Freezing of tasks failed" suggest
that it may be a kernel bug.
> The winxp image shows "suspend" in the shutdown menu. However, when I
> click on it I get a dialog that says:
>
> The device driver for the "Default Monitor" device is preventing the
> machine from entering standby. Please close all applications and try
> again. If the problem persists, you may need to update this driver.
>
This one sound familiar. You need latest vgabios with DPMS support.
--
Gleb.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Handle suspend in qemu.
2008-12-11 14:53 [Qemu-devel] [PATCH] Handle suspend in qemu Gleb Natapov
2008-12-16 5:46 ` Kevin O'Connor
@ 2008-12-17 22:32 ` Anthony Liguori
1 sibling, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2008-12-17 22:32 UTC (permalink / raw)
To: qemu-devel
Gleb Natapov wrote:
> BIOS changes are already upstream.
>
> Reset a PC and tell BIOS that resume from ram is required on the next
> boot.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
>
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-12-17 22:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-11 14:53 [Qemu-devel] [PATCH] Handle suspend in qemu Gleb Natapov
2008-12-16 5:46 ` Kevin O'Connor
2008-12-16 6:50 ` Gleb Natapov
2008-12-17 22:32 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2008-10-27 9:30 Gleb Natapov
2008-10-26 14:43 Gleb Natapov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).