diff options
author | blueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-03-02 08:48:47 +0000 |
---|---|---|
committer | blueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162> | 2008-03-02 08:48:47 +0000 |
commit | 8b17de88e0dbe05a4ed2b6b7c9f402857a584930 (patch) | |
tree | cd5de4e95aba04f0c5efba3a68fb1ac559902ef6 /hw | |
parent | e1ffb0f18f01dfedbff344bfeaf85ef9bd2084c4 (diff) |
Let ESP SCSI adapter to be usable outside sun4m (Herv�oussineau)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4007 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r-- | hw/esp.c | 21 | ||||
-rw-r--r-- | hw/scsi.h | 8 | ||||
-rw-r--r-- | hw/sun4m.c | 16 | ||||
-rw-r--r-- | hw/sun4m.h | 6 |
4 files changed, 31 insertions, 20 deletions
@@ -24,9 +24,7 @@ #include "hw.h" #include "block.h" #include "scsi-disk.h" -#include "sun4m.h" -/* FIXME: Only needed for MAX_DISKS, which is probably wrong. */ -#include "sysemu.h" +#include "scsi.h" /* debug ESP card */ //#define DEBUG_ESP @@ -75,6 +73,9 @@ struct ESPState { uint32_t dma_counter; uint8_t *async_buf; uint32_t async_len; + + espdma_memory_read_write dma_memory_read; + espdma_memory_read_write dma_memory_write; void *dma_opaque; }; @@ -152,7 +153,7 @@ static int get_cmd(ESPState *s, uint8_t *buf) target = s->wregs[ESP_WBUSID] & 7; DPRINTF("get_cmd: len %d target %d\n", dmalen, target); if (s->dma) { - espdma_memory_read(s->dma_opaque, buf, dmalen); + s->dma_memory_read(s->dma_opaque, buf, dmalen); } else { buf[0] = 0; memcpy(&buf[1], s->ti_buf, dmalen); @@ -236,7 +237,7 @@ static void write_response(ESPState *s) s->ti_buf[0] = s->sense; s->ti_buf[1] = 0; if (s->dma) { - espdma_memory_write(s->dma_opaque, s->ti_buf, 2); + s->dma_memory_write(s->dma_opaque, s->ti_buf, 2); s->rregs[ESP_RSTAT] = STAT_IN | STAT_TC | STAT_ST; s->rregs[ESP_RINTR] = INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] = SEQ_CD; @@ -269,7 +270,7 @@ static void esp_do_dma(ESPState *s) len = s->dma_left; if (s->do_cmd) { DPRINTF("command len %d + %d\n", s->cmdlen, len); - espdma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); + s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); s->ti_size = 0; s->cmdlen = 0; s->do_cmd = 0; @@ -284,9 +285,9 @@ static void esp_do_dma(ESPState *s) len = s->async_len; } if (to_device) { - espdma_memory_read(s->dma_opaque, s->async_buf, len); + s->dma_memory_read(s->dma_opaque, s->async_buf, len); } else { - espdma_memory_write(s->dma_opaque, s->async_buf, len); + s->dma_memory_write(s->dma_opaque, s->async_buf, len); } s->dma_left -= len; s->async_buf += len; @@ -621,6 +622,8 @@ void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id) } void *esp_init(target_phys_addr_t espaddr, + espdma_memory_read_write dma_memory_read, + espdma_memory_read_write dma_memory_write, void *dma_opaque, qemu_irq irq, qemu_irq *reset) { ESPState *s; @@ -631,6 +634,8 @@ void *esp_init(target_phys_addr_t espaddr, return NULL; s->irq = irq; + s->dma_memory_read = dma_memory_read; + s->dma_memory_write = dma_memory_write; s->dma_opaque = dma_opaque; esp_io_memory = cpu_register_io_memory(0, esp_mem_read, esp_mem_write, s); diff --git a/hw/scsi.h b/hw/scsi.h new file mode 100644 index 0000000000..a90927fc1e --- /dev/null +++ b/hw/scsi.h @@ -0,0 +1,8 @@ +/* esp.c */ +#define ESP_MAX_DEVS 7 +typedef void (*espdma_memory_read_write)(void *opaque, uint8_t *buf, int len); +void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id); +void *esp_init(target_phys_addr_t espaddr, + espdma_memory_read_write dma_memory_read, + espdma_memory_read_write dma_memory_write, + void *dma_opaque, qemu_irq irq, qemu_irq *reset); diff --git a/hw/sun4m.c b/hw/sun4m.c index e4717c485c..79130c13da 100644 --- a/hw/sun4m.c +++ b/hw/sun4m.c @@ -31,6 +31,7 @@ #include "net.h" #include "boards.h" #include "firmware_abi.h" +#include "scsi.h" //#define DEBUG_IRQ @@ -505,8 +506,9 @@ static void sun4m_hw_init(const struct hwdef *hwdef, int RAM_size, exit(1); } - main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, - esp_reset); + main_esp = esp_init(hwdef->esp_base, + espdma_memory_read, espdma_memory_write, + espdma, *espdma_irq, esp_reset); for (i = 0; i < ESP_MAX_DEVS; i++) { index = drive_get_index(IF_SCSI, 0, i); @@ -653,8 +655,9 @@ static void sun4c_hw_init(const struct hwdef *hwdef, int RAM_size, exit(1); } - main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, - esp_reset); + main_esp = esp_init(hwdef->esp_base, + espdma_memory_read, espdma_memory_write, + espdma, *espdma_irq, esp_reset); for (i = 0; i < ESP_MAX_DEVS; i++) { index = drive_get_index(IF_SCSI, 0, i); @@ -1158,8 +1161,9 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, int RAM_size, exit(1); } - main_esp = esp_init(hwdef->esp_base, espdma, *espdma_irq, - esp_reset); + main_esp = esp_init(hwdef->esp_base, + espdma_memory_read, espdma_memory_write, + espdma, *espdma_irq, esp_reset); for (i = 0; i < ESP_MAX_DEVS; i++) { index = drive_get_index(IF_SCSI, 0, i); diff --git a/hw/sun4m.h b/hw/sun4m.h index 484e3e860e..bf2eca31e2 100644 --- a/hw/sun4m.h +++ b/hw/sun4m.h @@ -59,12 +59,6 @@ void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base, CPUState *env); void slavio_set_power_fail(void *opaque, int power_failing); -/* esp.c */ -#define ESP_MAX_DEVS 7 -void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id); -void *esp_init(target_phys_addr_t espaddr, - void *dma_opaque, qemu_irq irq, qemu_irq *reset); - /* cs4231.c */ void cs_init(target_phys_addr_t base, int irq, void *intctl); |