diff options
author | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-12-24 17:12:43 +0000 |
---|---|---|
committer | ths <ths@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-12-24 17:12:43 +0000 |
commit | fa1fb14cd2f4f24e158b1bb284bd193e79899575 (patch) | |
tree | 8a38b3800d1f3a13153ef0f1b4b08761d82039b3 | |
parent | 1f9584496747480020bb93ee1582d104f877ce0a (diff) | |
download | hqemu-fa1fb14cd2f4f24e158b1bb284bd193e79899575.zip hqemu-fa1fb14cd2f4f24e158b1bb284bd193e79899575.tar.gz |
Fix SCSI cdrom boot, thanks Blue Swirl.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2278 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r-- | hw/esp.c | 33 | ||||
-rw-r--r-- | hw/sun4m.c | 6 | ||||
-rw-r--r-- | vl.c | 31 | ||||
-rw-r--r-- | vl.h | 4 |
4 files changed, 65 insertions, 9 deletions
@@ -43,6 +43,8 @@ do { printf("ESP: " fmt , ##args); } while (0) #define ESP_MAXREG 0x3f #define TI_BUFSZ 32 +/* The HBA is ID 7, so for simplicitly limit to 7 devices. */ +#define ESP_MAX_DEVS 7 typedef struct ESPState ESPState; @@ -526,11 +528,33 @@ static int esp_load(QEMUFile *f, void *opaque, int version_id) return 0; } +void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id) +{ + ESPState *s = (ESPState *)opaque; + + if (id < 0) { + for (id = 0; id < ESP_MAX_DEVS; id++) { + if (s->scsi_dev[id] == NULL) + break; + } + } + if (id >= ESP_MAX_DEVS) { + DPRINTF("Bad Device ID %d\n", id); + return; + } + if (s->scsi_dev[id]) { + DPRINTF("Destroying device %d\n", id); + scsi_disk_destroy(s->scsi_dev[id]); + } + DPRINTF("Attaching block device %d\n", id); + /* Command queueing is not implemented. */ + s->scsi_dev[id] = scsi_disk_init(bd, 0, esp_command_complete, s); +} + void *esp_init(BlockDriverState **bd, uint32_t espaddr, void *dma_opaque) { ESPState *s; int esp_io_memory; - int i; s = qemu_mallocz(sizeof(ESPState)); if (!s) @@ -546,13 +570,6 @@ void *esp_init(BlockDriverState **bd, uint32_t espaddr, void *dma_opaque) register_savevm("esp", espaddr, 2, esp_save, esp_load, s); qemu_register_reset(esp_reset, s); - for (i = 0; i < MAX_DISKS; i++) { - if (bs_table[i]) { - /* Command queueing is not implemented. */ - s->scsi_dev[i] = - scsi_disk_init(bs_table[i], 0, esp_command_complete, s); - } - } return s; } @@ -262,6 +262,12 @@ static void sun4m_init(int ram_size, int vga_ram_size, int boot_device, slavio_serial_init(PHYS_JJ_SER, PHYS_JJ_SER_IRQ, serial_hds[1], serial_hds[0]); fdctrl_init(PHYS_JJ_FLOPPY_IRQ, 0, 1, PHYS_JJ_FDC, fd_table); main_esp = esp_init(bs_table, PHYS_JJ_ESP, dma); + for (i = 0; i < MAX_SCSI_DISKS; i++) { + if (scsi_disks_info[i].adapter == SCSI_ESP && + scsi_disks_info[i].device_type != SCSI_NONE) { + esp_scsi_attach(main_esp, bs_scsi_table[i], scsi_disks_info[i].id); + } + } slavio_misc = slavio_misc_init(PHYS_JJ_SLAVIO, PHYS_JJ_ME_IRQ); cs_init(PHYS_JJ_CS, PHYS_JJ_CS_IRQ, slavio_intctl); sparc32_dma_set_reset_data(dma, main_esp, main_lance); @@ -3925,8 +3925,12 @@ static int disk_options_init(int num_ide_disks, for(i = 0; i < num_scsi_disks; i++) { +#if !defined(TARGET_SPARC) || defined(TARGET_SPARC64) temp_adapter = SCSI_LSI_53C895A; scsi_hba_lsi++; +#else + temp_adapter = SCSI_ESP; +#endif /*Check for sdx= parameter */ if (get_param_value(buf, sizeof(buf), "sdx", scsi_disk_options[i])) { @@ -3999,6 +4003,9 @@ static int disk_options_init(int num_ide_disks, fprintf(stderr, "qemu: SCSI disk image not specified for sd%c \n", i + 'a'); return -1; } + if (cdrom_device) { + bdrv_set_type_hint(bs_scsi_table[scsi_index], BDRV_TYPE_CDROM); + } } return 0; @@ -6887,6 +6894,8 @@ int main(int argc, char **argv) kernel_cmdline = optarg; break; case QEMU_OPTION_cdrom: +#if !defined(TARGET_SPARC) || defined(TARGET_SPARC64) + /* Assume boot cdrom is IDE */ { char buf[22]; if (num_ide_disks >= MAX_DISKS) { @@ -6904,6 +6913,27 @@ int main(int argc, char **argv) optarg); num_ide_disks++; } +#else + /* Assume boot cdrom is SCSI */ + { + char buf[27]; + if (num_scsi_disks >= MAX_SCSI_DISKS) { + fprintf(stderr, "qemu: too many SCSI disks/cdroms defined.\n"); + exit(1); + } + snprintf(buf, sizeof(buf), "type=cdrom,sdx=%c,id=%d,img=", + num_scsi_disks + 'a', num_scsi_disks + 2); + /* Build new disk SCSI syntax string */ + pstrcpy(scsi_options[num_scsi_disks], + 27, + buf); + /* Add on image filename */ + pstrcpy(&(scsi_options[num_scsi_disks][26]), + sizeof(scsi_options[0])-26, + optarg); + num_scsi_disks++; + } +#endif break; case QEMU_OPTION_boot: boot_device = optarg[0]; @@ -7193,6 +7223,7 @@ int main(int argc, char **argv) if (!linux_boot && num_ide_disks == 0 && + num_scsi_disks == 0 && fd_filename[0] == '\0') help(); @@ -1093,6 +1093,7 @@ void *slavio_misc_init(uint32_t base, int irq); void slavio_set_power_fail(void *opaque, int power_failing); /* esp.c */ +void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id); void *esp_init(BlockDriverState **bd, uint32_t espaddr, void *dma_opaque); void esp_reset(void *opaque); @@ -1223,7 +1224,8 @@ void scsi_cancel_io(SCSIDevice *s, uint32_t tag); uint8_t *scsi_get_buf(SCSIDevice *s, uint32_t tag); enum scsi_host_adapters { - SCSI_LSI_53C895A + SCSI_LSI_53C895A, + SCSI_ESP }; enum scsi_devices { SCSI_CDROM, |