From 04dc308f687d45dacc664251b266b6849f5a79d0 Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Fri, 25 Mar 2011 19:54:39 +0900 Subject: acpi, acpi_piix, vt82c686: factor out PM1a EVT logic factor out ACPI PM1a EVT logic. Later this will be used by ich9 acpi. Cc: Blue Swirl Cc: Huacai Chen Cc: Aurelien Jarno Signed-off-by: Isaku Yamahata Signed-off-by: Aurelien Jarno --- hw/acpi.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'hw/acpi.c') diff --git a/hw/acpi.c b/hw/acpi.c index 08cb126..07283be 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -15,6 +15,7 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see */ +#include "sysemu.h" #include "hw.h" #include "pc.h" #include "acpi.h" @@ -198,6 +199,42 @@ out: return -1; } +/* ACPI PM1a EVT */ +uint16_t acpi_pm1_evt_get_sts(ACPIPM1EVT *pm1, int64_t overflow_time) +{ + int64_t d = acpi_pm_tmr_get_clock(); + if (d >= overflow_time) { + pm1->sts |= ACPI_BITMASK_TIMER_STATUS; + } + return pm1->sts; +} + +void acpi_pm1_evt_write_sts(ACPIPM1EVT *pm1, ACPIPMTimer *tmr, uint16_t val) +{ + uint16_t pm1_sts = acpi_pm1_evt_get_sts(pm1, tmr->overflow_time); + if (pm1_sts & val & ACPI_BITMASK_TIMER_STATUS) { + /* if TMRSTS is reset, then compute the new overflow time */ + acpi_pm_tmr_calc_overflow_time(tmr); + } + pm1->sts &= ~val; +} + +void acpi_pm1_evt_power_down(ACPIPM1EVT *pm1, ACPIPMTimer *tmr) +{ + if (!pm1) { + qemu_system_shutdown_request(); + } else if (pm1->en & ACPI_BITMASK_POWER_BUTTON_ENABLE) { + pm1->sts |= ACPI_BITMASK_POWER_BUTTON_STATUS; + tmr->update_sci(tmr); + } +} + +void acpi_pm1_evt_reset(ACPIPM1EVT *pm1) +{ + pm1->sts = 0; + pm1->en = 0; +} + /* ACPI PM_TMR */ void acpi_pm_tmr_update(ACPIPMTimer *tmr, bool enable) { -- cgit v1.1