qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] qdev: hook up i440fx pcihost to system bus.


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH] qdev: hook up i440fx pcihost to system bus.
Date: Mon, 8 Jun 2009 14:33:48 +0200

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 hw/pci_host.h |    1 +
 hw/piix_pci.c |   22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/hw/pci_host.h b/hw/pci_host.h
index 757b0e2..bd7adcb 100644
--- a/hw/pci_host.h
+++ b/hw/pci_host.h
@@ -36,6 +36,7 @@ do { printf("pci_host_data: " fmt , ## __VA_ARGS__); } while 
(0)
 #endif
 
 typedef struct {
+    DeviceState qdev;
     uint32_t config_reg;
     PCIBus *bus;
 } PCIHostState;
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 914a65a..8eed137 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -175,8 +175,8 @@ PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq 
*pic)
     PCIDevice *d;
     I440FXState *s;
 
-    s = qemu_mallocz(sizeof(I440FXState));
-    b = pci_register_bus(NULL, "pci", 
+    s = container_of(qdev_create(NULL, "i440FX-pcihost"), I440FXState, qdev);
+    b = pci_register_bus(&s->qdev, "pci", 
                          piix3_set_irq, pci_slot_get_pirq, pic, 0, 4);
     s->bus = b;
 
@@ -206,6 +206,24 @@ PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq 
*pic)
     return b;
 }
 
+static void i440fx_initfn(DeviceState *qdev, DeviceInfo *base)
+{
+    /* dummy for now ... */
+}
+
+static struct DeviceInfo i440fx_pcihost_devinfo = {
+    .init = i440fx_initfn,
+    .bus_type = BUS_TYPE_SYSTEM,
+};
+
+static void i440fx_register(void)
+{
+    qdev_register("i440FX-pcihost", sizeof(I440FXState),
+                  &i440fx_pcihost_devinfo);
+}
+
+device_init(i440fx_register);
+
 /* PIIX3 PCI to ISA bridge */
 
 static PCIDevice *piix3_dev;
-- 
1.6.2.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]