1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 #ifndef _IC_DPTREG_H_
32 #define _IC_DPTREG_H_ 1
33
34
35 #define DPT_MAX_TARGETS 16
36 #define DPT_MAX_LUNS 8
37 #define DPT_MAX_CHANNELS 3
38
39
40 #define DPT_MAX_XFER ((DPT_SG_SIZE - 1) << PGSHIFT)
41 #define DPT_MAX_CCBS 256
42 #define DPT_SG_SIZE 64
43 #define DPT_ABORT_TIMEOUT 2000
44 #define DPT_MORE_TIMEOUT 1000
45
46 #ifdef _KERNEL
47
48 #if BYTE_ORDER == LITTLE_ENDIAN
49 #define SWAP32(x) bswap32((x))
50 #define SWAP16(x) bswap16((x))
51 #define RSWAP32(x) (x)
52 #define RSWAP16(x) (x)
53 #else
54 #define SWAP32(x) (x)
55 #define SWAP16(x) (x)
56 #define RSWAP32(x) bswap32((x))
57 #define RSWAP16(x) bswap16((x))
58 #endif
59
60 #ifdef __OpenBSD__
61 #define bswap16 swap16
62 #define bswap32 swap32
63 #endif
64
65 #define dpt_inb(x, o) \
66 bus_space_read_1((x)->sc_iot, (x)->sc_ioh, (o))
67
68 #define dpt_inw(x, o) \
69 RSWAP16(bus_space_read_2((x)->sc_iot, (x)->sc_ioh, (o)))
70
71 #define dpt_inl(x, o) \
72 RSWAP32(bus_space_read_4((x)->sc_iot, (x)->sc_ioh, (o)))
73
74 #define dpt_outb(x, o, d) \
75 bus_space_write_1((x)->sc_iot, (x)->sc_ioh, (o), (d))
76
77 #define dpt_outw(x, o, d) \
78 bus_space_write_2((x)->sc_iot, (x)->sc_ioh, (o), RSWAP16(d))
79
80 #define dpt_outl(x, o, d) \
81 bus_space_write_4((x)->sc_iot, (x)->sc_ioh, (o), RSWAP32(d))
82
83 #endif
84
85
86
87
88 #define HA_BASE 0x10
89 #define HA_DATA (HA_BASE + 0)
90 #define HA_ERROR (HA_BASE + 1)
91 #define HA_DMA_BASE (HA_BASE + 2)
92 #define HA_ICMD_CODE2 (HA_BASE + 4)
93 #define HA_ICMD_CODE1 (HA_BASE + 5)
94 #define HA_ICMD (HA_BASE + 6)
95
96
97 #define HA_COMMAND (HA_BASE + 7)
98 #define CP_PIO_GETCFG 0xf0
99 #define CP_PIO_CMD 0xf2
100 #define CP_DMA_GETCFG 0xfd
101 #define CP_DMA_CMD 0xff
102 #define CP_PIO_TRUNCATE 0xf4
103 #define CP_RESET 0xf9
104 #define CP_REBOOT 0x06
105 #define CP_IMMEDIATE 0xfa
106 #define CPI_GEN_ABORT 0x00
107 #define CPI_SPEC_RESET 0x01
108 #define CPI_BUS_RESET 0x02
109 #define CPI_SPEC_ABORT 0x03
110 #define CPI_QUIET_INTR 0x04
111 #define CPI_ROM_DL_EN 0x05
112 #define CPI_COLD_BOOT 0x06
113 #define CPI_FORCE_IO 0x07
114 #define CPI_BUS_OFFLINE 0x08
115 #define CPI_RESET_MSKD_BUS 0x09
116 #define CPI_POWEROFF_WARN 0x0a
117
118 #define HA_STATUS (HA_BASE + 7)
119 #define HA_ST_ERROR 0x01
120 #define HA_ST_MORE 0x02
121 #define HA_ST_CORRECTD 0x04
122 #define HA_ST_DRQ 0x08
123 #define HA_ST_SEEK_COMPLETE 0x10
124 #define HA_ST_WRT_FLT 0x20
125 #define HA_ST_READY 0x40
126 #define HA_ST_BUSY 0x80
127 #define HA_ST_DATA_RDY (HA_ST_SEEK_COMPLETE|HA_ST_READY|HA_ST_DRQ)
128
129 #define HA_AUX_STATUS (HA_BASE + 8)
130 #define HA_AUX_BUSY 0x01
131 #define HA_AUX_INTR 0x02
132
133
134
135
136 struct eata_cp {
137 u_int8_t cp_scsireset :1;
138 u_int8_t cp_hbainit :1;
139 u_int8_t cp_autosense :1;
140 u_int8_t cp_scatter :1;
141 u_int8_t cp_quick :1;
142 u_int8_t cp_interpret :1;
143 u_int8_t cp_dataout :1;
144 u_int8_t cp_datain :1;
145 u_int8_t cp_senselen;
146 u_int8_t cp_unused0[3];
147 u_int8_t cp_tophys :1;
148 u_int8_t cp_unused1 :7;
149 u_int8_t cp_physunit :1;
150 u_int8_t cp_noat :1;
151 u_int8_t cp_nocache :1;
152 u_int8_t cp_unused2 :5;
153 u_int8_t cp_id :5;
154 u_int8_t cp_channel :3;
155 u_int8_t cp_lun :3;
156 u_int8_t cp_unused3 :2;
157 u_int8_t cp_luntar :1;
158 u_int8_t cp_dispri :1;
159 u_int8_t cp_identify :1;
160 u_int8_t cp_msg[3];
161
162
163 u_int8_t cp_scsi_cmd;
164 u_int8_t cp_extent :1;
165 u_int8_t cp_bytchk :1;
166 u_int8_t cp_reladr :1;
167 u_int8_t cp_cmplst :1;
168 u_int8_t cp_fmtdata :1;
169 u_int8_t cp_cdblun :3;
170 u_int8_t cp_page;
171 u_int8_t cp_unused4;
172 u_int8_t cp_len;
173 u_int8_t cp_link :1;
174 u_int8_t cp_flag :1;
175 u_int8_t cp_unused5 :4;
176 u_int8_t cp_vendor :2;
177 u_int8_t cp_cdbmore[6];
178
179 u_int32_t cp_datalen;
180 u_int32_t cp_ccbid;
181 u_int32_t cp_dataaddr;
182 u_int32_t cp_stataddr;
183 u_int32_t cp_senseaddr;
184 };
185
186
187
188
189
190 struct eata_sp {
191 u_int8_t sp_hba_status;
192 u_int8_t sp_scsi_status;
193 u_int8_t sp_reserved[2];
194 u_int32_t sp_inv_residue;
195 u_int32_t sp_ccbid;
196 u_int8_t sp_id_message;
197 u_int8_t sp_que_message;
198 u_int8_t sp_tag_message;
199 u_int8_t sp_messages[9];
200 };
201
202
203
204
205 #define HA_NO_ERROR 0x00
206 #define HA_ERROR_SEL_TO 0x01
207 #define HA_ERROR_CMD_TO 0x02
208 #define HA_ERROR_RESET 0x03
209 #define HA_INIT_POWERUP 0x04
210 #define HA_UNX_BUSPHASE 0x05
211 #define HA_UNX_BUS_FREE 0x06
212 #define HA_BUS_PARITY 0x07
213 #define HA_SCSI_HUNG 0x08
214 #define HA_UNX_MSGRJCT 0x09
215 #define HA_RESET_STUCK 0x0A
216 #define HA_RSENSE_FAIL 0x0B
217 #define HA_PARITY 0x0C
218 #define HA_ABORT_NA 0x0D
219 #define HA_ABORTED 0x0E
220 #define HA_RESET_NA 0x0F
221 #define HA_RESET 0x10
222 #define HA_ECC 0x11
223 #define HA_PCI_PARITY 0x12
224 #define HA_PCI_MASTER 0x13
225 #define HA_PCI_TARGET 0x14
226 #define HA_PCI_SIGNAL_TARGET 0x15
227 #define HA_ABORT 0x20
228
229
230
231
232 struct eata_sg {
233 u_int32_t sg_addr;
234 u_int32_t sg_len;
235 };
236
237
238
239
240
241
242 struct eata_cfg {
243 u_int8_t ec_devtype;
244 u_int8_t ec_pagecode;
245 u_int8_t ec_reserved0;
246 u_int8_t ec_cfglen;
247 u_int8_t ec_eatasig[4];
248 u_int8_t ec_eataversion;
249 u_int8_t ec_overlapcmds : 1;
250 u_int8_t ec_targetmode : 1;
251 u_int8_t ec_trunnotrec : 1;
252 u_int8_t ec_moresupported:1;
253 u_int8_t ec_dmasupported : 1;
254 u_int8_t ec_dmanumvalid : 1;
255 u_int8_t ec_atadev : 1;
256 u_int8_t ec_hbavalid : 1;
257 u_int8_t ec_padlength[2];
258 u_int8_t ec_hba[4];
259 u_int8_t ec_cplen[4];
260 u_int8_t ec_splen[4];
261 u_int8_t ec_queuedepth[2];
262 u_int8_t ec_reserved1[2];
263 u_int8_t ec_sglen[2];
264 u_int8_t ec_irqnum : 4;
265 u_int8_t ec_irqtrigger : 1;
266 u_int8_t ec_secondary : 1;
267 u_int8_t ec_dmanum : 2;
268 u_int8_t ec_irq;
269 u_int8_t ec_iodisable : 1;
270 u_int8_t ec_forceaddr : 1;
271 u_int8_t ec_sg64k : 1;
272 u_int8_t ec_sgunaligned : 1;
273 u_int8_t ec_reserved2 : 4;
274 u_int8_t ec_maxtarget : 5;
275 u_int8_t ec_maxchannel : 3;
276 u_int8_t ec_maxlun;
277 u_int8_t ec_reserved3 : 3;
278 u_int8_t ec_autoterm : 1;
279 u_int8_t ec_pcim1 : 1;
280 u_int8_t ec_bogusraidid : 1;
281 u_int8_t ec_pci : 1;
282 u_int8_t ec_eisa : 1;
283 u_int8_t ec_raidnum;
284 };
285
286
287
288
289 struct eata_inquiry_data {
290 u_int8_t ei_device;
291 u_int8_t ei_dev_qual2;
292 u_int8_t ei_version;
293 u_int8_t ei_response_format;
294 u_int8_t ei_additional_length;
295 u_int8_t ei_unused[2];
296 u_int8_t ei_flags;
297 char ei_vendor[8];
298 char ei_model[7];
299 char ei_suffix[9];
300 char ei_fw[3];
301 char ei_fwrev[1];
302 u_int8_t ei_extra[8];
303 };
304
305 #endif