From fb92eb3152c7120ab0a4d7163645e8a4e7d1aaca Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Wed, 7 Mar 2012 08:00:21 +0100 Subject: [PATCH 07/12] suspend: make rtc alarm wakeup the guest. RH-Author: Gerd Hoffmann Message-id: <1331107226-21901-8-git-send-email-kraxel@redhat.com> Patchwork-id: 38359 O-Subject: [RHEL-6.3 qemu-kvm PATCH v3 07/12] suspend: make rtc alarm wakeup the guest. Bugzilla: 766303 RH-Acked-by: Paolo Bonzini RH-Acked-by: Gleb Natapov RH-Acked-by: Alex Williamson Make the rtc wake up the guest when the alarm fires. Add acpi windup to property support RTC_EN, so guests can enable and disable this. Signed-off-by: Gerd Hoffmann upstream: 62aeb0f765ea1f4a305a1963e66e94f7be9ac054 --- hw/acpi.c | 5 +++++ hw/mc146818rtc.c | 1 + sysemu.h | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- hw/acpi.c | 5 +++++ hw/mc146818rtc.c | 1 + sysemu.h | 1 + 3 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index 120865f..19d7c7a 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -82,6 +82,7 @@ typedef struct PIIX4PMState { } PIIX4PMState; #define RSM_STS (1 << 15) +#define RTC_STS (1 << 10) #define PWRBTN_STS (1 << 8) #define RTC_EN (1 << 10) #define PWRBTN_EN (1 << 8) @@ -152,6 +153,9 @@ static void acpi_notify_wakeup(Notifier *notifier, void *data) WakeupReason *reason = data; switch (*reason) { + case QEMU_WAKEUP_REASON_RTC: + s->pmsts |= (RSM_STS | RTC_STS); + break; case QEMU_WAKEUP_REASON_OTHER: default: /* RSM_STS should be set on resume. Pretend that resume @@ -183,6 +187,7 @@ static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val) break; case 0x02: s->pmen = val; + qemu_system_wakeup_enable(QEMU_WAKEUP_REASON_RTC, val & RTC_EN); pm_update_sci(s); break; case 0x04: diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c index be08e00..cba9ca8 100644 --- a/hw/mc146818rtc.c +++ b/hw/mc146818rtc.c @@ -432,6 +432,7 @@ static void rtc_update_second2(void *opaque) rtc_from_bcd(s, s->cmos_data[RTC_HOURS_ALARM]) == s->current_tm.tm_hour)) { s->cmos_data[RTC_REG_C] |= 0xa0; + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_RTC); rtc_irq_raise(s->irq); } } diff --git a/sysemu.h b/sysemu.h index e968915..770c69b 100644 --- a/sysemu.h +++ b/sysemu.h @@ -69,6 +69,7 @@ void cpu_disable_ticks(void); typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER = 0, + QEMU_WAKEUP_REASON_RTC, } WakeupReason; void qemu_system_reset_request(void); -- 1.7.7.6