esp: remove CMD pdma_origin

The cmdbuf is really just a copy of FIFO data (including extra message phase
bytes) so its pdma_origin is effectively TI. Fortunately we already know when
we are receiving a SCSI command since do_cmd == 1 which enables us to
distinguish between the two cases in esp_pdma_read()/esp_pdma_write().

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210304221103.6369-26-mark.cave-ayland@ilande.co.uk>
This commit is contained in:
Mark Cave-Ayland 2021-03-04 22:10:46 +00:00
parent 3c421400ff
commit 02abe24688
2 changed files with 12 additions and 11 deletions

View File

@ -143,10 +143,11 @@ static uint8_t esp_pdma_read(ESPState *s)
switch (s->pdma_origin) { switch (s->pdma_origin) {
case TI: case TI:
val = s->ti_buf[s->ti_rptr++]; if (s->do_cmd) {
break; val = s->cmdbuf[s->cmdlen++];
case CMD: } else {
val = s->cmdbuf[s->cmdlen++]; val = s->ti_buf[s->ti_rptr++];
}
break; break;
case ASYNC: case ASYNC:
val = s->async_buf[0]; val = s->async_buf[0];
@ -176,10 +177,11 @@ static void esp_pdma_write(ESPState *s, uint8_t val)
switch (s->pdma_origin) { switch (s->pdma_origin) {
case TI: case TI:
s->ti_buf[s->ti_wptr++] = val; if (s->do_cmd) {
break; s->cmdbuf[s->cmdlen++] = val;
case CMD: } else {
s->cmdbuf[s->cmdlen++] = val; s->ti_buf[s->ti_wptr++] = val;
}
break; break;
case ASYNC: case ASYNC:
s->async_buf[0] = val; s->async_buf[0] = val;
@ -240,7 +242,7 @@ static uint32_t get_cmd(ESPState *s)
if (s->dma_memory_read) { if (s->dma_memory_read) {
s->dma_memory_read(s->dma_opaque, buf, dmalen); s->dma_memory_read(s->dma_opaque, buf, dmalen);
} else { } else {
set_pdma(s, CMD); set_pdma(s, TI);
esp_raise_drq(s); esp_raise_drq(s);
return 0; return 0;
} }
@ -471,7 +473,7 @@ static void esp_do_dma(ESPState *s)
if (s->dma_memory_read) { if (s->dma_memory_read) {
s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len); s->dma_memory_read(s->dma_opaque, &s->cmdbuf[s->cmdlen], len);
} else { } else {
set_pdma(s, CMD); set_pdma(s, TI);
s->pdma_cb = do_dma_pdma_cb; s->pdma_cb = do_dma_pdma_cb;
esp_raise_drq(s); esp_raise_drq(s);
return; return;

View File

@ -17,7 +17,6 @@ typedef struct ESPState ESPState;
enum pdma_origin_id { enum pdma_origin_id {
TI, TI,
CMD,
ASYNC, ASYNC,
}; };