[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 10/42] esp: introduce esp_get_stc()
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v3 10/42] esp: introduce esp_get_stc() |
Date: |
Thu, 4 Mar 2021 22:10:31 +0000 |
This function simplifies reading the STC register value without having to
manually
shift each individual 8-bit value.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
hw/scsi/esp.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index dd94f7b47b..125bdea32a 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -116,6 +116,17 @@ static void esp_set_tc(ESPState *s, uint32_t dmalen)
s->rregs[ESP_TCHI] = dmalen >> 16;
}
+static uint32_t esp_get_stc(ESPState *s)
+{
+ uint32_t dmalen;
+
+ dmalen = s->wregs[ESP_TCLO];
+ dmalen |= s->wregs[ESP_TCMID] << 8;
+ dmalen |= s->wregs[ESP_TCHI] << 16;
+
+ return dmalen;
+}
+
static void set_pdma(ESPState *s, enum pdma_origin_id origin,
uint32_t index, uint32_t len)
{
@@ -687,9 +698,7 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t
val)
if (val & CMD_DMA) {
s->dma = 1;
/* Reload DMA counter. */
- s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO];
- s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID];
- s->rregs[ESP_TCHI] = s->wregs[ESP_TCHI];
+ esp_set_tc(s, esp_get_stc(s));
} else {
s->dma = 0;
}
--
2.20.1
- [PATCH v3 00/42] esp: consolidate PDMA transfer buffers and other fixes, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 01/42] esp: checkpatch fixes, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 02/42] esp: rename existing ESP QOM type to SYSBUS_ESP, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 03/42] esp: QOMify the internal ESP device state, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 04/42] esp: add vmstate_esp version to embedded ESPState, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 05/42] esp: add trace event when receiving a TI command, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 06/42] esp: fix esp_reg_read() trace event, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 07/42] esp: add PDMA trace events, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 08/42] esp: determine transfer direction directly from SCSI phase, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 09/42] esp: introduce esp_get_tc() and esp_set_tc(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 10/42] esp: introduce esp_get_stc(),
Mark Cave-Ayland <=
- [PATCH v3 11/42] esp: apply transfer length adjustment when STC is zero at TC load time, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 12/42] esp: remove dma_counter from ESPState, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 13/42] esp: remove dma_left from ESPState, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 14/42] esp: remove minlen restriction in handle_ti, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 15/42] esp: introduce esp_pdma_read() and esp_pdma_write() functions, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 16/42] esp: use pdma_origin directly in esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 17/42] esp: move pdma_len and TC logic into esp_pdma_read()/esp_pdma_write(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 18/42] esp: accumulate SCSI commands for PDMA transfers in cmdbuf instead of pdma_buf, Mark Cave-Ayland, 2021/03/04
- [PATCH v3 19/42] esp: remove buf parameter from do_cmd(), Mark Cave-Ayland, 2021/03/04
- [PATCH v3 20/42] esp: remove the buf and buflen parameters from get_cmd(), Mark Cave-Ayland, 2021/03/04