Le 02/10/2019 à 13:10, Philippe Mathieu-Daudé a écrit : > On 9/27/19 11:04 AM, Laurent Vivier wrote: >> There is no DMA in Quadra 800, so the CPU reads/writes the data from the >> PDMA register (offset 0x100, ESP_PDMA in hw/m68k/q800.c) and copies them >> to/from the memory. >> >> There is a nice assembly loop in the kernel to do that, see >> linux/drivers/scsi/mac_esp.c:MAC_ESP_PDMA_LOOP(). >> >> The start of the transfer is triggered by the DREQ interrupt (see linux >> mac_esp_send_pdma_cmd()), the CPU polls on the IRQ flag to start the >> transfer after a SCSI command has been sent (in Quadra 800 it goes >> through the VIA2, the via2-irq line and the vIFR register) >> >> The Macintosh hardware includes hardware handshaking to prevent the CPU >> from reading invalid data or writing data faster than the peripheral >> device can accept it. >> >> This is the "blind mode", and from the doc: >> "Approximate maximum SCSI transfer rates within a blocks are 1.4 MB per >> second for blind transfers in the Macintosh II" >> >> Some references can be found in: >> Apple Macintosh Family Hardware Reference, ISBN 0-201-19255-1 >> Guide to the Macintosh Family Hardware, ISBN-0-201-52405-8 >> >> Acked-by: Dr. David Alan Gilbert <dgilb...@redhat.com> >> Co-developed-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk> >> Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk> >> Signed-off-by: Laurent Vivier <laur...@vivier.eu> >> --- >> hw/scsi/esp.c | 338 ++++++++++++++++++++++++++++++++++++++---- >> include/hw/scsi/esp.h | 15 ++ > > I recommend you to install the scripts/git.orderfile file.
done > >> 2 files changed, 324 insertions(+), 29 deletions(-) >> ... >> --- a/include/hw/scsi/esp.h >> +++ b/include/hw/scsi/esp.h >> @@ -14,10 +14,18 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void >> *opaque, uint8_t *buf, int len); >> typedef struct ESPState ESPState; >> +enum pdma_origin_id { >> + PDMA, >> + TI, >> + CMD, >> + ASYNC, >> +}; >> + >> struct ESPState { >> uint8_t rregs[ESP_REGS]; >> uint8_t wregs[ESP_REGS]; >> qemu_irq irq; >> + qemu_irq irq_data; >> uint8_t chip_id; >> bool tchi_written; >> int32_t ti_size; >> @@ -48,6 +56,12 @@ struct ESPState { >> ESPDMAMemoryReadWriteFunc dma_memory_write; >> void *dma_opaque; >> void (*dma_cb)(ESPState *s); >> + uint8_t pdma_buf[32]; >> + int pdma_origin; > > 'int' -> 'enum pdma_origin_id' > > You can also declare the enum in place: > > enum pdma_origin_id { > PDMA, > TI, > CMD, > ASYNC, > } pdma_origin; If I remember correctly I put an "int" here because I didn't find the VMSTATE_XXX() to use and VMSTATE_INT32() doesn't like the enum type (which should be treated as an int). Thanks, Laurent