summary refs log tree commit diff stats
path: root/hw/pci.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-06-30 14:12:07 +0200
committerPaul Brook <paul@codesourcery.com>2009-07-09 13:07:02 +0100
commit0aab0d3a4a62505ab7e79ee0a67fe3f04f6dae23 (patch)
tree59539fa84519cc5cc7aa24c4c7cb0435edfbdfbb /hw/pci.c
parente2b19c85ea0f3fd6091386adfd3a2acd21107cb4 (diff)
downloadfocaccia-qemu-0aab0d3a4a62505ab7e79ee0a67fe3f04f6dae23.tar.gz
focaccia-qemu-0aab0d3a4a62505ab7e79ee0a67fe3f04f6dae23.zip
qdev: update pci device registration.
Makes pci_qdev_register take a PCIDeviceInfo struct instead of a bunch
of parameters.  Also adds config_read and config_write callbacks to
PCIDeviceInfo, so drivers needing these can be converted to the qdev
device API too.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/pci.c')
-rw-r--r--hw/pci.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/hw/pci.c b/hw/pci.c
index 44580790d3..e82965ff12 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -874,11 +874,6 @@ PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint16_t vid, uint16_t did,
     return s->bus;
 }
 
-typedef struct {
-    DeviceInfo qdev;
-    pci_qdev_initfn init;
-} PCIDeviceInfo;
-
 static void pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
 {
     PCIDevice *pci_dev = (PCIDevice *)qdev;
@@ -889,25 +884,26 @@ static void pci_qdev_init(DeviceState *qdev, DeviceInfo *base)
     bus = FROM_QBUS(PCIBus, qdev_get_parent_bus(qdev));
     devfn = qdev_get_prop_int(qdev, "devfn", -1);
     pci_dev = do_pci_register_device(pci_dev, bus, "FIXME", devfn,
-                                     NULL, NULL);//FIXME:config_read, config_write);
+                                     info->config_read, info->config_write);
     assert(pci_dev);
     info->init(pci_dev);
 }
 
-void pci_qdev_register(const char *name, int size, pci_qdev_initfn init)
+void pci_qdev_register(PCIDeviceInfo *info)
 {
-    PCIDeviceInfo *info;
-
-    info = qemu_mallocz(sizeof(*info));
-    info->qdev.name = qemu_strdup(name);
-    info->qdev.size = size;
-    info->init = init;
     info->qdev.init = pci_qdev_init;
     info->qdev.bus_type = BUS_TYPE_PCI;
-
     qdev_register(&info->qdev);
 }
 
+void pci_qdev_register_many(PCIDeviceInfo *info)
+{
+    while (info->qdev.name) {
+        pci_qdev_register(info);
+        info++;
+    }
+}
+
 PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name)
 {
     DeviceState *dev;