[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/10] esp: introduce esp_set_pdma_cb() function
From: |
Mark Cave-Ayland |
Subject: |
[PATCH v2 06/10] esp: introduce esp_set_pdma_cb() function |
Date: |
Wed, 2 Mar 2022 21:27:48 +0000 |
This function is to be used to set the current PDMA callback rather than
accessing the ESPState pdma_cb function pointer directly.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/scsi/esp.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 58d0edbd56..d1640218c4 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -195,6 +195,11 @@ static void esp_pdma_write(ESPState *s, uint8_t val)
esp_set_tc(s, dmalen);
}
+static void esp_set_pdma_cb(ESPState *s, void (*cb)(ESPState *))
+{
+ s->pdma_cb = cb;
+}
+
static int esp_select(ESPState *s)
{
int target;
@@ -356,7 +361,7 @@ static void handle_satn(ESPState *s)
s->dma_cb = handle_satn;
return;
}
- s->pdma_cb = satn_pdma_cb;
+ esp_set_pdma_cb(s, satn_pdma_cb);
cmdlen = get_cmd(s, ESP_CMDFIFO_SZ);
if (cmdlen > 0) {
s->cmdfifo_cdb_offset = 1;
@@ -387,7 +392,7 @@ static void handle_s_without_atn(ESPState *s)
s->dma_cb = handle_s_without_atn;
return;
}
- s->pdma_cb = s_without_satn_pdma_cb;
+ esp_set_pdma_cb(s, s_without_satn_pdma_cb);
cmdlen = get_cmd(s, ESP_CMDFIFO_SZ);
if (cmdlen > 0) {
s->cmdfifo_cdb_offset = 0;
@@ -422,7 +427,7 @@ static void handle_satn_stop(ESPState *s)
s->dma_cb = handle_satn_stop;
return;
}
- s->pdma_cb = satn_stop_pdma_cb;
+ esp_set_pdma_cb(s, satn_stop_pdma_cb);
cmdlen = get_cmd(s, 1);
if (cmdlen > 0) {
trace_esp_handle_satn_stop(fifo8_num_used(&s->cmdfifo));
@@ -464,7 +469,7 @@ static void write_response(ESPState *s)
s->rregs[ESP_RINTR] |= INTR_BS | INTR_FC;
s->rregs[ESP_RSEQ] = SEQ_CD;
} else {
- s->pdma_cb = write_response_pdma_cb;
+ esp_set_pdma_cb(s, write_response_pdma_cb);
esp_raise_drq(s);
return;
}
@@ -604,7 +609,7 @@ static void esp_do_dma(ESPState *s)
s->dma_memory_read(s->dma_opaque, buf, len);
fifo8_push_all(&s->cmdfifo, buf, len);
} else {
- s->pdma_cb = do_dma_pdma_cb;
+ esp_set_pdma_cb(s, do_dma_pdma_cb);
esp_raise_drq(s);
return;
}
@@ -646,7 +651,7 @@ static void esp_do_dma(ESPState *s)
if (s->dma_memory_read) {
s->dma_memory_read(s->dma_opaque, s->async_buf, len);
} else {
- s->pdma_cb = do_dma_pdma_cb;
+ esp_set_pdma_cb(s, do_dma_pdma_cb);
esp_raise_drq(s);
return;
}
@@ -678,7 +683,7 @@ static void esp_do_dma(ESPState *s)
}
esp_set_tc(s, esp_get_tc(s) - len);
- s->pdma_cb = do_dma_pdma_cb;
+ esp_set_pdma_cb(s, do_dma_pdma_cb);
esp_raise_drq(s);
/* Indicate transfer to FIFO is complete */
--
2.20.1
- Re: [PATCH v2 03/10] macfb: increase number of registers saved in MacfbState, (continued)
Re: [PATCH v2 03/10] macfb: increase number of registers saved in MacfbState, Laurent Vivier, 2022/03/04
[PATCH v2 04/10] macfb: add VMStateDescription fields for display type and VBL timer, Mark Cave-Ayland, 2022/03/02
[PATCH v2 05/10] macfb: set initial value of mode control registers in macfb_common_realize(), Mark Cave-Ayland, 2022/03/02
[PATCH v2 06/10] esp: introduce esp_set_pdma_cb() function,
Mark Cave-Ayland <=
[PATCH v2 07/10] esp: introduce esp_pdma_cb() function, Mark Cave-Ayland, 2022/03/02
[PATCH v2 08/10] esp: convert ESPState pdma_cb from a function pointer to an integer, Mark Cave-Ayland, 2022/03/02
[PATCH v2 09/10] esp: include the current PDMA callback in the migration stream, Mark Cave-Ayland, 2022/03/02
[PATCH v2 10/10] esp: recreate ESPState current_req after migration, Mark Cave-Ayland, 2022/03/02