[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/20] qdev: convert piix acpi.
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 09/20] qdev: convert piix acpi. |
Date: |
Mon, 29 Jun 2009 14:46:10 +0200 |
Hook up pci device and smbus into qdev.
TODO: smbus creation is still hardcoded.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/acpi.c | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/hw/acpi.c b/hw/acpi.c
index 5928fe7..f76ca0c 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -497,15 +497,11 @@ static void piix4_reset(void *opaque)
}
}
-i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
- qemu_irq sci_irq)
+static void piix4_pm_initfn(PCIDevice *dev)
{
- PIIX4PMState *s;
- uint8_t *pci_conf;
+ PIIX4PMState *s = DO_UPCAST(PIIX4PMState, dev, dev);
+ uint8_t *pci_conf = s->dev.config;
- s = (PIIX4PMState *)pci_register_device(bus,
- "PM", sizeof(PIIX4PMState),
- devfn, NULL, pm_write_config);
pm_state = s;
pci_conf = s->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
@@ -538,23 +534,49 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t
smb_io_base,
pci_conf[0x67] = (serial_hds[0] != NULL ? 0x08 : 0) |
(serial_hds[1] != NULL ? 0x90 : 0);
+ s->tmr_timer = qemu_new_timer(vm_clock, pm_tmr_timer, s);
+
+ register_savevm("piix4_pm", 0, 1, pm_save, pm_load, s);
+
+}
+
+i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+ qemu_irq sci_irq)
+{
+ PCIDevice *dev;
+ PIIX4PMState *s;
+ uint8_t *pci_conf;
+
+ dev = pci_create_simple(bus, devfn, "PM");
+ s = DO_UPCAST(PIIX4PMState, dev, dev);
+
+ pci_conf = s->dev.config;
pci_conf[0x90] = smb_io_base | 1;
pci_conf[0x91] = smb_io_base >> 8;
pci_conf[0xd2] = 0x09;
register_ioport_write(smb_io_base, 64, 1, smb_ioport_writeb, s);
register_ioport_read(smb_io_base, 64, 1, smb_ioport_readb, s);
+ s->smbus = i2c_init_bus(&s->dev.qdev, "i2c");
- s->tmr_timer = qemu_new_timer(vm_clock, pm_tmr_timer, s);
-
- register_savevm("piix4_pm", 0, 1, pm_save, pm_load, s);
-
- s->smbus = i2c_init_bus(NULL, "i2c");
s->irq = sci_irq;
qemu_register_reset(piix4_reset, 0, s);
return s->smbus;
}
+static PCIDeviceInfo acpi_info = {
+ .qdev.name = "PM",
+ .qdev.size = sizeof(PIIX4PMState),
+ .init = piix4_pm_initfn,
+ .config_write = pm_write_config,
+};
+
+static void acpi_register(void)
+{
+ pci_qdev_register(&acpi_info);
+}
+device_init(acpi_register);
+
#if defined(TARGET_I386)
void qemu_system_powerdown(void)
{
--
1.6.2.5
- [Qemu-devel] [PATCH 0/20] qdev patches., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 03/20] qdev: remove DeviceType, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 05/20] qdev/core: add monitor command to list all drivers, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 04/20] qdev/core: bus list, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 01/20] qdev: update pci device registration., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 06/20] qdev/pci: misc fixes., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 02/20] qdev: replace bus_type enum with bus_info struct., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 09/20] qdev: convert piix acpi.,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 08/20] qdev: convert piix-ide., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 07/20] qdev/pci: hook up i440fx., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 11/20] qdev: convert es1370., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 12/20] qdev: convert ac97., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 17/20] qdev: convert ohci., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 16/20] qdev/usb: print usb dev info, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 10/20] qdev: convert all vga, Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 13/20] qdev: convert uhci., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 15/20] qdev/usb: make qemu aware of usb busses., Gerd Hoffmann, 2009/06/29
- [Qemu-devel] [PATCH 14/20] qdev/usb: add usb bus support to qdev, convert drivers., Gerd Hoffmann, 2009/06/29