aboutsummaryrefslogtreecommitdiff
path: root/hw/acpi.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-02-23 13:45:20 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2012-02-24 13:36:03 -0600
commitda98c8eb4c35225049cad8cf767647eb39788b5d (patch)
treeb6321ed36190de3ecf265ae4c5b25a2bfe54bb3e /hw/acpi.c
parent95b363b5c643d8ad81c5377726e753b84c909037 (diff)
suspend: switch acpi s3 to new infrastructure.
This patch switches pc s3 suspend over to the new infrastructure. The cmos_s3 qemu_irq is killed, the new notifier is used instead. The xen hack goes away with that too, the hypercall can simply be done in a notifier function now. This patch also makes the guest actually stay suspended instead of leaving suspend instantly, so it is useful for more than just testing whenever the suspend/resume cycle actually works. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/acpi.c')
-rw-r--r--hw/acpi.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/hw/acpi.c b/hw/acpi.c
index 407949bfa0..7b167161fb 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -248,6 +248,22 @@ int acpi_table_add(const char *t)
}
+static void acpi_notify_wakeup(Notifier *notifier, void *data)
+{
+ ACPIREGS *ar = container_of(notifier, ACPIREGS, wakeup);
+ WakeupReason *reason = data;
+
+ switch (*reason) {
+ case QEMU_WAKEUP_REASON_OTHER:
+ default:
+ /* ACPI_BITMASK_WAKE_STATUS should be set on resume.
+ Pretend that resume was caused by power button */
+ ar->pm1.evt.sts |=
+ (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS);
+ break;
+ }
+}
+
/* ACPI PM1a EVT */
uint16_t acpi_pm1_evt_get_sts(ACPIREGS *ar)
{
@@ -333,9 +349,10 @@ void acpi_pm_tmr_reset(ACPIREGS *ar)
}
/* ACPI PM1aCNT */
-void acpi_pm1_cnt_init(ACPIREGS *ar, qemu_irq cmos_s3)
+void acpi_pm1_cnt_init(ACPIREGS *ar)
{
- ar->pm1.cnt.cmos_s3 = cmos_s3;
+ ar->wakeup.notify = acpi_notify_wakeup;
+ qemu_register_wakeup_notifier(&ar->wakeup);
}
void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
@@ -350,12 +367,8 @@ void acpi_pm1_cnt_write(ACPIREGS *ar, uint16_t val)
qemu_system_shutdown_request();
break;
case 1:
- /* ACPI_BITMASK_WAKE_STATUS should be set on resume.
- Pretend that resume was caused by power button */
- ar->pm1.evt.sts |=
- (ACPI_BITMASK_WAKE_STATUS | ACPI_BITMASK_POWER_BUTTON_STATUS);
- qemu_system_reset_request();
- qemu_irq_raise(ar->pm1.cnt.cmos_s3);
+ qemu_system_suspend_request();
+ break;
default:
break;
}
@@ -376,9 +389,6 @@ void acpi_pm1_cnt_update(ACPIREGS *ar,
void acpi_pm1_cnt_reset(ACPIREGS *ar)
{
ar->pm1.cnt.cnt = 0;
- if (ar->pm1.cnt.cmos_s3) {
- qemu_irq_lower(ar->pm1.cnt.cmos_s3);
- }
}
/* ACPI GPE */