mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
esp: add pseudo-DMA as used by Macintosh
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 <dgilbert@redhat.com> Co-developed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20191026164546.30020-4-laurent@vivier.eu>
This commit is contained in:
parent
6130b18850
commit
74d71ea16b
2 changed files with 284 additions and 9 deletions
|
@ -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;
|
||||
uint32_t pdma_len;
|
||||
uint32_t pdma_start;
|
||||
uint32_t pdma_cur;
|
||||
void (*pdma_cb)(ESPState *s);
|
||||
};
|
||||
|
||||
#define TYPE_ESP "esp"
|
||||
|
@ -59,6 +73,7 @@ typedef struct {
|
|||
/*< public >*/
|
||||
|
||||
MemoryRegion iomem;
|
||||
MemoryRegion pdma;
|
||||
uint32_t it_shift;
|
||||
ESPState esp;
|
||||
} SysBusESPState;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue