[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/25] esp: introduce esp_get_tc() and esp_set_tc()
From: |
Mark Cave-Ayland |
Subject: |
[PATCH 06/25] esp: introduce esp_get_tc() and esp_set_tc() |
Date: |
Wed, 30 Dec 2020 15:37:26 +0000 |
This simplifies reading and writing the TC register value without having to
manually shift each individual 8-bit value.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 7169294437..42cbc1da9b 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -98,6 +98,24 @@ void esp_request_cancelled(SCSIRequest *req)
}
}
+static uint32_t esp_get_tc(ESPState *s)
+{
+ uint32_t dmalen;
+
+ dmalen = s->rregs[ESP_TCLO];
+ dmalen |= s->rregs[ESP_TCMID] << 8;
+ dmalen |= s->rregs[ESP_TCHI] << 16;
+
+ return dmalen;
+}
+
+static void esp_set_tc(ESPState *s, uint32_t dmalen)
+{
+ s->rregs[ESP_TCLO] = dmalen & 0xff;
+ s->rregs[ESP_TCMID] = dmalen >> 8;
+ s->rregs[ESP_TCHI] = dmalen >> 16;
+}
+
static void set_pdma(ESPState *s, enum pdma_origin_id origin,
uint32_t index, uint32_t len)
{
@@ -157,9 +175,7 @@ static uint32_t get_cmd(ESPState *s, uint8_t *buf, uint8_t
buflen)
target = s->wregs[ESP_WBUSID] & BUSID_DID;
if (s->dma) {
- dmalen = s->rregs[ESP_TCLO];
- dmalen |= s->rregs[ESP_TCMID] << 8;
- dmalen |= s->rregs[ESP_TCHI] << 16;
+ dmalen = esp_get_tc(s);
if (dmalen > buflen) {
return 0;
}
@@ -536,9 +552,7 @@ static void handle_ti(ESPState *s)
return;
}
- dmalen = s->rregs[ESP_TCLO];
- dmalen |= s->rregs[ESP_TCMID] << 8;
- dmalen |= s->rregs[ESP_TCHI] << 16;
+ dmalen = esp_get_tc(s);
if (dmalen == 0) {
dmalen = 0x10000;
}
@@ -869,9 +883,7 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr,
trace_esp_pdma_write(size);
- dmalen = s->rregs[ESP_TCLO];
- dmalen |= s->rregs[ESP_TCMID] << 8;
- dmalen |= s->rregs[ESP_TCHI] << 16;
+ dmalen = esp_get_tc(s);
if (dmalen == 0 || s->pdma_len == 0) {
return;
}
@@ -888,9 +900,7 @@ static void sysbus_esp_pdma_write(void *opaque, hwaddr addr,
dmalen -= 2;
break;
}
- s->rregs[ESP_TCLO] = dmalen & 0xff;
- s->rregs[ESP_TCMID] = dmalen >> 8;
- s->rregs[ESP_TCHI] = dmalen >> 16;
+ esp_set_tc(s, dmalen);
if (s->pdma_len == 0 && s->pdma_cb) {
esp_lower_drq(s);
s->pdma_cb(s);
--
2.20.1
- [PATCH 00/25] esp: consolidate PDMA transfer buffers, Mark Cave-Ayland, 2020/12/30
- [PATCH 02/25] esp: add trace event when receiving a TI command, Mark Cave-Ayland, 2020/12/30
- [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 <=
- [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, 2020/12/30
- [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