[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 49/88] esp.c: move CMD_SELATN end of message phase detection to es
From: |
Mark Cave-Ayland |
Subject: |
[PULL 49/88] esp.c: move CMD_SELATN end of message phase detection to esp_do_dma() and do_dma_pdma_cb() |
Date: |
Tue, 13 Feb 2024 19:40:13 +0000 |
The special logic in satn_pdma_cb() is now no longer required since esp_do_dma()
can be used as a direct replacement.
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-50-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 75 +++++++++++++++++++++++++------------------
include/hw/scsi/esp.h | 1 -
2 files changed, 43 insertions(+), 33 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 81144ace83..f8c20d0584 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -261,6 +261,9 @@ static int esp_select(ESPState *s)
return 0;
}
+static void esp_do_dma(ESPState *s);
+static void esp_do_nodma(ESPState *s);
+
static uint32_t get_cmd(ESPState *s, uint32_t maxlen)
{
uint8_t buf[ESP_CMDFIFO_SZ];
@@ -368,45 +371,26 @@ static void do_cmd(ESPState *s)
do_command_phase(s);
}
-static void satn_pdma_cb(ESPState *s)
-{
- uint8_t buf[ESP_FIFO_SZ];
- int n;
-
- /* 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);
-
- if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) {
- s->cmdfifo_cdb_offset = 1;
- do_cmd(s);
- }
-}
-
static void handle_satn(ESPState *s)
{
- int32_t cmdlen;
-
if (s->dma && !s->dma_enabled) {
s->dma_cb = handle_satn;
return;
}
- esp_set_pdma_cb(s, SATN_PDMA_CB);
+ esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
if (esp_select(s) < 0) {
return;
}
- cmdlen = get_cmd(s, ESP_CMDFIFO_SZ);
- if (cmdlen > 0) {
- s->cmdfifo_cdb_offset = 1;
- do_cmd(s);
- } else if (cmdlen == 0) {
- if (s->dma) {
- esp_raise_drq(s);
+
+ esp_set_phase(s, STAT_MO);
+
+ if (s->dma) {
+ esp_do_dma(s);
+ } else {
+ if (get_cmd(s, ESP_CMDFIFO_SZ)) {
+ s->cmdfifo_cdb_offset = 1;
+ do_cmd(s);
}
- /* Target present, but no cmd yet - switch to command phase */
- s->rregs[ESP_RSEQ] = SEQ_CD;
- esp_set_phase(s, STAT_CD);
}
}
@@ -558,6 +542,21 @@ static void do_dma_pdma_cb(ESPState *s)
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
+ switch (s->rregs[ESP_CMD]) {
+ case CMD_SELATN | CMD_DMA:
+ if (fifo8_num_used(&s->cmdfifo) >= 1) {
+ /* First byte received, switch to command phase */
+ esp_set_phase(s, STAT_CD);
+ s->cmdfifo_cdb_offset = 1;
+
+ if (fifo8_num_used(&s->cmdfifo) > 1) {
+ /* Process any additional command phase data */
+ esp_do_dma(s);
+ }
+ }
+ break;
+ }
+
/* ATN remains asserted until TC == 0 */
if (esp_get_tc(s) == 0) {
esp_set_phase(s, STAT_CD);
@@ -663,6 +662,21 @@ static void esp_do_dma(ESPState *s)
esp_set_pdma_cb(s, DO_DMA_PDMA_CB);
esp_raise_drq(s);
+ switch (s->rregs[ESP_CMD]) {
+ case CMD_SELATN | CMD_DMA:
+ if (fifo8_num_used(&s->cmdfifo) >= 1) {
+ /* First byte received, switch to command phase */
+ esp_set_phase(s, STAT_CD);
+ s->cmdfifo_cdb_offset = 1;
+
+ if (fifo8_num_used(&s->cmdfifo) > 1) {
+ /* Process any additional command phase data */
+ esp_do_dma(s);
+ }
+ }
+ break;
+ }
+
/* ATN remains asserted until TC == 0 */
if (esp_get_tc(s) == 0) {
esp_set_phase(s, STAT_CD);
@@ -890,9 +904,6 @@ static void esp_do_nodma(ESPState *s)
static void esp_pdma_cb(ESPState *s)
{
switch (s->pdma_cb) {
- case SATN_PDMA_CB:
- satn_pdma_cb(s);
- break;
case SATN_STOP_PDMA_CB:
satn_stop_pdma_cb(s);
break;
diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h
index b727181da9..9945645837 100644
--- a/include/hw/scsi/esp.h
+++ b/include/hw/scsi/esp.h
@@ -152,7 +152,6 @@ struct SysBusESPState {
/* PDMA callbacks */
enum pdma_cb {
- SATN_PDMA_CB = 0,
SATN_STOP_PDMA_CB = 2,
WRITE_RESPONSE_PDMA_CB = 3,
DO_DMA_PDMA_CB = 4
--
2.39.2
- [PULL 39/88] esp.c: convert do_dma_pdma_db() to switch statement based upon SCSI phase, (continued)
- [PULL 39/88] esp.c: convert do_dma_pdma_db() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/02/13
- [PULL 40/88] esp.c: convert esp_do_nodma() to switch statement based upon SCSI phase, Mark Cave-Ayland, 2024/02/13
- [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 <=
- [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, 2024/02/13
- [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