summaryrefslogtreecommitdiff
path: root/hw/acpi.c
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2010-05-14 16:29:00 +0900
committerBlue Swirl <blauwirbel@gmail.com>2010-05-15 15:27:19 +0000
commit04762841d8803429fd9bf71eff481d3c5915fa3e (patch)
treecc0ca1c2fe8454d2633b8b1f0fd15aad850a1a62 /hw/acpi.c
parentfc0bdd995ca36a34cc576ee706df239dd5ff79a9 (diff)
downloadqemu-04762841d8803429fd9bf71eff481d3c5915fa3e.tar.gz
acpi: split out apm register emulation from acpi.c
Split out apm register emulation for acpi.c into apm.c. The apm emulation will be used later. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Cc: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'hw/acpi.c')
-rw-r--r--hw/acpi.c61
1 files changed, 18 insertions, 43 deletions
diff --git a/hw/acpi.c b/hw/acpi.c
index ad8f4c79dd..8dc9538dd8 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -17,6 +17,7 @@
*/
#include "hw.h"
#include "pc.h"
+#include "apm.h"
#include "pm_smbus.h"
#include "pci.h"
#include "qemu-timer.h"
@@ -36,8 +37,9 @@ typedef struct PIIX4PMState {
uint16_t pmsts;
uint16_t pmen;
uint16_t pmcntrl;
- uint8_t apmc;
- uint8_t apms;
+
+ APMState apm;
+
QEMUTimer *tmr_timer;
int64_t tmr_overflow_time;
@@ -218,48 +220,22 @@ static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
return val;
}
-static void pm_smi_writeb(void *opaque, uint32_t addr, uint32_t val)
+static void apm_ctrl_changed(uint32_t val, void *arg)
{
- PIIX4PMState *s = opaque;
- addr &= 1;
-#ifdef DEBUG
- printf("pm_smi_writeb addr=0x%x val=0x%02x\n", addr, val);
-#endif
- if (addr == 0) {
- s->apmc = val;
-
- /* ACPI specs 3.0, 4.7.2.5 */
- if (val == ACPI_ENABLE) {
- s->pmcntrl |= SCI_EN;
- } else if (val == ACPI_DISABLE) {
- s->pmcntrl &= ~SCI_EN;
- }
+ PIIX4PMState *s = arg;
- if (s->dev.config[0x5b] & (1 << 1)) {
- if (s->smi_irq) {
- qemu_irq_raise(s->smi_irq);
- }
- }
- } else {
- s->apms = val;
+ /* ACPI specs 3.0, 4.7.2.5 */
+ if (val == ACPI_ENABLE) {
+ s->pmcntrl |= SCI_EN;
+ } else if (val == ACPI_DISABLE) {
+ s->pmcntrl &= ~SCI_EN;
}
-}
-static uint32_t pm_smi_readb(void *opaque, uint32_t addr)
-{
- PIIX4PMState *s = opaque;
- uint32_t val;
-
- addr &= 1;
- if (addr == 0) {
- val = s->apmc;
- } else {
- val = s->apms;
+ if (s->dev.config[0x5b] & (1 << 1)) {
+ if (s->smi_irq) {
+ qemu_irq_raise(s->smi_irq);
+ }
}
-#ifdef DEBUG
- printf("pm_smi_readb addr=0x%x val=0x%02x\n", addr, val);
-#endif
- return val;
}
static void acpi_dbg_writel(void *opaque, uint32_t addr, uint32_t val)
@@ -315,8 +291,7 @@ static const VMStateDescription vmstate_acpi = {
VMSTATE_UINT16(pmsts, PIIX4PMState),
VMSTATE_UINT16(pmen, PIIX4PMState),
VMSTATE_UINT16(pmcntrl, PIIX4PMState),
- VMSTATE_UINT8(apmc, PIIX4PMState),
- VMSTATE_UINT8(apms, PIIX4PMState),
+ VMSTATE_STRUCT(apm, PIIX4PMState, 0, vmstate_apm, APMState),
VMSTATE_TIMER(tmr_timer, PIIX4PMState),
VMSTATE_INT64(tmr_overflow_time, PIIX4PMState),
VMSTATE_END_OF_LIST()
@@ -375,8 +350,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
pci_conf[0x40] = 0x01; /* PM io base read only bit */
- register_ioport_write(0xb2, 2, 1, pm_smi_writeb, s);
- register_ioport_read(0xb2, 2, 1, pm_smi_readb, s);
+ /* APM */
+ apm_init(&s->apm, apm_ctrl_changed, s);
register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);