From fa1fb14cd2f4f24e158b1bb284bd193e79899575 Mon Sep 17 00:00:00 2001 From: ths Date: Sun, 24 Dec 2006 17:12:43 +0000 Subject: Fix SCSI cdrom boot, thanks Blue Swirl. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2278 c046a42c-6fe2-441c-8c8c-71466251a162 --- hw/esp.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'hw/esp.c') 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; } -- cgit v1.2.3