1
2 typedef u_int8_t physaddr[3];
3 typedef u_int8_t physlen[3];
4 #define ltophys _lto3b
5 #define phystol _3btol
6
7
8
9
10 #define AHA_CTRL_PORT 0
11 #define AHA_STAT_PORT 0
12 #define AHA_CMD_PORT 1
13 #define AHA_DATA_PORT 1
14 #define AHA_INTR_PORT 2
15
16
17
18
19 #define AHA_CTRL_HRST 0x80
20 #define AHA_CTRL_SRST 0x40
21 #define AHA_CTRL_IRST 0x20
22 #define AHA_CTRL_SCRST 0x10
23
24
25
26
27 #define AHA_STAT_STST 0x80
28 #define AHA_STAT_DIAGF 0x40
29 #define AHA_STAT_INIT 0x20
30 #define AHA_STAT_IDLE 0x10
31 #define AHA_STAT_CDF 0x08
32 #define AHA_STAT_DF 0x04
33 #define AHA_STAT_INVDCMD 0x01
34
35
36
37
38 #define AHA_NOP 0x00
39 #define AHA_MBX_INIT 0x01
40 #define AHA_START_SCSI 0x02
41 #define AHA_INQUIRE_REVISION 0x04
42 #define AHA_MBO_INTR_EN 0x05
43 #if 0
44 #define AHA_SEL_TIMEOUT_SET 0x06
45 #define AHA_BUS_ON_TIME_SET 0x07
46 #define AHA_BUS_OFF_TIME_SET 0x08
47 #define AHA_SPEED_SET 0x09
48 #endif
49 #define AHA_INQUIRE_DEVICES 0x0a
50 #define AHA_INQUIRE_CONFIG 0x0b
51 #define AHA_TARGET_EN 0x0c
52 #define AHA_INQUIRE_SETUP 0x0d
53 #define AHA_ECHO 0x1e
54 #define AHA_INQUIRE_DEVICES_2 0x23
55 #define AHA_EXT_BIOS 0x28
56 #define AHA_MBX_ENABLE 0x29
57
58
59
60
61 #define AHA_INTR_ANYINTR 0x80
62 #define AHA_INTR_SCRD 0x08
63 #define AHA_INTR_HACC 0x04
64 #define AHA_INTR_MBOA 0x02
65 #define AHA_INTR_MBIF 0x01
66
67 struct aha_mbx_out {
68 u_char cmd;
69 physaddr ccb_addr;
70 };
71
72 struct aha_mbx_in {
73 u_char stat;
74 physaddr ccb_addr;
75 };
76
77
78
79
80 #define AHA_MBO_FREE 0x0
81 #define AHA_MBO_START 0x1
82 #define AHA_MBO_ABORT 0x2
83
84
85
86
87 #define AHA_MBI_FREE 0x0
88 #define AHA_MBI_OK 0x1
89 #define AHA_MBI_ABORT 0x2
90 #define AHA_MBI_UNKNOWN 0x3
91 #define AHA_MBI_ERROR 0x4
92
93
94 #define AHA_NSEG 17
95
96
97 struct aha_scat_gath {
98 physlen seg_len;
99 physaddr seg_addr;
100 };
101
102 struct aha_ccb {
103 u_char opcode;
104 u_char lun:3;
105 u_char data_in:1;
106 u_char data_out:1;
107 u_char target:3;
108 u_char scsi_cmd_length;
109 u_char req_sense_length;
110 physlen data_length;
111 physaddr data_addr;
112 physaddr link_addr;
113 u_char link_id;
114 u_char host_stat;
115 u_char target_stat;
116 u_char reserved[2];
117 struct scsi_generic scsi_cmd;
118 struct scsi_sense_data scsi_sense;
119 struct aha_scat_gath scat_gath[AHA_NSEG];
120
121 #define CCB_PHYS_SIZE ((int)&((struct aha_ccb *)0)->chain)
122 TAILQ_ENTRY(aha_ccb) chain;
123 struct aha_ccb *nexthash;
124 struct scsi_xfer *xs;
125 int flags;
126 #define CCB_ALLOC 0x01
127 #define CCB_ABORT 0x02
128 #ifdef AHADIAG
129 #define CCB_SENDING 0x04
130 #endif
131 int timeout;
132 bus_dmamap_t dmam;
133 bus_dmamap_t ccb_dmam;
134 };
135
136
137
138
139 #define AHA_INITIATOR_CCB 0x00
140 #define AHA_TARGET_CCB 0x01
141 #define AHA_INIT_SCAT_GATH_CCB 0x02
142 #define AHA_RESET_CCB 0x81
143
144
145
146
147 #define AHA_OK 0x00
148 #define AHA_LINK_OK 0x0a
149 #define AHA_LINK_IT 0x0b
150 #define AHA_SEL_TIMEOUT 0x11
151 #define AHA_OVER_UNDER 0x12
152 #define AHA_BUS_FREE 0x13
153 #define AHA_INV_BUS 0x14
154 #define AHA_BAD_MBO 0x15
155 #define AHA_BAD_CCB 0x16
156 #define AHA_BAD_LINK 0x17
157 #define AHA_INV_TARGET 0x18
158 #define AHA_CCB_DUP 0x19
159 #define AHA_INV_CCB 0x1a
160
161 struct aha_revision {
162 struct {
163 u_char opcode;
164 } cmd;
165 struct {
166 u_char boardid;
167
168
169
170
171
172
173
174 u_char spec_opts;
175
176 u_char revision_1;
177 u_char revision_2;
178 } reply;
179 };
180
181 struct aha_extbios {
182 struct {
183 u_char opcode;
184 } cmd;
185 struct {
186 u_char flags;
187 u_char mailboxlock;
188 } reply;
189 };
190
191 struct aha_toggle {
192 struct {
193 u_char opcode;
194 u_char enable;
195 } cmd;
196 };
197
198 struct aha_config {
199 struct {
200 u_char opcode;
201 } cmd;
202 struct {
203 u_char chan;
204 u_char intr;
205 u_char scsi_dev:3;
206 u_char :5;
207 } reply;
208 };
209
210 struct aha_mailbox {
211 struct {
212 u_char opcode;
213 u_char nmbx;
214 physaddr addr;
215 } cmd;
216 };
217
218 struct aha_unlock {
219 struct {
220 u_char opcode;
221 u_char junk;
222 u_char magic;
223 } cmd;
224 };
225
226 struct aha_devices {
227 struct {
228 u_char opcode;
229 } cmd;
230 struct {
231 u_char junk[8];
232 } reply;
233 };
234
235 struct aha_setup {
236 struct {
237 u_char opcode;
238 u_char len;
239 } cmd;
240 struct {
241 u_char sync_neg:1;
242 u_char parity:1;
243 u_char :6;
244 u_char speed;
245 u_char bus_on;
246 u_char bus_off;
247 u_char num_mbx;
248 u_char mbx[3];
249 struct {
250 u_char offset:4;
251 u_char period:3;
252 u_char valid:1;
253 } sync[8];
254 u_char disc_sts;
255 } reply;
256 };
257
258 #define INT9 0x01
259 #define INT10 0x02
260 #define INT11 0x04
261 #define INT12 0x08
262 #define INT14 0x20
263 #define INT15 0x40
264
265 #define EISADMA 0x00
266 #define CHAN0 0x01
267 #define CHAN5 0x20
268 #define CHAN6 0x40
269 #define CHAN7 0x80