From 0aab0d3a4a62505ab7e79ee0a67fe3f04f6dae23 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 30 Jun 2009 14:12:07 +0200 Subject: 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 --- hw/pci.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'hw/pci.c') 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; -- cgit 1.4.1