Message ID | 20210209193018.31339-17-mark.cave-ayland@ilande.co.uk |
---|---|
State | New |
Headers | show |
Series | esp: consolidate PDMA transfer buffers and other fixes | expand |
On 2/9/21 8:29 PM, Mark Cave-Ayland wrote: > This is the first step in removing get_pdma_buf() from esp.c. > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> > --- > hw/scsi/esp.c | 34 ++++++++++++++++++++++++++++------ > 1 file changed, 28 insertions(+), 6 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Le 09/02/2021 à 20:29, Mark Cave-Ayland a écrit : > This is the first step in removing get_pdma_buf() from esp.c. > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> > --- > hw/scsi/esp.c | 34 ++++++++++++++++++++++++++++------ > 1 file changed, 28 insertions(+), 6 deletions(-) > > diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c > index b0cba889a9..cfeba2feb0 100644 > --- a/hw/scsi/esp.c > +++ b/hw/scsi/esp.c > @@ -153,16 +153,38 @@ static uint8_t *get_pdma_buf(ESPState *s) > > static uint8_t esp_pdma_read(ESPState *s) > { > - uint8_t *buf = get_pdma_buf(s); > - > - return buf[s->pdma_cur++]; > + switch (s->pdma_origin) { > + case PDMA: > + return s->pdma_buf[s->pdma_cur++]; > + case TI: > + return s->ti_buf[s->pdma_cur++]; > + case CMD: > + return s->cmdbuf[s->pdma_cur++]; > + case ASYNC: > + return s->async_buf[s->pdma_cur++]; > + default: > + g_assert_not_reached(); > + } > } > > static void esp_pdma_write(ESPState *s, uint8_t val) > { > - uint8_t *buf = get_pdma_buf(s); > - > - buf[s->pdma_cur++] = val; > + switch (s->pdma_origin) { > + case PDMA: > + s->pdma_buf[s->pdma_cur++] = val; > + break; > + case TI: > + s->ti_buf[s->pdma_cur++] = val; > + break; > + case CMD: > + s->cmdbuf[s->pdma_cur++] = val; > + break; > + case ASYNC: > + s->async_buf[s->pdma_cur++] = val; > + break; > + default: > + g_assert_not_reached(); > + } > } > > static int get_cmd_cb(ESPState *s) > Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index b0cba889a9..cfeba2feb0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -153,16 +153,38 @@ static uint8_t *get_pdma_buf(ESPState *s) static uint8_t esp_pdma_read(ESPState *s) { - uint8_t *buf = get_pdma_buf(s); - - return buf[s->pdma_cur++]; + switch (s->pdma_origin) { + case PDMA: + return s->pdma_buf[s->pdma_cur++]; + case TI: + return s->ti_buf[s->pdma_cur++]; + case CMD: + return s->cmdbuf[s->pdma_cur++]; + case ASYNC: + return s->async_buf[s->pdma_cur++]; + default: + g_assert_not_reached(); + } } static void esp_pdma_write(ESPState *s, uint8_t val) { - uint8_t *buf = get_pdma_buf(s); - - buf[s->pdma_cur++] = val; + switch (s->pdma_origin) { + case PDMA: + s->pdma_buf[s->pdma_cur++] = val; + break; + case TI: + s->ti_buf[s->pdma_cur++] = val; + break; + case CMD: + s->cmdbuf[s->pdma_cur++] = val; + break; + case ASYNC: + s->async_buf[s->pdma_cur++] = val; + break; + default: + g_assert_not_reached(); + } } static int get_cmd_cb(ESPState *s)
This is the first step in removing get_pdma_buf() from esp.c. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> --- hw/scsi/esp.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)