[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 47/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in do_d
From: |
Mark Cave-Ayland |
Subject: |
[PULL 47/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in do_dma_pdma_cb() |
Date: |
Tue, 13 Feb 2024 19:40:11 +0000 |
This makes it clearer that ATN is asserted until the end of the next TI command
in the MESSAGE OUT phase.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Helge Deller <deller@gmx.de>
Tested-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20240112125420.514425-48-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 66 ++++++++++++++++++++++++++++++++-------------------
1 file changed, 42 insertions(+), 24 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 2f54fd1285..7ab195f884 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -536,36 +536,30 @@ static void do_dma_pdma_cb(ESPState *s)
{
uint8_t buf[ESP_CMDFIFO_SZ];
int len;
- uint32_t n;
+ uint32_t n, cmdlen;
+
+ len = esp_get_tc(s);
switch (esp_get_phase(s)) {
case STAT_MO:
- case STAT_CD:
- /* Copy FIFO into cmdfifo */
- n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo));
- n = MIN(fifo8_num_free(&s->cmdfifo), n);
- fifo8_push_all(&s->cmdfifo, buf, n);
-
- /* Ensure we have received complete command after SATN and stop */
- if (esp_get_tc(s) || fifo8_is_empty(&s->cmdfifo)) {
- return;
+ if (s->dma_memory_read) {
+ len = MIN(len, fifo8_num_free(&s->cmdfifo));
+ s->dma_memory_read(s->dma_opaque, buf, len);
+ fifo8_push_all(&s->cmdfifo, buf, len);
+ esp_set_tc(s, esp_get_tc(s) - len);
+ s->cmdfifo_cdb_offset += len;
+ } else {
+ n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo));
+ n = MIN(fifo8_num_free(&s->cmdfifo), n);
+ fifo8_push_all(&s->cmdfifo, buf, n);
+ s->cmdfifo_cdb_offset += n;
}
- s->ti_size = 0;
- if (esp_get_phase(s) == STAT_CD) {
- /* No command received */
- if (s->cmdfifo_cdb_offset == fifo8_num_used(&s->cmdfifo)) {
- return;
- }
+ esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
+ esp_raise_drq(s);
- /* Command has been received */
- do_cmd(s);
- } else {
- /*
- * Extra message out bytes received: update cmdfifo_cdb_offset
- * and then switch to command phase
- */
- s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
+ /* ATN remains asserted until TC == 0 */
+ if (esp_get_tc(s) == 0) {
esp_set_phase(s, STAT_CD);
s->rregs[ESP_RSEQ] = SEQ_CD;
s->rregs[ESP_RINTR] |= INTR_BS;
@@ -573,6 +567,30 @@ static void do_dma_pdma_cb(ESPState *s)
}
break;
+ case STAT_CD:
+ cmdlen = fifo8_num_used(&s->cmdfifo);
+ trace_esp_do_dma(cmdlen, len);
+ if (s->dma_memory_read) {
+ len = MIN(len, fifo8_num_free(&s->cmdfifo));
+ s->dma_memory_read(s->dma_opaque, buf, len);
+ fifo8_push_all(&s->cmdfifo, buf, len);
+ esp_set_tc(s, esp_get_tc(s) - len);
+ } else {
+ n = esp_fifo_pop_buf(&s->fifo, buf, fifo8_num_used(&s->fifo));
+ n = MIN(fifo8_num_free(&s->cmdfifo), n);
+ fifo8_push_all(&s->cmdfifo, buf, n);
+
+ esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
+ esp_raise_drq(s);
+ }
+ trace_esp_handle_ti_cmd(cmdlen);
+ s->ti_size = 0;
+ if (esp_get_tc(s) == 0) {
+ /* Command has been received */
+ do_cmd(s);
+ }
+ break;
+
case STAT_DO:
if (!s->current_req) {
return;
--
2.39.2
- [PULL 38/88] esp.c: convert esp_do_dma() to switch statement based upon SCSI phase, (continued)
- [PULL 38/88] esp.c: convert esp_do_dma() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/02/13
- [PULL 37/88] esp.c: introduce esp_get_phase() function, Mark Cave-Ayland, 2024/02/13
- [PULL 41/88] esp.c: convert esp_do_dma() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/02/13
- [PULL 43/88] esp.c: convert esp_do_nodma() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/02/13
- [PULL 44/88] esp.c: convert esp_reg_write() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/02/13
- [PULL 48/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_nodma(), Mark Cave-Ayland, 2024/02/13
- [PULL 45/88] esp.c: remove do_cmd from ESPState, Mark Cave-Ayland, 2024/02/13
- [PULL 42/88] esp.c: convert do_dma_pdma_cb() do_cmd path to check for SCSI phase instead, Mark Cave-Ayland, 2024/02/13
- [PULL 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb(), Mark Cave-Ayland, 2024/02/13
- [PULL 46/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in esp_do_dma(), Mark Cave-Ayland, 2024/02/13
- [PULL 47/88] esp.c: untangle MESSAGE OUT and COMMAND phase logic in do_dma_pdma_cb(),
Mark Cave-Ayland <=
- [PULL 69/88] esp.c: consolidate end of command sequence after ICCS command, Mark Cave-Ayland, 2024/02/13
- [PULL 70/88] esp.c: ensure that STAT_INT is cleared when reading ESP_RINTR, Mark Cave-Ayland, 2024/02/13
- [PULL 81/88] esp.c: remove redundant n variable in PDMA COMMAND phase, Mark Cave-Ayland, 2024/02/13
- [PULL 78/88] esp.c: consolidate DMA and PDMA logic in DATA OUT phase, Mark Cave-Ayland, 2024/02/13
- [PULL 64/88] esp.c: don't raise INTR_BS interrupt in DATA IN phase until TI command issued, Mark Cave-Ayland, 2024/02/13
- [PULL 51/88] esp.c: don't use get_cmd() for CMD_SEL DMA commands, Mark Cave-Ayland, 2024/02/13
- [PULL 57/88] esp.c: rename data_in_ready to to data_ready, Mark Cave-Ayland, 2024/02/13
- [PULL 79/88] esp.c: consolidate DMA and PDMA logic in DATA IN phase, Mark Cave-Ayland, 2024/02/13
- [PULL 71/88] esp.c: don't clear the SCSI phase when reading ESP_RINTR, Mark Cave-Ayland, 2024/02/13
- [PULL 65/88] esp.c: move non-DMA TI logic to separate esp_nodma_ti_dataout() function, Mark Cave-Ayland, 2024/02/13