diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2009-06-30 14:12:07 +0200 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-07-09 13:07:02 +0100 |
commit | 0aab0d3a4a62505ab7e79ee0a67fe3f04f6dae23 (patch) | |
tree | 59539fa84519cc5cc7aa24c4c7cb0435edfbdfbb /hw | |
parent | e2b19c85ea0f3fd6091386adfd3a2acd21107cb4 (diff) |
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')
-rw-r--r-- | hw/e1000.c | 8 | ||||
-rw-r--r-- | hw/eepro100.c | 25 | ||||
-rw-r--r-- | hw/lsi53c895a.c | 8 | ||||
-rw-r--r-- | hw/ne2000.c | 8 | ||||
-rw-r--r-- | hw/pci.c | 24 | ||||
-rw-r--r-- | hw/pci.h | 10 | ||||
-rw-r--r-- | hw/pcnet.c | 8 | ||||
-rw-r--r-- | hw/rtl8139.c | 8 | ||||
-rw-r--r-- | hw/versatile_pci.c | 9 | ||||
-rw-r--r-- | hw/virtio-pci.c | 31 |
10 files changed, 103 insertions, 36 deletions
diff --git a/hw/e1000.c b/hw/e1000.c index da07c46039..4ac8918593 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -1125,9 +1125,15 @@ static void pci_e1000_init(PCIDevice *pci_dev) e1000_reset(d); } +static PCIDeviceInfo e1000_info = { + .qdev.name = "e1000", + .qdev.size = sizeof(E1000State), + .init = pci_e1000_init, +}; + static void e1000_register_devices(void) { - pci_qdev_register("e1000", sizeof(E1000State), pci_e1000_init); + pci_qdev_register(&e1000_info); } device_init(e1000_register_devices) diff --git a/hw/eepro100.c b/hw/eepro100.c index 00021408c2..85446ed697 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -1792,14 +1792,27 @@ static void pci_i82559er_init(PCIDevice *dev) nic_init(dev, i82559ER); } +static PCIDeviceInfo eepro100_info[] = { + { + .qdev.name = "i82551", + .qdev.size = sizeof(PCIEEPRO100State), + .init = pci_i82551_init, + },{ + .qdev.name = "i82557b", + .qdev.size = sizeof(PCIEEPRO100State), + .init = pci_i82557b_init, + },{ + .qdev.name = "i82559er", + .qdev.size = sizeof(PCIEEPRO100State), + .init = pci_i82559er_init, + },{ + /* end of list */ + } +}; + static void eepro100_register_devices(void) { - pci_qdev_register("i82551", sizeof(PCIEEPRO100State), - pci_i82551_init); - pci_qdev_register("i82557b", sizeof(PCIEEPRO100State), - pci_i82557b_init); - pci_qdev_register("i82559er", sizeof(PCIEEPRO100State), - pci_i82559er_init); + pci_qdev_register_many(eepro100_info); } device_init(eepro100_register_devices) diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index 71f8281165..516a46842e 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -2035,9 +2035,15 @@ static void lsi_scsi_init(PCIDevice *dev) scsi_bus_new(&dev->qdev, lsi_scsi_attach); } +static PCIDeviceInfo lsi_info = { + .qdev.name = "lsi53c895a", + .qdev.size = sizeof(LSIState), + .init = lsi_scsi_init, +}; + static void lsi53c895a_register_devices(void) { - pci_qdev_register("lsi53c895a", sizeof(LSIState), lsi_scsi_init); + pci_qdev_register(&lsi_info); } device_init(lsi53c895a_register_devices); diff --git a/hw/ne2000.c b/hw/ne2000.c index 66ae9ab03b..66ff29d0fc 100644 --- a/hw/ne2000.c +++ b/hw/ne2000.c @@ -832,9 +832,15 @@ static void pci_ne2000_init(PCIDevice *pci_dev) register_savevm("ne2000", -1, 3, ne2000_save, ne2000_load, s); } +static PCIDeviceInfo ne2000_info = { + .qdev.name = "ne2k_pci", + .qdev.size = sizeof(PCINE2000State), + .init = pci_ne2000_init, +}; + static void ne2000_register_devices(void) { - pci_qdev_register("ne2k_pci", sizeof(PCINE2000State), pci_ne2000_init); + pci_qdev_register(&ne2000_info); } device_init(ne2000_register_devices) @@ -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; @@ -314,7 +314,15 @@ pci_config_set_class(uint8_t *pci_config, uint16_t val) } typedef void (*pci_qdev_initfn)(PCIDevice *dev); -void pci_qdev_register(const char *name, int size, pci_qdev_initfn init); +typedef struct { + DeviceInfo qdev; + pci_qdev_initfn init; + PCIConfigReadFunc *config_read; + PCIConfigWriteFunc *config_write; +} PCIDeviceInfo; + +void pci_qdev_register(PCIDeviceInfo *info); +void pci_qdev_register_many(PCIDeviceInfo *info); PCIDevice *pci_create(const char *name, const char *devaddr); PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); diff --git a/hw/pcnet.c b/hw/pcnet.c index a184146e0d..4519780cf8 100644 --- a/hw/pcnet.c +++ b/hw/pcnet.c @@ -2143,9 +2143,15 @@ static void lance_init(SysBusDevice *dev) } #endif /* TARGET_SPARC */ +static PCIDeviceInfo pcnet_info = { + .qdev.name = "pcnet", + .qdev.size = sizeof(PCIPCNetState), + .init = pci_pcnet_init, +}; + static void pcnet_register_devices(void) { - pci_qdev_register("pcnet", sizeof(PCIPCNetState), pci_pcnet_init); + pci_qdev_register(&pcnet_info); #if defined (TARGET_SPARC) && !defined(TARGET_SPARC64) sysbus_register_dev("lance", sizeof(SysBusPCNetState), lance_init); #endif diff --git a/hw/rtl8139.c b/hw/rtl8139.c index 2280018b81..91165dbff4 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -3499,9 +3499,15 @@ static void pci_rtl8139_init(PCIDevice *dev) #endif /* RTL8139_ONBOARD_TIMER */ } +static PCIDeviceInfo rtl8139_info = { + .qdev.name = "rtl8139", + .qdev.size = sizeof(PCIRTL8139State), + .init = pci_rtl8139_init, +}; + static void rtl8139_register_devices(void) { - pci_qdev_register("rtl8139", sizeof(PCIRTL8139State), pci_rtl8139_init); + pci_qdev_register(&rtl8139_info); } device_init(rtl8139_register_devices) diff --git a/hw/versatile_pci.c b/hw/versatile_pci.c index e89add1be5..5eb26251a3 100644 --- a/hw/versatile_pci.c +++ b/hw/versatile_pci.c @@ -153,13 +153,18 @@ static void versatile_pci_host_init(PCIDevice *d) d->config[0x0D] = 0x10; // latency_timer } +static PCIDeviceInfo versatile_pci_host_info = { + .qdev.name = "versatile_pci_host", + .qdev.size = sizeof(PCIDevice), + .init = versatile_pci_host_init, +}; + static void versatile_pci_register_devices(void) { sysbus_register_dev("versatile_pci", sizeof(PCIVPBState), pci_vpb_init); sysbus_register_dev("realview_pci", sizeof(PCIVPBState), pci_realview_init); - pci_qdev_register("versatile_pci_host", sizeof(PCIDevice), - versatile_pci_host_init); + pci_qdev_register(&versatile_pci_host_info); } device_init(versatile_pci_register_devices) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index f7da503752..39e290dc62 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -466,16 +466,31 @@ static void virtio_balloon_init_pci(PCIDevice *pci_dev) 0x00); } +static PCIDeviceInfo virtio_info[] = { + { + .qdev.name = "virtio-blk-pci", + .qdev.size = sizeof(VirtIOPCIProxy), + .init = virtio_blk_init_pci, + },{ + .qdev.name = "virtio-net-pci", + .qdev.size = sizeof(VirtIOPCIProxy), + .init = virtio_net_init_pci, + },{ + .qdev.name = "virtio-console-pci", + .qdev.size = sizeof(VirtIOPCIProxy), + .init = virtio_console_init_pci, + },{ + .qdev.name = "virtio-balloon-pci", + .qdev.size = sizeof(VirtIOPCIProxy), + .init = virtio_balloon_init_pci, + },{ + /* end of list */ + } +}; + static void virtio_pci_register_devices(void) { - pci_qdev_register("virtio-blk-pci", sizeof(VirtIOPCIProxy), - virtio_blk_init_pci); - pci_qdev_register("virtio-net-pci", sizeof(VirtIOPCIProxy), - virtio_net_init_pci); - pci_qdev_register("virtio-console-pci", sizeof(VirtIOPCIProxy), - virtio_console_init_pci); - pci_qdev_register("virtio-balloon-pci", sizeof(VirtIOPCIProxy), - virtio_balloon_init_pci); + pci_qdev_register_many(virtio_info); } device_init(virtio_pci_register_devices) |