aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/esp.c33
-rw-r--r--hw/sun4m.c6
-rw-r--r--vl.c31
-rw-r--r--vl.h4
4 files changed, 65 insertions, 9 deletions
diff --git a/hw/esp.c b/hw/esp.c
index 4587502e2b..fea08d8783 100644
--- a/hw/esp.c
+++ b/hw/esp.c
@@ -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;
}
diff --git a/hw/sun4m.c b/hw/sun4m.c
index a636638b5f..c6765d9e17 100644
--- a/hw/sun4m.c
+++ b/hw/sun4m.c
@@ -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);
diff --git a/vl.c b/vl.c
index ed3109e21b..aea96387d6 100644
--- a/vl.c
+++ b/vl.c
@@ -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();
diff --git a/vl.h b/vl.h
index d3c56d4ce8..6d0e7a7694 100644
--- a/vl.h
+++ b/vl.h
@@ -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,