aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2009-08-09 08:42:19 +0000
committerBlue Swirl <blauwirbel@gmail.com>2009-08-09 08:42:19 +0000
commitd9c3231019a0fbacbe15dcb26a0e3708b726af77 (patch)
treef00d2747772fbf49fcc46cefcd8f30bec97154a2
parentb2b6f6ec3996925ebc85e77c5ac31ff34e8783f6 (diff)
Use qemu_irq for system_powerdown
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
-rw-r--r--hw/acpi.c28
-rw-r--r--hw/sun4m.c9
-rw-r--r--hw/sun4u.c4
-rw-r--r--sysemu.h9
-rw-r--r--vl.c7
5 files changed, 23 insertions, 34 deletions
diff --git a/hw/acpi.c b/hw/acpi.c
index 056e4c6344..37a5d9823b 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -496,6 +496,20 @@ static void piix4_reset(void *opaque)
}
}
+static void piix4_powerdown(void *opaque, int irq, int power_failing)
+{
+#if defined(TARGET_I386)
+ PIIX4PMState *s = opaque;
+
+ if (!s) {
+ qemu_system_shutdown_request();
+ } else if (s->pmen & PWRBTN_EN) {
+ s->pmsts |= PWRBTN_EN;
+ pm_update_sci(s);
+ }
+#endif
+}
+
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq)
{
@@ -545,6 +559,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
s->tmr_timer = qemu_new_timer(vm_clock, pm_tmr_timer, s);
+ qemu_system_powerdown = *qemu_allocate_irqs(piix4_powerdown, s, 1);
+
register_savevm("piix4_pm", 0, 1, pm_save, pm_load, s);
s->smbus = i2c_init_bus(NULL, "i2c");
@@ -554,18 +570,6 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
return s->smbus;
}
-#if defined(TARGET_I386)
-void qemu_system_powerdown(void)
-{
- if (!pm_state) {
- qemu_system_shutdown_request();
- } else if (pm_state->pmen & PWRBTN_EN) {
- pm_state->pmsts |= PWRBTN_EN;
- pm_update_sci(pm_state);
- }
-}
-#endif
-
#define GPE_BASE 0xafe0
#define PCI_BASE 0xae00
#define PCI_EJ_BASE 0xae08
diff --git a/hw/sun4m.c b/hw/sun4m.c
index 5e47240af3..abadfd6ffe 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -451,13 +451,6 @@ static void slavio_timer_init_all(target_phys_addr_t addr, qemu_irq master_irq,
#define MISC_MDM 0x01b00000
#define MISC_SYS 0x01f00000
-static qemu_irq slavio_powerdown;
-
-void qemu_system_powerdown(void)
-{
- qemu_irq_raise(slavio_powerdown);
-}
-
static void slavio_misc_init(target_phys_addr_t base,
target_phys_addr_t aux1_base,
target_phys_addr_t aux2_base, qemu_irq irq,
@@ -494,7 +487,7 @@ static void slavio_misc_init(target_phys_addr_t base,
}
sysbus_connect_irq(s, 0, irq);
sysbus_connect_irq(s, 1, fdc_tc);
- slavio_powerdown = qdev_get_gpio_in(dev, 0);
+ qemu_system_powerdown = qdev_get_gpio_in(dev, 0);
}
static void ecc_init(target_phys_addr_t base, qemu_irq irq, uint32_t version)
diff --git a/hw/sun4u.c b/hw/sun4u.c
index cede477cc7..59bcf64ebe 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -254,10 +254,6 @@ static void cpu_set_irq(void *opaque, int irq, int level)
}
}
-void qemu_system_powerdown(void)
-{
-}
-
typedef struct ResetData {
CPUState *env;
uint64_t reset_addr;
diff --git a/sysemu.h b/sysemu.h
index 6af88d82e1..c7065ac038 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -47,14 +47,7 @@ void qemu_system_powerdown_request(void);
int qemu_shutdown_requested(void);
int qemu_reset_requested(void);
int qemu_powerdown_requested(void);
-#ifdef NEED_CPU_H
-#if !defined(TARGET_SPARC) && !defined(TARGET_I386)
-// Please implement a power failure function to signal the OS
-#define qemu_system_powerdown() do{}while(0)
-#else
-void qemu_system_powerdown(void);
-#endif
-#endif
+extern qemu_irq qemu_system_powerdown;
void qemu_system_reset(void);
void do_savevm(Monitor *mon, const char *name);
diff --git a/vl.c b/vl.c
index fdd4f033a8..a526cb0f35 100644
--- a/vl.c
+++ b/vl.c
@@ -4281,6 +4281,8 @@ static int vm_can_run(void)
return 1;
}
+qemu_irq qemu_system_powerdown;
+
static void main_loop(void)
{
int r;
@@ -4321,8 +4323,9 @@ static void main_loop(void)
qemu_system_reset();
resume_all_vcpus();
}
- if (qemu_powerdown_requested())
- qemu_system_powerdown();
+ if (qemu_powerdown_requested()) {
+ qemu_irq_raise(qemu_system_powerdown);
+ }
if ((r = qemu_vmstop_requested()))
vm_stop(r);
}