aboutsummaryrefslogtreecommitdiff
path: root/drivers/esp.c
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2024-09-13 22:36:19 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2024-09-13 22:53:17 +0100
commitc3a19c1e54977a53027d6232050e1e3e39a98a1b (patch)
tree83caf8b2225c21d6944e83f66679db8d27b4f719 /drivers/esp.c
parent56fa1b2a72c71bc8aae0ac8599160ccdd1c77668 (diff)
downloadopenbios-master.zip
openbios-master.tar.gz
openbios-master.tar.bz2
esp: correctly terminate successful SCSI commandsHEADlatestmaster
An upcoming series for QEMU's ESP emulation will check that ESP commands are only issued according to their valid states as listed in the datasheet, and otherwise generate an illegal command interrupt. Currently if a SCSI command is expected to return no data or transfers data successfully, the ASC is not returned to its disconnected state. This means that any subsequent ESP initiator commands should be rejected until the SCSI bus transaction is terminated. Update the ESP driver so that if a SCSI command is successful then the ICCS and MSGACC commands are issued by the host to complete the SCSI transaction. This ensures that the ASC is returned to the disconnected state which allows the ESP to accept subsequent SCSI commands without generating an illegal command interrupt. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'drivers/esp.c')
-rw-r--r--drivers/esp.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/esp.c b/drivers/esp.c
index 5c7ddb5..92f28cc 100644
--- a/drivers/esp.c
+++ b/drivers/esp.c
@@ -115,11 +115,12 @@ do_command(esp_private_t *esp, sd_private_t *sd, int cmdlen, int replylen)
return status;
}
if (replylen == 0) {
- return 0;
+ /* No reply expected, ICCS and MSGACC to complete */
+ goto done;
}
/* Target went to status phase instead of data phase? */
if ((status & ESP_STAT_PMASK) == ESP_STATP) {
- return status;
+ goto done;
}
// Get reply
@@ -141,10 +142,18 @@ do_command(esp_private_t *esp, sd_private_t *sd, int cmdlen, int replylen)
DPRINTF("do_command_reply: status 0x%x\n", status);
- if ((status & ESP_STAT_TCNT) != ESP_STAT_TCNT)
+ if ((status & ESP_STAT_TCNT) != ESP_STAT_TCNT) {
return status;
- else
- return 0; // OK
+ }
+
+done:
+ // ICCS and MSGACC sequence to complete
+ esp->ll->regs[ESP_CMD] = ESP_CMD_ICCSEQ;
+ (void)esp->ll->regs[ESP_FDATA]; // Ignore 1st byte for now
+ (void)esp->ll->regs[ESP_FDATA]; // Ignore 2nd byte for now
+ esp->ll->regs[ESP_CMD] = ESP_CMD_MOK;
+
+ return 0; // OK
}
// offset is in sectors