diff options
-rw-r--r-- | hw/lsi53c895a.c | 24 | ||||
-rw-r--r-- | hw/pc.c | 12 | ||||
-rw-r--r-- | hw/pci-hotplug.c | 9 | ||||
-rw-r--r-- | hw/pci.h | 3 | ||||
-rw-r--r-- | hw/realview.c | 15 | ||||
-rw-r--r-- | hw/versatilepb.c | 15 |
6 files changed, 26 insertions, 52 deletions
diff --git a/hw/lsi53c895a.c b/hw/lsi53c895a.c index f4e57aedb5..39d8ea20fa 100644 --- a/hw/lsi53c895a.c +++ b/hw/lsi53c895a.c @@ -1939,9 +1939,9 @@ static void lsi_mmio_mapfunc(PCIDevice *pci_dev, int region_num, cpu_register_physical_memory(addr + 0, 0x400, s->mmio_io_addr); } -void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id) +void lsi_scsi_attach(DeviceState *host, BlockDriverState *bd, int id) { - LSIState *s = (LSIState *)opaque; + LSIState *s = (LSIState *)host; if (id < 0) { for (id = 0; id < LSI_MAX_DEVS; id++) { @@ -1976,18 +1976,11 @@ static int lsi_scsi_uninit(PCIDevice *d) return 0; } -void *lsi_scsi_init(PCIBus *bus, int devfn) +static void lsi_scsi_init(PCIDevice *dev) { - LSIState *s; + LSIState *s = (LSIState *)dev; uint8_t *pci_conf; - s = (LSIState *)pci_register_device(bus, "LSI53C895A SCSI HBA", - sizeof(*s), devfn, NULL, NULL); - if (s == NULL) { - fprintf(stderr, "lsi-scsi: Failed to register PCI device\n"); - return NULL; - } - pci_conf = s->pci_dev.config; /* PCI Vendor ID (word) */ @@ -2022,5 +2015,12 @@ void *lsi_scsi_init(PCIBus *bus, int devfn) lsi_soft_reset(s); - return s; + scsi_bus_new(&dev->qdev, lsi_scsi_attach); } + +static void lsi53c895a_register_devices(void) +{ + pci_qdev_register("lsi53c895a", sizeof(LSIState), lsi_scsi_init); +} + +device_init(lsi53c895a_register_devices); @@ -1122,19 +1122,11 @@ static void pc_init1(ram_addr_t ram_size, if (pci_enabled) { int max_bus; - int bus, unit; - void *scsi; + int bus; max_bus = drive_get_max_bus(IF_SCSI); - for (bus = 0; bus <= max_bus; bus++) { - scsi = lsi_scsi_init(pci_bus, -1); - for (unit = 0; unit < LSI_MAX_DEVS; unit++) { - index = drive_get_index(IF_SCSI, bus, unit); - if (index == -1) - continue; - lsi_scsi_attach(scsi, drives_table[index].bdrv, unit); - } + pci_create_simple(pci_bus, -1, "lsi53c895a"); } } diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 603d74d1e5..294fdd11e2 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -71,8 +71,8 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts) switch (type) { case IF_SCSI: success = 1; - lsi_scsi_attach (dev, drives_table[drive_idx].bdrv, - drives_table[drive_idx].unit); + lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv, + drives_table[drive_idx].unit); break; default: monitor_printf(mon, "Can't hot-add drive to type %d\n", type); @@ -117,10 +117,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus, switch (type) { case IF_SCSI: - opaque = lsi_scsi_init (pci_bus, -1); - if (opaque && drive_idx >= 0) - lsi_scsi_attach (opaque, drives_table[drive_idx].bdrv, - drives_table[drive_idx].unit); + opaque = pci_create_simple(pci_bus, -1, "lsi53c895a"); break; case IF_VIRTIO: opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv); @@ -227,8 +227,7 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); /* lsi53c895a.c */ #define LSI_MAX_DEVS 7 -void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id); -void *lsi_scsi_init(PCIBus *bus, int devfn); +void lsi_scsi_attach(DeviceState *host, BlockDriverState *bd, int id); /* vmware_vga.c */ void pci_vmsvga_init(PCIBus *bus); diff --git a/hw/realview.c b/hw/realview.c index 3ec8a3cb75..e227f72575 100644 --- a/hw/realview.c +++ b/hw/realview.c @@ -32,7 +32,6 @@ static void realview_init(ram_addr_t ram_size, CPUState *env; ram_addr_t ram_offset; qemu_irq *pic; - void *scsi_hba; PCIBus *pci_bus; NICInfo *nd; int n; @@ -111,16 +110,10 @@ static void realview_init(ram_addr_t ram_size, if (usb_enabled) { usb_ohci_init_pci(pci_bus, 3, -1); } - if (drive_get_max_bus(IF_SCSI) > 0) { - fprintf(stderr, "qemu: too many SCSI bus\n"); - exit(1); - } - scsi_hba = lsi_scsi_init(pci_bus, -1); - for (n = 0; n < LSI_MAX_DEVS; n++) { - index = drive_get_index(IF_SCSI, 0, n); - if (index == -1) - continue; - lsi_scsi_attach(scsi_hba, drives_table[index].bdrv, n); + n = drive_get_max_bus(IF_SCSI); + while (n >= 0) { + pci_create_simple(pci_bus, -1, "lsi53c895a"); + n--; } for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; diff --git a/hw/versatilepb.c b/hw/versatilepb.c index d9e1cfc81e..19b66bb402 100644 --- a/hw/versatilepb.c +++ b/hw/versatilepb.c @@ -163,7 +163,6 @@ static void versatile_init(ram_addr_t ram_size, ram_addr_t ram_offset; qemu_irq *pic; qemu_irq *sic; - void *scsi_hba; PCIBus *pci_bus; NICInfo *nd; int n; @@ -206,16 +205,10 @@ static void versatile_init(ram_addr_t ram_size, if (usb_enabled) { usb_ohci_init_pci(pci_bus, 3, -1); } - if (drive_get_max_bus(IF_SCSI) > 0) { - fprintf(stderr, "qemu: too many SCSI bus\n"); - exit(1); - } - scsi_hba = lsi_scsi_init(pci_bus, -1); - for (n = 0; n < LSI_MAX_DEVS; n++) { - index = drive_get_index(IF_SCSI, 0, n); - if (index == -1) - continue; - lsi_scsi_attach(scsi_hba, drives_table[index].bdrv, n); + n = drive_get_max_bus(IF_SCSI); + while (n >= 0) { + pci_create_simple(pci_bus, -1, "lsi53c895a"); + n--; } sysbus_create_simple("pl011", 0x101f1000, pic[12]); |