summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Cave-Ayland2021-03-04 23:10:36 +0100
committerMark Cave-Ayland2021-03-07 11:39:05 +0100
commit761bef75dd0bcad72e6041172f9bb573c9237ee4 (patch)
tree1b3306bc0d4bd12efb11b0f5e61c658101b2cbe0
parentesp: remove minlen restriction in handle_ti (diff)
downloadqemu-761bef75dd0bcad72e6041172f9bb573c9237ee4.tar.gz
qemu-761bef75dd0bcad72e6041172f9bb573c9237ee4.tar.xz
qemu-761bef75dd0bcad72e6041172f9bb573c9237ee4.zip
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>
-rw-r--r--hw/scsi/esp.c28
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;