qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 07/10] qdev-ify: piix acpi
Date: Wed, 17 Jun 2009 14:59:22 +0200	[thread overview]
Message-ID: <1245243565-24807-8-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1245243565-24807-1-git-send-email-kraxel@redhat.com>


Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/acpi.c |   46 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index fccae69..6b627cb 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, 1);
+}
+device_init(acpi_register);
+
 #if defined(TARGET_I386)
 void qemu_system_powerdown(void)
 {
-- 
1.6.2.2

  parent reply	other threads:[~2009-06-17 12:59 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-17 12:59 [Qemu-devel] [PATCH 0/10] qdev patches Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 01/10] qdev: update pci device registration Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 02/10] qdev: replace bus_type enum with bus_info struct Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 03/10] qdev: remove DeviceType Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 04/10] qdev/pci: bus name Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 05/10] qdev: hook up i440fx Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 06/10] qdev: convert piix-ide, first step Gerd Hoffmann
2009-06-17 12:59 ` Gerd Hoffmann [this message]
2009-06-17 12:59 ` [Qemu-devel] [PATCH 08/10] qdev-ify: uhci Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 09/10] qdev-ify: usb Gerd Hoffmann
2009-06-17 12:59 ` [Qemu-devel] [PATCH 10/10] qdev-ify: scsi Gerd Hoffmann
2009-06-18 14:39 ` [Qemu-devel] Re: [PATCH 0/10] qdev patches Gerd Hoffmann
2009-06-19 15:59   ` Gerd Hoffmann
2009-06-19 17:51     ` Paul Brook
2009-06-22  9:15       ` Gerd Hoffmann
2009-06-22  9:36         ` Avi Kivity
2009-06-22  9:57           ` Gerd Hoffmann
2009-06-22 11:25             ` Gerd Hoffmann
2009-06-22 11:29               ` Avi Kivity
2009-06-22 14:02         ` Gerd Hoffmann
2009-06-22 13:45       ` Gerd Hoffmann
2009-06-19 16:26 ` [Qemu-devel] " Paul Brook
2009-06-26 21:16   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245243565-24807-8-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).