Skip to content

Commit

Permalink
esp.c: zero command register when TI command terminates due to phase …
Browse files Browse the repository at this point in the history
…change

This is the behaviour documented in the datasheet and allows the state machine
to correctly process multiple consecutive TI commands.

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-63-mark.cave-ayland@ilande.co.uk>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
  • Loading branch information
mcayland committed Feb 13, 2024
1 parent 036120f commit cb22ce5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hw/scsi/esp.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ static void esp_do_dma(ESPState *s)
/* ATN remains asserted until TC == 0 */
if (esp_get_tc(s) == 0) {
esp_set_phase(s, STAT_CD);
s->rregs[ESP_CMD] = 0;
s->rregs[ESP_RSEQ] = SEQ_CD;
s->rregs[ESP_RINTR] |= INTR_BS;
esp_raise_irq(s);
Expand Down Expand Up @@ -717,6 +718,7 @@ static void esp_do_nodma(ESPState *s)
*/
s->cmdfifo_cdb_offset = fifo8_num_used(&s->cmdfifo);
esp_set_phase(s, STAT_CD);
s->rregs[ESP_CMD] = 0;
s->rregs[ESP_RSEQ] = SEQ_CD;
s->rregs[ESP_RINTR] |= INTR_BS;
esp_raise_irq(s);
Expand Down Expand Up @@ -831,6 +833,11 @@ void esp_command_complete(SCSIRequest *req, size_t resid)
*/
s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC;
break;

case CMD_TI | CMD_DMA:
case CMD_TI:
s->rregs[ESP_CMD] = 0;
break;
}

/* Raise bus service interrupt to indicate change to STATUS phase */
Expand Down Expand Up @@ -885,6 +892,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len)
* Bus service interrupt raised because of initial change to
* DATA phase
*/
s->rregs[ESP_CMD] = 0;
s->rregs[ESP_RINTR] |= INTR_BS;
break;
}
Expand Down

0 comments on commit cb22ce5

Please sign in to comment.