[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 67/88] esp.c: replace get_cmd() with esp_do_nodma()
|
From: |
Mark Cave-Ayland |
|
Subject: |
[PATCH 67/88] esp.c: replace get_cmd() with esp_do_nodma() |
|
Date: |
Fri, 12 Jan 2024 12:53:59 +0000 |
Now that the esp_do_nodma() state machine correctly handles incoming FIFO
data, all remaining users of get_cmd() can be replaced with esp_do_nodma()
and the get_cmd() function removed completely.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
hw/scsi/esp.c | 54 ++++-----------------------------------------------
1 file changed, 4 insertions(+), 50 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 5bb8cc4ea7..277eb8647b 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -257,40 +257,6 @@ static int esp_select(ESPState *s)
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];
- uint32_t dmalen, n;
- int target;
-
- target = s->wregs[ESP_WBUSID] & BUSID_DID;
- if (s->dma) {
- dmalen = MIN(esp_get_tc(s), maxlen);
- if (dmalen == 0) {
- return 0;
- }
- if (s->dma_memory_read) {
- s->dma_memory_read(s->dma_opaque, buf, dmalen);
- dmalen = MIN(fifo8_num_free(&s->cmdfifo), dmalen);
- fifo8_push_all(&s->cmdfifo, buf, dmalen);
- esp_set_tc(s, esp_get_tc(s) - dmalen);
- } else {
- return 0;
- }
- } else {
- dmalen = MIN(fifo8_num_used(&s->fifo), maxlen);
- if (dmalen == 0) {
- return 0;
- }
- n = esp_fifo_pop_buf(&s->fifo, buf, dmalen);
- n = MIN(fifo8_num_free(&s->cmdfifo), n);
- fifo8_push_all(&s->cmdfifo, buf, n);
- }
- trace_esp_get_cmd(dmalen, target);
-
- return dmalen;
-}
-
static void do_command_phase(ESPState *s)
{
uint32_t cmdlen;
@@ -376,10 +342,7 @@ static void handle_satn(ESPState *s)
if (s->dma) {
esp_do_dma(s);
} else {
- if (get_cmd(s, ESP_CMDFIFO_SZ)) {
- s->cmdfifo_cdb_offset = 1;
- do_cmd(s);
- }
+ esp_do_nodma(s);
}
}
@@ -401,9 +364,7 @@ static void handle_s_without_atn(ESPState *s)
if (s->dma) {
esp_do_dma(s);
} else {
- if (get_cmd(s, ESP_CMDFIFO_SZ)) {
- do_cmd(s);
- }
+ esp_do_nodma(s);
}
}
@@ -425,14 +386,7 @@ static void handle_satn_stop(ESPState *s)
if (s->dma) {
esp_do_dma(s);
} else {
- if (get_cmd(s, 1)) {
- trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo));
-
- /* Raise command completion interrupt */
- s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC;
- s->rregs[ESP_RSEQ] = SEQ_MO;
- esp_raise_irq(s);
- }
+ esp_do_nodma(s);
}
}
@@ -770,7 +724,7 @@ static void esp_do_nodma(ESPState *s)
break;
case CMD_SELATNS:
- if (fifo8_num_used(&s->cmdfifo) == 1) {
+ if (fifo8_num_used(&s->cmdfifo) >= 1) {
/* First byte received, stop in message out phase */
s->cmdfifo_cdb_offset = 1;
--
2.39.2
- [PATCH 63/88] esp.c: remove unneeded ti_cmd field, (continued)
- [PATCH 63/88] esp.c: remove unneeded ti_cmd field, Mark Cave-Ayland, 2024/01/12
- [PATCH 82/88] esp.c: consolidate DMA and PDMA logic in STATUS and MESSAGE IN phases, Mark Cave-Ayland, 2024/01/12
- [PATCH 69/88] esp.c: consolidate end of command sequence after ICCS command, Mark Cave-Ayland, 2024/01/12
- [PATCH 52/88] esp.c: move CMD_SELATNS end of command logic to esp_do_dma() and do_dma_pdma_cb(), Mark Cave-Ayland, 2024/01/12
- [PATCH 68/88] esp.c: move write_response() non-DMA logic to esp_do_nodma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 86/88] esp.c: keep track of the DRQ state during DMA, Mark Cave-Ayland, 2024/01/12
- [PATCH 88/88] esp.c: add my copyright to the file, Mark Cave-Ayland, 2024/01/12
- [PATCH 60/88] esp.c: use deferred interrupts for both DATA IN and DATA OUT phases, Mark Cave-Ayland, 2024/01/12
- [PATCH 85/88] esp.c: rename irq_data IRQ to drq_irq, Mark Cave-Ayland, 2024/01/12
- [PATCH 83/88] esp.c: replace n variable with len in esp_do_nodma(), Mark Cave-Ayland, 2024/01/12
- [PATCH 67/88] esp.c: replace get_cmd() with esp_do_nodma(),
Mark Cave-Ayland <=
- [PATCH 87/88] esp.c: switch TypeInfo registration to use DEFINE_TYPES() macro, Mark Cave-Ayland, 2024/01/12
- Re: [PATCH 00/88] esp: rework ESP emulation to use a SCSI phase-based state machine, Mark Cave-Ayland, 2024/01/22
- Re: [PATCH 00/88] esp: rework ESP emulation to use a SCSI phase-based state machine, Thomas Huth, 2024/01/25