diff options
author | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2024-01-12 12:53:30 +0000 |
---|---|---|
committer | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2024-02-13 19:37:28 +0000 |
commit | 1454dc765bc943b68ae3f4b0fce84ff202ea8de6 (patch) | |
tree | c3e8447a946082367780169ff7d71ff1d2147451 /hw | |
parent | 5a83e83e1cc64bba2f67cba999552443744767bc (diff) | |
download | qemu-1454dc765bc943b68ae3f4b0fce84ff202ea8de6.zip qemu-1454dc765bc943b68ae3f4b0fce84ff202ea8de6.tar.gz qemu-1454dc765bc943b68ae3f4b0fce84ff202ea8de6.tar.bz2 |
esp.c: convert esp_do_dma() to switch statement based upon SCSI phase
Currently only the DATA IN and DATA OUT phases are supported.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Helge Deller <deller@gmx.de>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20240112125420.514425-39-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/scsi/esp.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index de8d980..67d1d39 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -626,7 +626,6 @@ static void do_dma_pdma_cb(ESPState *s) static void esp_do_dma(ESPState *s) { uint32_t len, cmdlen; - int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_CMDFIFO_SZ]; int n; @@ -681,17 +680,19 @@ static void esp_do_dma(ESPState *s) } return; } - if (!s->current_req) { - return; - } - if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { - /* Defer until data is available. */ - return; - } - if (len > s->async_len) { - len = s->async_len; - } - if (to_device) { + + switch (esp_get_phase(s)) { + case STAT_DO: + if (!s->current_req) { + return; + } + if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { + /* Defer until data is available. */ + return; + } + if (len > s->async_len) { + len = s->async_len; + } if (s->dma_memory_read) { s->dma_memory_read(s->dma_opaque, s->async_buf, len); @@ -727,7 +728,19 @@ static void esp_do_dma(ESPState *s) esp_dma_ti_check(s); } - } else { + break; + + case STAT_DI: + if (!s->current_req) { + return; + } + if (s->async_len == 0 && esp_get_tc(s) && s->ti_size) { + /* Defer until data is available. */ + return; + } + if (len > s->async_len) { + len = s->async_len; + } if (s->dma_memory_write) { s->dma_memory_write(s->dma_opaque, s->async_buf, len); @@ -762,6 +775,7 @@ static void esp_do_dma(ESPState *s) esp_dma_ti_check(s); } + break; } } |