esp.c: remove do_cmd from ESPState

Now that the accumulation of the CDB is handled by SCSI phase, there is no need
for a separate variable to control it.

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-46-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
This commit is contained in:
Mark Cave-Ayland 2024-01-12 12:53:37 +00:00
parent df91fd4ecd
commit 6d97f5acbf

View File

@ -380,7 +380,6 @@ static void satn_pdma_cb(ESPState *s)
if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) {
s->cmdfifo_cdb_offset = 1; s->cmdfifo_cdb_offset = 1;
s->do_cmd = 0;
do_cmd(s); do_cmd(s);
} }
} }
@ -400,13 +399,11 @@ static void handle_satn(ESPState *s)
cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); cmdlen = get_cmd(s, ESP_CMDFIFO_SZ);
if (cmdlen > 0) { if (cmdlen > 0) {
s->cmdfifo_cdb_offset = 1; s->cmdfifo_cdb_offset = 1;
s->do_cmd = 0;
do_cmd(s); do_cmd(s);
} else if (cmdlen == 0) { } else if (cmdlen == 0) {
if (s->dma) { if (s->dma) {
esp_raise_drq(s); esp_raise_drq(s);
} }
s->do_cmd = 1;
/* Target present, but no cmd yet - switch to command phase */ /* Target present, but no cmd yet - switch to command phase */
s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RSEQ] = SEQ_CD;
esp_set_phase(s, STAT_CD); esp_set_phase(s, STAT_CD);
@ -428,13 +425,11 @@ static void handle_s_without_atn(ESPState *s)
cmdlen = get_cmd(s, ESP_CMDFIFO_SZ); cmdlen = get_cmd(s, ESP_CMDFIFO_SZ);
if (cmdlen > 0) { if (cmdlen > 0) {
s->cmdfifo_cdb_offset = 0; s->cmdfifo_cdb_offset = 0;
s->do_cmd = 0;
do_cmd(s); do_cmd(s);
} else if (cmdlen == 0) { } else if (cmdlen == 0) {
if (s->dma) { if (s->dma) {
esp_raise_drq(s); esp_raise_drq(s);
} }
s->do_cmd = 1;
/* Target present, but no cmd yet - switch to command phase */ /* Target present, but no cmd yet - switch to command phase */
s->rregs[ESP_RSEQ] = SEQ_CD; s->rregs[ESP_RSEQ] = SEQ_CD;
esp_set_phase(s, STAT_CD); esp_set_phase(s, STAT_CD);
@ -453,7 +448,6 @@ static void satn_stop_pdma_cb(ESPState *s)
if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) { if (!esp_get_tc(s) && !fifo8_is_empty(&s->cmdfifo)) {
trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo));
s->do_cmd = 1;
s->cmdfifo_cdb_offset = 1; s->cmdfifo_cdb_offset = 1;
esp_set_phase(s, STAT_CD); esp_set_phase(s, STAT_CD);
s->rregs[ESP_RSTAT] |= STAT_TC; s->rregs[ESP_RSTAT] |= STAT_TC;
@ -478,7 +472,6 @@ static void handle_satn_stop(ESPState *s)
cmdlen = get_cmd(s, 1); cmdlen = get_cmd(s, 1);
if (cmdlen > 0) { if (cmdlen > 0) {
trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo)); trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo));
s->do_cmd = 1;
s->cmdfifo_cdb_offset = 1; s->cmdfifo_cdb_offset = 1;
esp_set_phase(s, STAT_MO); esp_set_phase(s, STAT_MO);
s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC; s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC;
@ -488,7 +481,6 @@ static void handle_satn_stop(ESPState *s)
if (s->dma) { if (s->dma) {
esp_raise_drq(s); esp_raise_drq(s);
} }
s->do_cmd = 1;
/* Target present, switch to message out phase */ /* Target present, switch to message out phase */
s->rregs[ESP_RSEQ] = SEQ_MO; s->rregs[ESP_RSEQ] = SEQ_MO;
esp_set_phase(s, STAT_MO); esp_set_phase(s, STAT_MO);
@ -567,7 +559,6 @@ static void do_dma_pdma_cb(ESPState *s)
} }
/* Command has been received */ /* Command has been received */
s->do_cmd = 0;
do_cmd(s); do_cmd(s);
} else { } else {
/* /*
@ -669,7 +660,6 @@ static void esp_do_dma(ESPState *s)
} }
/* Command has been received */ /* Command has been received */
s->do_cmd = 0;
do_cmd(s); do_cmd(s);
} else { } else {
/* /*
@ -805,7 +795,6 @@ static void esp_do_nodma(ESPState *s)
} }
/* Command has been received */ /* Command has been received */
s->do_cmd = 0;
do_cmd(s); do_cmd(s);
} else { } else {
/* /*
@ -949,7 +938,6 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len)
int to_device = (esp_get_phase(s) == STAT_DO); int to_device = (esp_get_phase(s) == STAT_DO);
uint32_t dmalen = esp_get_tc(s); uint32_t dmalen = esp_get_tc(s);
assert(!s->do_cmd);
trace_esp_transfer_data(dmalen, s->ti_size); trace_esp_transfer_data(dmalen, s->ti_size);
s->async_len = len; s->async_len = len;
s->async_buf = scsi_req_get_buf(req); s->async_buf = scsi_req_get_buf(req);
@ -1012,7 +1000,6 @@ void esp_hard_reset(ESPState *s)
fifo8_reset(&s->fifo); fifo8_reset(&s->fifo);
fifo8_reset(&s->cmdfifo); fifo8_reset(&s->cmdfifo);
s->dma = 0; s->dma = 0;
s->do_cmd = 0;
s->dma_cb = NULL; s->dma_cb = NULL;
s->rregs[ESP_CFG1] = 7; s->rregs[ESP_CFG1] = 7;