LSI SCSI qdev conversion
Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
		
							parent
							
								
									86394e969d
								
							
						
					
					
						commit
						9be5dafe48
					
				@ -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);
 | 
					    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) {
 | 
					    if (id < 0) {
 | 
				
			||||||
        for (id = 0; id < LSI_MAX_DEVS; id++) {
 | 
					        for (id = 0; id < LSI_MAX_DEVS; id++) {
 | 
				
			||||||
@ -1976,18 +1976,11 @@ static int lsi_scsi_uninit(PCIDevice *d)
 | 
				
			|||||||
    return 0;
 | 
					    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;
 | 
					    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_conf = s->pci_dev.config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* PCI Vendor ID (word) */
 | 
					    /* PCI Vendor ID (word) */
 | 
				
			||||||
@ -2022,5 +2015,12 @@ void *lsi_scsi_init(PCIBus *bus, int devfn)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    lsi_soft_reset(s);
 | 
					    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
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								hw/pc.c
									
									
									
									
									
								
							@ -1122,19 +1122,11 @@ static void pc_init1(ram_addr_t ram_size,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (pci_enabled) {
 | 
					    if (pci_enabled) {
 | 
				
			||||||
	int max_bus;
 | 
						int max_bus;
 | 
				
			||||||
        int bus, unit;
 | 
					        int bus;
 | 
				
			||||||
        void *scsi;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        max_bus = drive_get_max_bus(IF_SCSI);
 | 
					        max_bus = drive_get_max_bus(IF_SCSI);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (bus = 0; bus <= max_bus; bus++) {
 | 
						for (bus = 0; bus <= max_bus; bus++) {
 | 
				
			||||||
            scsi = lsi_scsi_init(pci_bus, -1);
 | 
					            pci_create_simple(pci_bus, -1, "lsi53c895a");
 | 
				
			||||||
            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);
 | 
					 | 
				
			||||||
	    }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,7 @@ void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts)
 | 
				
			|||||||
    switch (type) {
 | 
					    switch (type) {
 | 
				
			||||||
    case IF_SCSI:
 | 
					    case IF_SCSI:
 | 
				
			||||||
        success = 1;
 | 
					        success = 1;
 | 
				
			||||||
        lsi_scsi_attach (dev, drives_table[drive_idx].bdrv,
 | 
					        lsi_scsi_attach(&dev->qdev, drives_table[drive_idx].bdrv,
 | 
				
			||||||
                        drives_table[drive_idx].unit);
 | 
					                        drives_table[drive_idx].unit);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
@ -117,10 +117,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon, PCIBus *pci_bus,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    switch (type) {
 | 
					    switch (type) {
 | 
				
			||||||
    case IF_SCSI:
 | 
					    case IF_SCSI:
 | 
				
			||||||
        opaque = lsi_scsi_init (pci_bus, -1);
 | 
					        opaque = pci_create_simple(pci_bus, -1, "lsi53c895a");
 | 
				
			||||||
        if (opaque && drive_idx >= 0)
 | 
					 | 
				
			||||||
            lsi_scsi_attach (opaque, drives_table[drive_idx].bdrv,
 | 
					 | 
				
			||||||
                             drives_table[drive_idx].unit);
 | 
					 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
    case IF_VIRTIO:
 | 
					    case IF_VIRTIO:
 | 
				
			||||||
        opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv);
 | 
					        opaque = virtio_blk_init (pci_bus, drives_table[drive_idx].bdrv);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								hw/pci.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								hw/pci.h
									
									
									
									
									
								
							@ -227,8 +227,7 @@ PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* lsi53c895a.c */
 | 
					/* lsi53c895a.c */
 | 
				
			||||||
#define LSI_MAX_DEVS 7
 | 
					#define LSI_MAX_DEVS 7
 | 
				
			||||||
void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
 | 
					void lsi_scsi_attach(DeviceState *host, BlockDriverState *bd, int id);
 | 
				
			||||||
void *lsi_scsi_init(PCIBus *bus, int devfn);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* vmware_vga.c */
 | 
					/* vmware_vga.c */
 | 
				
			||||||
void pci_vmsvga_init(PCIBus *bus);
 | 
					void pci_vmsvga_init(PCIBus *bus);
 | 
				
			||||||
 | 
				
			|||||||
@ -32,7 +32,6 @@ static void realview_init(ram_addr_t ram_size,
 | 
				
			|||||||
    CPUState *env;
 | 
					    CPUState *env;
 | 
				
			||||||
    ram_addr_t ram_offset;
 | 
					    ram_addr_t ram_offset;
 | 
				
			||||||
    qemu_irq *pic;
 | 
					    qemu_irq *pic;
 | 
				
			||||||
    void *scsi_hba;
 | 
					 | 
				
			||||||
    PCIBus *pci_bus;
 | 
					    PCIBus *pci_bus;
 | 
				
			||||||
    NICInfo *nd;
 | 
					    NICInfo *nd;
 | 
				
			||||||
    int n;
 | 
					    int n;
 | 
				
			||||||
@ -111,16 +110,10 @@ static void realview_init(ram_addr_t ram_size,
 | 
				
			|||||||
    if (usb_enabled) {
 | 
					    if (usb_enabled) {
 | 
				
			||||||
        usb_ohci_init_pci(pci_bus, 3, -1);
 | 
					        usb_ohci_init_pci(pci_bus, 3, -1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (drive_get_max_bus(IF_SCSI) > 0) {
 | 
					    n = drive_get_max_bus(IF_SCSI);
 | 
				
			||||||
        fprintf(stderr, "qemu: too many SCSI bus\n");
 | 
					    while (n >= 0) {
 | 
				
			||||||
        exit(1);
 | 
					        pci_create_simple(pci_bus, -1, "lsi53c895a");
 | 
				
			||||||
    }
 | 
					        n--;
 | 
				
			||||||
    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);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for(n = 0; n < nb_nics; n++) {
 | 
					    for(n = 0; n < nb_nics; n++) {
 | 
				
			||||||
        nd = &nd_table[n];
 | 
					        nd = &nd_table[n];
 | 
				
			||||||
 | 
				
			|||||||
@ -163,7 +163,6 @@ static void versatile_init(ram_addr_t ram_size,
 | 
				
			|||||||
    ram_addr_t ram_offset;
 | 
					    ram_addr_t ram_offset;
 | 
				
			||||||
    qemu_irq *pic;
 | 
					    qemu_irq *pic;
 | 
				
			||||||
    qemu_irq *sic;
 | 
					    qemu_irq *sic;
 | 
				
			||||||
    void *scsi_hba;
 | 
					 | 
				
			||||||
    PCIBus *pci_bus;
 | 
					    PCIBus *pci_bus;
 | 
				
			||||||
    NICInfo *nd;
 | 
					    NICInfo *nd;
 | 
				
			||||||
    int n;
 | 
					    int n;
 | 
				
			||||||
@ -206,16 +205,10 @@ static void versatile_init(ram_addr_t ram_size,
 | 
				
			|||||||
    if (usb_enabled) {
 | 
					    if (usb_enabled) {
 | 
				
			||||||
        usb_ohci_init_pci(pci_bus, 3, -1);
 | 
					        usb_ohci_init_pci(pci_bus, 3, -1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (drive_get_max_bus(IF_SCSI) > 0) {
 | 
					    n = drive_get_max_bus(IF_SCSI);
 | 
				
			||||||
        fprintf(stderr, "qemu: too many SCSI bus\n");
 | 
					    while (n >= 0) {
 | 
				
			||||||
        exit(1);
 | 
					        pci_create_simple(pci_bus, -1, "lsi53c895a");
 | 
				
			||||||
    }
 | 
					        n--;
 | 
				
			||||||
    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);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sysbus_create_simple("pl011", 0x101f1000, pic[12]);
 | 
					    sysbus_create_simple("pl011", 0x101f1000, pic[12]);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user