diff options
author | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2024-01-12 12:53:32 +0000 |
---|---|---|
committer | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2024-02-13 19:37:28 +0000 |
commit | 9d1aa52b761bc9e38d19009ada723bd4f734cd90 (patch) | |
tree | 75ed43a80bd8fe0c98ecb1aab16f8cce0aa21434 /hw | |
parent | 844b3a84eaa3ae92e5c178cd985506f94756ad86 (diff) | |
download | qemu-9d1aa52b761bc9e38d19009ada723bd4f734cd90.zip qemu-9d1aa52b761bc9e38d19009ada723bd4f734cd90.tar.gz qemu-9d1aa52b761bc9e38d19009ada723bd4f734cd90.tar.bz2 |
esp.c: convert esp_do_nodma() 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-41-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 | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f6d05b0..c1b44e5 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -786,7 +786,6 @@ static void esp_do_dma(ESPState *s) static void esp_do_nodma(ESPState *s) { - int to_device = (esp_get_phase(s) == STAT_DO); uint8_t buf[ESP_FIFO_SZ]; uint32_t cmdlen; int len, n; @@ -823,38 +822,55 @@ static void esp_do_nodma(ESPState *s) return; } - if (!s->current_req) { - return; - } - - if (s->async_len == 0) { - /* Defer until data is available. */ - return; - } - - if (to_device) { + switch (esp_get_phase(s)) { + case STAT_DO: + if (!s->current_req) { + return; + } + if (s->async_len == 0) { + /* Defer until data is available. */ + return; + } len = MIN(s->async_len, ESP_FIFO_SZ); len = MIN(len, fifo8_num_used(&s->fifo)); esp_fifo_pop_buf(&s->fifo, s->async_buf, len); s->async_buf += len; s->async_len -= len; s->ti_size += len; - } else { + + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + return; + } + + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + + case STAT_DI: + if (!s->current_req) { + return; + } + if (s->async_len == 0) { + /* Defer until data is available. */ + return; + } if (fifo8_is_empty(&s->fifo)) { fifo8_push(&s->fifo, s->async_buf[0]); s->async_buf++; s->async_len--; s->ti_size--; } - } - if (s->async_len == 0) { - scsi_req_continue(s->current_req); - return; - } + if (s->async_len == 0) { + scsi_req_continue(s->current_req); + return; + } - s->rregs[ESP_RINTR] |= INTR_BS; - esp_raise_irq(s); + s->rregs[ESP_RINTR] |= INTR_BS; + esp_raise_irq(s); + break; + } } static void esp_pdma_cb(ESPState *s) |