LSI SCSI qdev conversion

Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
Paul Brook 2009-05-14 22:35:07 +01:00
parent 86394e969d
commit 9be5dafe48
6 changed files with 26 additions and 52 deletions

View File

@ -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);

12
hw/pc.c
View File

@ -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");
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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];

View File

@ -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]);