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 --- drivers/esp.c | 19 ++++++++++++++----- 1 file 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