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++) {
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) */
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);
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");
}
}
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);
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);
/* 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);
CPUState *env;
ram_addr_t ram_offset;
qemu_irq *pic;
- void *scsi_hba;
PCIBus *pci_bus;
NICInfo *nd;
int n;
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];
ram_addr_t ram_offset;
qemu_irq *pic;
qemu_irq *sic;
- void *scsi_hba;
PCIBus *pci_bus;
NICInfo *nd;
int n;
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]);