4 #include "hw/scsi/scsi.h"
6 #include "qemu/fifo8.h"
7 #include "qom/object.h"
10 #define ESP_MAX_DEVS 7
11 typedef void (*ESPDMAMemoryReadWriteFunc
)(void *opaque
, uint8_t *buf
, int len
);
14 #define ESP_FIFO_SZ 16
15 #define ESP_CMDFIFO_SZ 32
17 typedef struct ESPState ESPState
;
19 #define TYPE_ESP "esp"
20 OBJECT_DECLARE_SIMPLE_TYPE(ESPState
, ESP
)
23 DeviceState parent_obj
;
25 uint8_t rregs
[ESP_REGS
];
26 uint8_t wregs
[ESP_REGS
];
36 SCSIDevice
*current_dev
;
37 SCSIRequest
*current_req
;
39 uint8_t cmdfifo_cdb_offset
;
50 ESPDMAMemoryReadWriteFunc dma_memory_read
;
51 ESPDMAMemoryReadWriteFunc dma_memory_write
;
53 void (*dma_cb
)(ESPState
*s
);
54 void (*pdma_cb
)(ESPState
*s
);
56 uint8_t mig_version_id
;
58 /* Legacy fields for vmstate_esp version < 5 */
59 uint32_t mig_dma_left
;
60 uint32_t mig_deferred_status
;
61 bool mig_deferred_complete
;
62 uint32_t mig_ti_rptr
, mig_ti_wptr
;
63 uint8_t mig_ti_buf
[ESP_FIFO_SZ
];
64 uint8_t mig_cmdbuf
[ESP_CMDFIFO_SZ
];
68 #define TYPE_SYSBUS_ESP "sysbus-esp"
69 OBJECT_DECLARE_SIMPLE_TYPE(SysBusESPState
, SYSBUS_ESP
)
71 struct SysBusESPState
{
73 SysBusDevice parent_obj
;
87 #define ESP_WBUSID 0x4
91 #define ESP_WSYNTP 0x6
92 #define ESP_RFLAGS 0x7
109 #define CMD_FLUSH 0x01
110 #define CMD_RESET 0x02
111 #define CMD_BUSRESET 0x03
113 #define CMD_ICCS 0x11
114 #define CMD_MSGACC 0x12
116 #define CMD_SATN 0x1a
117 #define CMD_RSTATN 0x1b
119 #define CMD_SELATN 0x42
120 #define CMD_SELATNS 0x43
121 #define CMD_ENSEL 0x44
122 #define CMD_DISSEL 0x45
130 #define STAT_PIO_MASK 0x06
135 #define STAT_INT 0x80
137 #define BUSID_DID 0x07
142 #define INTR_RST 0x80
148 #define CFG1_RESREPT 0x40
150 #define TCHI_FAS100A 0x4
151 #define TCHI_AM53C974 0x12
153 void esp_dma_enable(ESPState
*s
, int irq
, int level
);
154 void esp_request_cancelled(SCSIRequest
*req
);
155 void esp_command_complete(SCSIRequest
*req
, size_t resid
);
156 void esp_transfer_data(SCSIRequest
*req
, uint32_t len
);
157 void esp_hard_reset(ESPState
*s
);
158 uint64_t esp_reg_read(ESPState
*s
, uint32_t saddr
);
159 void esp_reg_write(ESPState
*s
, uint32_t saddr
, uint64_t val
);
160 extern const VMStateDescription vmstate_esp
;
161 int esp_pre_save(void *opaque
);