diff options
author | Mark Cave-Ayland | 2021-03-04 23:10:43 +0100 |
---|---|---|
committer | Mark Cave-Ayland | 2021-03-07 11:39:05 +0100 |
commit | 93efe2e6243d0192ed0e383a3e3e91b0ce1d9063 (patch) | |
tree | 1cd180318829b3da7be654f0369fc4124f8712b4 /hw/scsi/esp.c | |
parent | esp: remove redundant pdma_start from ESPState (diff) | |
download | qemu-93efe2e6243d0192ed0e383a3e3e91b0ce1d9063.tar.gz qemu-93efe2e6243d0192ed0e383a3e3e91b0ce1d9063.tar.xz qemu-93efe2e6243d0192ed0e383a3e3e91b0ce1d9063.zip |
esp: move PDMA length adjustments into esp_pdma_read()/esp_pdma_write()
Here the updates to async_len and ti_size are moved into the corresponding
esp_pdma_read()/esp_pdma_write() function to eliminate the reference to
pdma_cur in do_dma_pdma_cb().
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210304221103.6369-23-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw/scsi/esp.c')
-rw-r--r-- | hw/scsi/esp.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 38c05e97c3..bb3a9cd5e3 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -153,12 +153,18 @@ static uint8_t esp_pdma_read(ESPState *s) s->pdma_cur++; break; case ASYNC: - val = s->async_buf[s->pdma_cur++]; + val = s->async_buf[0]; + if (s->async_len > 0) { + s->async_len--; + s->async_buf++; + } + s->pdma_cur++; break; default: g_assert_not_reached(); } + s->ti_size--; s->pdma_len--; dmalen--; esp_set_tc(s, dmalen); @@ -183,12 +189,18 @@ static void esp_pdma_write(ESPState *s, uint8_t val) s->pdma_cur++; break; case ASYNC: - s->async_buf[s->pdma_cur++] = val; + s->async_buf[0] = val; + if (s->async_len > 0) { + s->async_len--; + s->async_buf++; + } + s->pdma_cur++; break; default: g_assert_not_reached(); } + s->ti_size++; s->pdma_len--; dmalen--; esp_set_tc(s, dmalen); @@ -427,7 +439,6 @@ static void esp_dma_done(ESPState *s) static void do_dma_pdma_cb(ESPState *s) { int to_device = ((s->rregs[ESP_RSTAT] & 7) == STAT_DO); - int len = s->pdma_cur; if (s->do_cmd) { s->ti_size = 0; @@ -436,13 +447,6 @@ static void do_dma_pdma_cb(ESPState *s) do_cmd(s); return; } - s->async_buf += len; - s->async_len -= len; - if (to_device) { - s->ti_size += len; - } else { - s->ti_size -= len; - } if (s->async_len == 0) { scsi_req_continue(s->current_req); /* |