[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix ind
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent. |
Date: |
Tue, 7 Jul 2009 15:35:46 +0900 |
Make qemu_system_powerdown() piix independent by
registering callback function.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/acpi.c | 30 ++++++++++++++++++++++++++----
hw/acpi.h | 29 +++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 4 deletions(-)
create mode 100644 hw/acpi.h
diff --git a/hw/acpi.c b/hw/acpi.c
index 7351947..14015cd 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -26,6 +26,7 @@
#include "i2c.h"
#include "smbus.h"
#include "kvm.h"
+#include "acpi.h"
//#define DEBUG
@@ -323,6 +324,18 @@ static void piix4_reset(void *opaque)
}
}
+#if defined(TARGET_I386)
+static void piix4_pm_powerdown(void *arg)
+{
+ PIIX4PMState *pm_state = (PIIX4PMState*) arg;
+
+ if (pm_state->pmen & PWRBTN_EN) {
+ pm_state->pmsts |= PWRBTN_EN;
+ pm_update_sci(pm_state);
+ }
+}
+#endif
+
i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
qemu_irq sci_irq)
{
@@ -377,18 +390,27 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t
smb_io_base,
pc_smbus_init(&s->smb);
s->irq = sci_irq;
qemu_register_reset(piix4_reset, s);
+ qemu_system_powerdown_register(piix4_pm_powerdown, pm_state);
return s->smb.smbus;
}
#if defined(TARGET_I386)
+static qemu_powerdown_t qemu_powerdown_callback;
+static void *qemu_powerdown_arg;
+
+void qemu_system_powerdown_register(qemu_powerdown_t callback, void *arg)
+{
+ qemu_powerdown_callback = callback;
+ qemu_powerdown_arg = arg;
+}
+
void qemu_system_powerdown(void)
{
- if (!pm_state) {
+ if (!qemu_powerdown_callback) {
qemu_system_shutdown_request();
- } else if (pm_state->pmen & PWRBTN_EN) {
- pm_state->pmsts |= PWRBTN_EN;
- pm_update_sci(pm_state);
+ } else {
+ qemu_powerdown_callback(qemu_powerdown_arg);
}
}
#endif
diff --git a/hw/acpi.h b/hw/acpi.h
new file mode 100644
index 0000000..884512c
--- /dev/null
+++ b/hw/acpi.h
@@ -0,0 +1,29 @@
+#ifndef QEMU_HW_ACPI_H
+#define QEMU_HW_ACPI_H
+/*
+ * Copyright (c) 2009 Isaku Yamahata <yamahata at valinux co jp>
+ * VA Linux Systems Japan K.K.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
+ */
+
+#if defined(TARGET_I386)
+typedef void (*qemu_powerdown_t)(void *arg);
+void qemu_system_powerdown_register(qemu_powerdown_t callback, void *arg);
+#else
+#define qemu_system_powerdown_register(callback, arg) do { } while (0)
+#endif
+
+#endif /* !QEMU_HW_ACPI_H */
--
1.6.0.2
- [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v3, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 01/17] acpi.c: split out pc smbus routines from acpi.c into pc_smbus.c, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 04/17] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 17/17] pc.c: split out piix specific part from pc.c into pc_piix.c, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 07/17] pc.c: remove unnecessary global variables, pit and ioapic.., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 02/17] acpi.c: split out apm register emulation., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 11/17] pc.c: make pc_init1() not refer ferr_irq directly., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 13/17] pc.c: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 09/17] pc.c: remove a global variable, RTCState *rtc_state., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 14/17] pc.c: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 06/17] pc.c: Make smm enable/disable function i440fx independent., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 05/17] acpi.c: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 08/17] pc.c: remove a global variable, floppy_controller., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 12/17] pc.c: split out cpu initialization from pc_init1() into pc_cpus_init()., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 10/17] pc.c: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 15/17] pc.c: split out basic device init from pc_init1() into pc_basic_device_init(), Isaku Yamahata, 2009/07/07