diff options
author | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2021-03-04 22:10:36 +0000 |
---|---|---|
committer | Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> | 2021-03-07 10:39:05 +0000 |
commit | 761bef75dd0bcad72e6041172f9bb573c9237ee4 (patch) | |
tree | 1b3306bc0d4bd12efb11b0f5e61c658101b2cbe0 /hw/scsi | |
parent | b76624de5062fdf874a377ade84af90c62903833 (diff) |
esp: introduce esp_pdma_read() and esp_pdma_write() functions
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210304221103.6369-16-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw/scsi')
-rw-r--r-- | hw/scsi/esp.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 07d57cb791..0fafc866a4 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -151,6 +151,20 @@ static uint8_t *get_pdma_buf(ESPState *s) return NULL; } +static uint8_t esp_pdma_read(ESPState *s) +{ + uint8_t *buf = get_pdma_buf(s); + + return buf[s->pdma_cur++]; +} + +static void esp_pdma_write(ESPState *s, uint8_t val) +{ + uint8_t *buf = get_pdma_buf(s); + + buf[s->pdma_cur++] = val; +} + static int get_cmd_cb(ESPState *s) { int target; @@ -909,7 +923,6 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr, SysBusESPState *sysbus = opaque; ESPState *s = ESP(&sysbus->esp); uint32_t dmalen = esp_get_tc(s); - uint8_t *buf = get_pdma_buf(s); trace_esp_pdma_write(size); @@ -918,13 +931,13 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr, } switch (size) { case 1: - buf[s->pdma_cur++] = val; + esp_pdma_write(s, val); s->pdma_len--; dmalen--; break; case 2: - buf[s->pdma_cur++] = val >> 8; - buf[s->pdma_cur++] = val; + esp_pdma_write(s, val >> 8); + esp_pdma_write(s, val); s->pdma_len -= 2; dmalen -= 2; break; @@ -943,7 +956,6 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr, SysBusESPState *sysbus = opaque; ESPState *s = ESP(&sysbus->esp); uint32_t dmalen = esp_get_tc(s); - uint8_t *buf = get_pdma_buf(s); uint64_t val = 0; trace_esp_pdma_read(size); @@ -953,13 +965,13 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr, } switch (size) { case 1: - val = buf[s->pdma_cur++]; + val = esp_pdma_read(s); s->pdma_len--; dmalen--; break; case 2: - val = buf[s->pdma_cur++]; - val = (val << 8) | buf[s->pdma_cur++]; + val = esp_pdma_read(s); + val = (val << 8) | esp_pdma_read(s); s->pdma_len -= 2; dmalen -= 2; break; |