[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/42] esp: introduce esp_pdma_read() and esp_pdma_write() functio
From: |
Mark Cave-Ayland |
Subject: |
[PULL 15/42] esp: introduce esp_pdma_read() and esp_pdma_write() functions |
Date: |
Sun, 7 Mar 2021 12:08:23 +0000 |
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>
---
hw/scsi/esp.c | 28 ++++++++++++++++++++--------
1 file 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;
--
2.20.1
- [PULL 05/42] esp: add trace event when receiving a TI command, (continued)
- [PULL 05/42] esp: add trace event when receiving a TI command, Mark Cave-Ayland, 2021/03/07
- [PULL 06/42] esp: fix esp_reg_read() trace event, Mark Cave-Ayland, 2021/03/07
- [PULL 07/42] esp: add PDMA trace events, Mark Cave-Ayland, 2021/03/07
- [PULL 08/42] esp: determine transfer direction directly from SCSI phase, Mark Cave-Ayland, 2021/03/07
- [PULL 09/42] esp: introduce esp_get_tc() and esp_set_tc(), Mark Cave-Ayland, 2021/03/07
- [PULL 10/42] esp: introduce esp_get_stc(), Mark Cave-Ayland, 2021/03/07
- [PULL 11/42] esp: apply transfer length adjustment when STC is zero at TC load time, Mark Cave-Ayland, 2021/03/07
- [PULL 12/42] esp: remove dma_counter from ESPState, Mark Cave-Ayland, 2021/03/07
- [PULL 13/42] esp: remove dma_left from ESPState, Mark Cave-Ayland, 2021/03/07
- [PULL 14/42] esp: remove minlen restriction in handle_ti, Mark Cave-Ayland, 2021/03/07
- [PULL 15/42] esp: introduce esp_pdma_read() and esp_pdma_write() functions,
Mark Cave-Ayland <=
- [PULL 16/42] esp: use pdma_origin directly in esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/07
- [PULL 17/42] esp: move pdma_len and TC logic into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/07
- [PULL 18/42] esp: accumulate SCSI commands for PDMA transfers in cmdbuf instead of pdma_buf, Mark Cave-Ayland, 2021/03/07
- [PULL 19/42] esp: remove buf parameter from do_cmd(), Mark Cave-Ayland, 2021/03/07
- [PULL 20/42] esp: remove the buf and buflen parameters from get_cmd(), Mark Cave-Ayland, 2021/03/07
- [PULL 21/42] esp: remove redundant pdma_start from ESPState, Mark Cave-Ayland, 2021/03/07
- [PULL 22/42] esp: move PDMA length adjustments into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/07
- [PULL 23/42] esp: use ti_wptr/ti_rptr to manage the current FIFO position for PDMA, Mark Cave-Ayland, 2021/03/07
- [PULL 24/42] esp: use in-built TC to determine PDMA transfer length, Mark Cave-Ayland, 2021/03/07
- [PULL 25/42] esp: remove CMD pdma_origin, Mark Cave-Ayland, 2021/03/07