[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/25] esp: introduce esp_pdma_read() and esp_pdma_write() functi
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 12/25] esp: introduce esp_pdma_read() and esp_pdma_write() functions |
Date: |
Wed, 30 Dec 2020 15:37:32 +0000 |
Signed-off-by: Mark Cave-Ayland <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 39c5eeb57c..80f7f73002 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;
@@ -879,7 +893,6 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr,
SysBusESPState *sysbus = opaque;
ESPState *s = &sysbus->esp;
uint32_t dmalen = esp_get_tc(s);
- uint8_t *buf = get_pdma_buf(s);
trace_esp_pdma_write(size);
@@ -888,13 +901,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;
@@ -913,7 +926,6 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr
addr,
SysBusESPState *sysbus = opaque;
ESPState *s = &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);
@@ -923,13 +935,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
- [PATCH 01/25] esp: checkpatch fixes, (continued)
- [PATCH 01/25] esp: checkpatch fixes, Mark Cave-Ayland, 2020/12/30
- [PATCH 03/25] esp: fix esp_reg_read() trace event, Mark Cave-Ayland, 2020/12/30
- [PATCH 04/25] esp: add PDMA trace events, Mark Cave-Ayland, 2020/12/30
- [PATCH 07/25] esp: introduce esp_get_stc(), Mark Cave-Ayland, 2020/12/30
- [PATCH 05/25] esp: determine transfer direction directly from SCSI phase, Mark Cave-Ayland, 2020/12/30
- [PATCH 06/25] esp: introduce esp_get_tc() and esp_set_tc(), Mark Cave-Ayland, 2020/12/30
- [PATCH 08/25] esp: apply transfer length adjustment when STC is zero at TC load time, Mark Cave-Ayland, 2020/12/30
- [PATCH 09/25] esp: remove dma_counter from ESPState, Mark Cave-Ayland, 2020/12/30
- [PATCH 10/25] esp: remove dma_left from ESPState, Mark Cave-Ayland, 2020/12/30
- [PATCH 11/25] esp: remove minlen restriction in handle_ti, Mark Cave-Ayland, 2020/12/30
- [PATCH 12/25] esp: introduce esp_pdma_read() and esp_pdma_write() functions,
Mark Cave-Ayland <=
- [PATCH 14/25] esp: move pdma_len and TC logic into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2020/12/30
- [PATCH 13/25] esp: use pdma_origin directly in esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2020/12/30
- [PATCH 16/25] esp: remove redundant pdma_start from ESPState, Mark Cave-Ayland, 2020/12/30
- [PATCH 15/25] esp: accumulate SCSI commands for PDMA transfers in cmdbuf instead of pdma_buf, Mark Cave-Ayland, 2020/12/30
- [PATCH 17/25] esp: move PDMA length adjustments into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2020/12/30
- [PATCH 18/25] esp: use ti_wptr/ti_rptr to manage the current FIFO position for PDMA, Mark Cave-Ayland, 2020/12/30
- [PATCH 19/25] esp: use in-built TC to determine PDMA transfer length, Mark Cave-Ayland, 2020/12/30
- [PATCH 20/25] esp: remove CMD pdma_origin, Mark Cave-Ayland, 2020/12/30
- [PATCH 21/25] esp: rename get_cmd_cb() to esp_select(), Mark Cave-Ayland, 2020/12/30
- [PATCH 22/25] esp: fix PDMA target selection, Mark Cave-Ayland, 2020/12/30