4 #include "hw/scsi/scsi.h"
9 typedef void (*ESPDMAMemoryReadWriteFunc
)(void *opaque
, uint8_t *buf
, int len
);
13 #define ESP_CMDBUF_SZ 32
15 typedef struct ESPState ESPState
;
18 uint8_t rregs
[ESP_REGS
];
19 uint8_t wregs
[ESP_REGS
];
24 uint32_t ti_rptr
, ti_wptr
;
27 uint8_t ti_buf
[TI_BUFSZ
];
29 SCSIDevice
*current_dev
;
30 SCSIRequest
*current_req
;
31 uint8_t cmdbuf
[ESP_CMDBUF_SZ
];
35 /* The amount of data left in the current DMA transfer. */
37 /* The size of the current DMA transfer. Zero if no transfer is in
45 ESPDMAMemoryReadWriteFunc dma_memory_read
;
46 ESPDMAMemoryReadWriteFunc dma_memory_write
;
48 void (*dma_cb
)(ESPState
*s
);
51 #define TYPE_ESP "esp"
52 #define ESP_STATE(obj) OBJECT_CHECK(SysBusESPState, (obj), TYPE_ESP)
56 SysBusDevice parent_obj
;
69 #define ESP_WBUSID 0x4
73 #define ESP_WSYNTP 0x6
74 #define ESP_RFLAGS 0x7
91 #define CMD_FLUSH 0x01
92 #define CMD_RESET 0x02
93 #define CMD_BUSRESET 0x03
96 #define CMD_MSGACC 0x12
99 #define CMD_RSTATN 0x1b
101 #define CMD_SELATN 0x42
102 #define CMD_SELATNS 0x43
103 #define CMD_ENSEL 0x44
104 #define CMD_DISSEL 0x45
112 #define STAT_PIO_MASK 0x06
117 #define STAT_INT 0x80
119 #define BUSID_DID 0x07
124 #define INTR_RST 0x80
129 #define CFG1_RESREPT 0x40
131 #define TCHI_FAS100A 0x4
132 #define TCHI_AM53C974 0x12
134 ESPState
*esp_init(hwaddr espaddr
, int it_shift
,
135 ESPDMAMemoryReadWriteFunc dma_memory_read
,
136 ESPDMAMemoryReadWriteFunc dma_memory_write
,
137 void *dma_opaque
, qemu_irq irq
, qemu_irq
*reset
,
138 qemu_irq
*dma_enable
);
139 void esp_dma_enable(ESPState
*s
, int irq
, int level
);
140 void esp_request_cancelled(SCSIRequest
*req
);
141 void esp_command_complete(SCSIRequest
*req
, uint32_t status
, size_t resid
);
142 void esp_transfer_data(SCSIRequest
*req
, uint32_t len
);
143 void esp_hard_reset(ESPState
*s
);
144 uint64_t esp_reg_read(ESPState
*s
, uint32_t saddr
);
145 void esp_reg_write(ESPState
*s
, uint32_t saddr
, uint64_t val
);
146 extern const VMStateDescription vmstate_esp
;