bhareg.h revision 1.5 1 1.5 thorpej /* $NetBSD: bhareg.h,v 1.5 1996/12/20 21:35:11 thorpej Exp $ */
2 1.2 mycroft
3 1.2 mycroft /*
4 1.2 mycroft * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
5 1.2 mycroft *
6 1.2 mycroft * Redistribution and use in source and binary forms, with or without
7 1.2 mycroft * modification, are permitted provided that the following conditions
8 1.2 mycroft * are met:
9 1.2 mycroft * 1. Redistributions of source code must retain the above copyright
10 1.2 mycroft * notice, this list of conditions and the following disclaimer.
11 1.2 mycroft * 2. Redistributions in binary form must reproduce the above copyright
12 1.2 mycroft * notice, this list of conditions and the following disclaimer in the
13 1.2 mycroft * documentation and/or other materials provided with the distribution.
14 1.2 mycroft * 3. All advertising materials mentioning features or use of this software
15 1.2 mycroft * must display the following acknowledgement:
16 1.2 mycroft * This product includes software developed by Charles M. Hannum.
17 1.2 mycroft * 4. The name of the author may not be used to endorse or promote products
18 1.2 mycroft * derived from this software without specific prior written permission.
19 1.2 mycroft *
20 1.2 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.2 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.2 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.2 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.2 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.2 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.2 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.2 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.2 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.2 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.2 mycroft */
31 1.2 mycroft
32 1.2 mycroft /*
33 1.2 mycroft * Originally written by Julian Elischer (julian (at) tfs.com)
34 1.2 mycroft * for TRW Financial Systems for use under the MACH(2.5) operating system.
35 1.2 mycroft *
36 1.2 mycroft * TRW Financial Systems, in accordance with their agreement with Carnegie
37 1.2 mycroft * Mellon University, makes this software available to CMU to distribute
38 1.2 mycroft * or use in any manner that they see fit as long as this message is kept with
39 1.2 mycroft * the software. For this reason TFS also grants any other persons or
40 1.2 mycroft * organisations permission to use or modify this software.
41 1.2 mycroft *
42 1.2 mycroft * TFS supplies this software to be publicly redistributed
43 1.2 mycroft * on the understanding that TFS is not responsible for the correct
44 1.2 mycroft * functioning of this software in any circumstances.
45 1.2 mycroft */
46 1.2 mycroft
47 1.1 mycroft typedef u_int8_t physaddr[4];
48 1.1 mycroft typedef u_int8_t physlen[4];
49 1.1 mycroft #define ltophys _lto4l
50 1.1 mycroft #define phystol _4ltol
51 1.1 mycroft
52 1.1 mycroft /*
53 1.1 mycroft * I/O port offsets
54 1.1 mycroft */
55 1.1 mycroft #define BHA_CTRL_PORT 0 /* control (wo) */
56 1.1 mycroft #define BHA_STAT_PORT 0 /* status (ro) */
57 1.1 mycroft #define BHA_CMD_PORT 1 /* command (wo) */
58 1.1 mycroft #define BHA_DATA_PORT 1 /* data (ro) */
59 1.1 mycroft #define BHA_INTR_PORT 2 /* interrupt status (ro) */
60 1.3 jonathan #define BHA_EXTGEOM_PORT 2 /* extended geometry (ro) */
61 1.1 mycroft
62 1.1 mycroft /*
63 1.1 mycroft * BHA_CTRL bits
64 1.1 mycroft */
65 1.1 mycroft #define BHA_CTRL_HRST 0x80 /* Hardware reset */
66 1.1 mycroft #define BHA_CTRL_SRST 0x40 /* Software reset */
67 1.1 mycroft #define BHA_CTRL_IRST 0x20 /* Interrupt reset */
68 1.1 mycroft #define BHA_CTRL_SCRST 0x10 /* SCSI bus reset */
69 1.1 mycroft
70 1.1 mycroft /*
71 1.1 mycroft * BHA_STAT bits
72 1.1 mycroft */
73 1.1 mycroft #define BHA_STAT_STST 0x80 /* Self test in Progress */
74 1.1 mycroft #define BHA_STAT_DIAGF 0x40 /* Diagnostic Failure */
75 1.1 mycroft #define BHA_STAT_INIT 0x20 /* Mbx Init required */
76 1.1 mycroft #define BHA_STAT_IDLE 0x10 /* Host Adapter Idle */
77 1.1 mycroft #define BHA_STAT_CDF 0x08 /* cmd/data out port full */
78 1.1 mycroft #define BHA_STAT_DF 0x04 /* Data in port full */
79 1.1 mycroft #define BHA_STAT_INVDCMD 0x01 /* Invalid command */
80 1.1 mycroft
81 1.1 mycroft /*
82 1.1 mycroft * BHA_CMD opcodes
83 1.1 mycroft */
84 1.1 mycroft #define BHA_NOP 0x00 /* No operation */
85 1.1 mycroft #define BHA_MBX_INIT 0x01 /* Mbx initialization */
86 1.1 mycroft #define BHA_START_SCSI 0x02 /* start scsi command */
87 1.1 mycroft #define BHA_INQUIRE_REVISION 0x04 /* Adapter Inquiry */
88 1.1 mycroft #define BHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
89 1.1 mycroft #if 0
90 1.1 mycroft #define BHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
91 1.1 mycroft #define BHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */
92 1.1 mycroft #define BHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
93 1.1 mycroft #define BHA_SPEED_SET 0x09 /* set transfer speed */
94 1.1 mycroft #endif
95 1.1 mycroft #define BHA_INQUIRE_DEVICES 0x0a /* return installed devices 0-7 */
96 1.1 mycroft #define BHA_INQUIRE_CONFIG 0x0b /* return configuration data */
97 1.1 mycroft #define BHA_TARGET_EN 0x0c /* enable target mode */
98 1.1 mycroft #define BHA_INQUIRE_SETUP 0x0d /* return setup data */
99 1.1 mycroft #define BHA_ECHO 0x1e /* Echo command data */
100 1.1 mycroft #define BHA_INQUIRE_DEVICES_2 0x23 /* return installed devices 8-15 */
101 1.1 mycroft #define BHA_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */
102 1.1 mycroft #define BHA_INQUIRE_REVISION_3 0x84 /* Get 3rd firmware version byte */
103 1.1 mycroft #define BHA_INQUIRE_REVISION_4 0x85 /* Get 4th firmware version byte */
104 1.1 mycroft #define BHA_INQUIRE_MODEL 0x8b /* Get hardware ID and revision */
105 1.1 mycroft #define BHA_INQUIRE_PERIOD 0x8c /* Get synchronous period */
106 1.1 mycroft #define BHA_INQUIRE_EXTENDED 0x8d /* Adapter Setup Inquiry */
107 1.1 mycroft #define BHA_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */
108 1.3 jonathan #define BHA_MODIFY_IOPORT 0x95 /* change or disable I/O port */
109 1.3 jonathan
110 1.1 mycroft
111 1.1 mycroft /*
112 1.1 mycroft * BHA_INTR bits
113 1.1 mycroft */
114 1.1 mycroft #define BHA_INTR_ANYINTR 0x80 /* Any interrupt */
115 1.1 mycroft #define BHA_INTR_SCRD 0x08 /* SCSI reset detected */
116 1.1 mycroft #define BHA_INTR_HACC 0x04 /* Command complete */
117 1.1 mycroft #define BHA_INTR_MBOA 0x02 /* MBX out empty */
118 1.1 mycroft #define BHA_INTR_MBIF 0x01 /* MBX in full */
119 1.1 mycroft
120 1.1 mycroft struct bha_mbx_out {
121 1.1 mycroft physaddr ccb_addr;
122 1.1 mycroft u_char dummy[3];
123 1.1 mycroft u_char cmd;
124 1.1 mycroft };
125 1.1 mycroft
126 1.1 mycroft struct bha_mbx_in {
127 1.1 mycroft physaddr ccb_addr;
128 1.1 mycroft u_char dummy[3];
129 1.1 mycroft u_char stat;
130 1.1 mycroft };
131 1.1 mycroft
132 1.1 mycroft /*
133 1.1 mycroft * mbo.cmd values
134 1.1 mycroft */
135 1.1 mycroft #define BHA_MBO_FREE 0x0 /* MBO entry is free */
136 1.1 mycroft #define BHA_MBO_START 0x1 /* MBO activate entry */
137 1.1 mycroft #define BHA_MBO_ABORT 0x2 /* MBO abort entry */
138 1.1 mycroft
139 1.1 mycroft /*
140 1.1 mycroft * mbi.stat values
141 1.1 mycroft */
142 1.1 mycroft #define BHA_MBI_FREE 0x0 /* MBI entry is free */
143 1.1 mycroft #define BHA_MBI_OK 0x1 /* completed without error */
144 1.1 mycroft #define BHA_MBI_ABORT 0x2 /* aborted ccb */
145 1.1 mycroft #define BHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
146 1.1 mycroft #define BHA_MBI_ERROR 0x4 /* Completed with error */
147 1.1 mycroft
148 1.1 mycroft #if defined(BIG_DMA)
149 1.1 mycroft WARNING...THIS WON'T WORK(won't fit on 1 page)
150 1.1 mycroft #if 0
151 1.1 mycroft #define BHA_NSEG 2048 /* Number of scatter gather segments - to much vm */
152 1.1 mycroft #endif
153 1.1 mycroft #define BHA_NSEG 128
154 1.1 mycroft #else
155 1.1 mycroft #define BHA_NSEG 33
156 1.1 mycroft #endif /* BIG_DMA */
157 1.1 mycroft
158 1.1 mycroft struct bha_scat_gath {
159 1.1 mycroft physlen seg_len;
160 1.1 mycroft physaddr seg_addr;
161 1.1 mycroft };
162 1.1 mycroft
163 1.1 mycroft struct bha_ccb {
164 1.1 mycroft u_char opcode;
165 1.1 mycroft u_char:3, data_in:1, data_out:1,:3;
166 1.1 mycroft u_char scsi_cmd_length;
167 1.1 mycroft u_char req_sense_length;
168 1.1 mycroft /*------------------------------------longword boundary */
169 1.1 mycroft physlen data_length;
170 1.1 mycroft /*------------------------------------longword boundary */
171 1.1 mycroft physaddr data_addr;
172 1.1 mycroft /*------------------------------------longword boundary */
173 1.1 mycroft u_char dummy1[2];
174 1.1 mycroft u_char host_stat;
175 1.1 mycroft u_char target_stat;
176 1.1 mycroft /*------------------------------------longword boundary */
177 1.1 mycroft u_char target;
178 1.1 mycroft u_char lun;
179 1.1 mycroft struct scsi_generic scsi_cmd;
180 1.1 mycroft u_char dummy2[1];
181 1.1 mycroft u_char link_id;
182 1.1 mycroft /*------------------------------------longword boundary */
183 1.1 mycroft physaddr link_addr;
184 1.1 mycroft /*------------------------------------longword boundary */
185 1.1 mycroft physaddr sense_ptr;
186 1.1 mycroft /*-----end of HW fields-----------------------longword boundary */
187 1.1 mycroft struct scsi_sense_data scsi_sense;
188 1.1 mycroft /*------------------------------------longword boundary */
189 1.1 mycroft struct bha_scat_gath scat_gath[BHA_NSEG];
190 1.1 mycroft /*------------------------------------longword boundary */
191 1.1 mycroft TAILQ_ENTRY(bha_ccb) chain;
192 1.1 mycroft struct bha_ccb *nexthash;
193 1.1 mycroft long hashkey;
194 1.1 mycroft struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
195 1.1 mycroft int flags;
196 1.1 mycroft #define CCB_ALLOC 0x01
197 1.1 mycroft #define CCB_ABORT 0x02
198 1.1 mycroft #ifdef BHADIAG
199 1.1 mycroft #define CCB_SENDING 0x04
200 1.1 mycroft #endif
201 1.1 mycroft int timeout;
202 1.1 mycroft };
203 1.1 mycroft
204 1.1 mycroft /*
205 1.1 mycroft * opcode fields
206 1.1 mycroft */
207 1.1 mycroft #define BHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
208 1.1 mycroft #define BHA_TARGET_CCB 0x01 /* SCSI Target CCB */
209 1.1 mycroft #define BHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */
210 1.1 mycroft #define BHA_RESET_CCB 0x81 /* SCSI Bus reset */
211 1.1 mycroft
212 1.1 mycroft /*
213 1.1 mycroft * bha_ccb.host_stat values
214 1.1 mycroft */
215 1.1 mycroft #define BHA_OK 0x00 /* cmd ok */
216 1.1 mycroft #define BHA_LINK_OK 0x0a /* Link cmd ok */
217 1.1 mycroft #define BHA_LINK_IT 0x0b /* Link cmd ok + int */
218 1.1 mycroft #define BHA_SEL_TIMEOUT 0x11 /* Selection time out */
219 1.1 mycroft #define BHA_OVER_UNDER 0x12 /* Data over/under run */
220 1.1 mycroft #define BHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */
221 1.1 mycroft #define BHA_INV_BUS 0x14 /* Invalid bus phase/sequence */
222 1.1 mycroft #define BHA_BAD_MBO 0x15 /* Incorrect MBO cmd */
223 1.1 mycroft #define BHA_BAD_CCB 0x16 /* Incorrect ccb opcode */
224 1.1 mycroft #define BHA_BAD_LINK 0x17 /* Not same values of LUN for links */
225 1.1 mycroft #define BHA_INV_TARGET 0x18 /* Invalid target direction */
226 1.1 mycroft #define BHA_CCB_DUP 0x19 /* Duplicate CCB received */
227 1.1 mycroft #define BHA_INV_CCB 0x1a /* Invalid CCB or segment list */
228 1.1 mycroft
229 1.1 mycroft struct bha_extended_inquire {
230 1.1 mycroft struct {
231 1.1 mycroft u_char opcode;
232 1.1 mycroft u_char len;
233 1.1 mycroft } cmd;
234 1.1 mycroft struct {
235 1.1 mycroft u_char bus_type; /* Type of bus connected to */
236 1.1 mycroft #define BHA_BUS_TYPE_24BIT 'A' /* ISA bus */
237 1.1 mycroft #define BHA_BUS_TYPE_32BIT 'E' /* EISA/VLB/PCI bus */
238 1.1 mycroft #define BHA_BUS_TYPE_MCA 'M' /* MicroChannel bus */
239 1.1 mycroft u_char bios_address; /* Address of adapter BIOS */
240 1.4 jonathan u_short sg_limit;
241 1.4 jonathan u_char mbox_count;
242 1.4 jonathan u_char mbox_baseaddr[4]; /* packed/unaligned uint_32_t */
243 1.4 jonathan u_char intrflags;
244 1.4 jonathan #define BHA_INTR_LEVEL 0x40 /* bit 6: level-sensitive interrupt */
245 1.4 jonathan u_char firmware_level[3]; /* last 3 digits of firmware rev */
246 1.4 jonathan u_char scsi_flags; /* supported SCSI features */
247 1.4 jonathan #define BHA_SCSI_WIDE 0x01
248 1.4 jonathan #define BHA_SCSI_DIFFERENTIAL 0x02
249 1.4 jonathan #define BHA_SCSI_AUTOCONF 0x04
250 1.4 jonathan #define BHA_SCSI_ULTRA 0x08
251 1.4 jonathan #define BHA_SCSI_TERMINATION 0x10
252 1.1 mycroft } reply;
253 1.1 mycroft };
254 1.1 mycroft
255 1.1 mycroft struct bha_config {
256 1.1 mycroft struct {
257 1.1 mycroft u_char opcode;
258 1.1 mycroft } cmd;
259 1.1 mycroft struct {
260 1.1 mycroft u_char chan;
261 1.1 mycroft u_char intr;
262 1.1 mycroft u_char scsi_dev:3;
263 1.1 mycroft u_char :5;
264 1.1 mycroft } reply;
265 1.1 mycroft };
266 1.1 mycroft
267 1.1 mycroft struct bha_toggle {
268 1.1 mycroft struct {
269 1.1 mycroft u_char opcode;
270 1.1 mycroft u_char enable;
271 1.1 mycroft } cmd;
272 1.1 mycroft };
273 1.1 mycroft
274 1.1 mycroft struct bha_mailbox {
275 1.1 mycroft struct {
276 1.1 mycroft u_char opcode;
277 1.1 mycroft u_char nmbx;
278 1.1 mycroft physaddr addr;
279 1.1 mycroft } cmd;
280 1.1 mycroft };
281 1.1 mycroft
282 1.1 mycroft struct bha_model {
283 1.1 mycroft struct {
284 1.1 mycroft u_char opcode;
285 1.1 mycroft u_char len;
286 1.1 mycroft } cmd;
287 1.1 mycroft struct {
288 1.1 mycroft u_char id[4]; /* i.e bt742a -> '7','4','2','A' */
289 1.1 mycroft u_char version[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */
290 1.1 mycroft } reply;
291 1.1 mycroft };
292 1.1 mycroft
293 1.1 mycroft struct bha_revision {
294 1.1 mycroft struct {
295 1.1 mycroft u_char opcode;
296 1.1 mycroft } cmd;
297 1.1 mycroft struct {
298 1.1 mycroft u_char board_type;
299 1.1 mycroft u_char custom_feature;
300 1.1 mycroft char firm_revision;
301 1.1 mycroft u_char firm_version;
302 1.1 mycroft } reply;
303 1.1 mycroft };
304 1.1 mycroft
305 1.1 mycroft struct bha_digit {
306 1.1 mycroft struct {
307 1.1 mycroft u_char opcode;
308 1.1 mycroft } cmd;
309 1.1 mycroft struct {
310 1.1 mycroft u_char digit;
311 1.1 mycroft } reply;
312 1.1 mycroft };
313 1.1 mycroft
314 1.1 mycroft struct bha_devices {
315 1.1 mycroft struct {
316 1.1 mycroft u_char opcode;
317 1.1 mycroft } cmd;
318 1.1 mycroft struct {
319 1.1 mycroft u_char junk[8];
320 1.1 mycroft } reply;
321 1.1 mycroft };
322 1.1 mycroft
323 1.5 thorpej struct bha_sync {
324 1.5 thorpej u_char offset:4;
325 1.5 thorpej u_char period:3;
326 1.5 thorpej u_char valid:1;
327 1.5 thorpej };
328 1.5 thorpej
329 1.5 thorpej struct bha_setup_reply {
330 1.5 thorpej u_char sync_neg:1;
331 1.5 thorpej u_char parity:1;
332 1.5 thorpej u_char :6;
333 1.5 thorpej u_char speed;
334 1.5 thorpej u_char bus_on;
335 1.5 thorpej u_char bus_off;
336 1.5 thorpej u_char num_mbx;
337 1.5 thorpej u_char mbx[3]; /*XXX */
338 1.5 thorpej /* doesn't make sense with 32bit addresses */
339 1.5 thorpej struct bha_sync sync[8];
340 1.5 thorpej u_char disc_sts;
341 1.5 thorpej };
342 1.5 thorpej
343 1.5 thorpej /* additional reply data supplied by wide controlers */
344 1.5 thorpej struct bus_setup_reply_wide {
345 1.5 thorpej u_char pad[5]; /* ??? */
346 1.5 thorpej struct bha_sync sync[8];
347 1.5 thorpej u_char disc_sts;
348 1.5 thorpej };
349 1.5 thorpej
350 1.1 mycroft struct bha_setup {
351 1.1 mycroft struct {
352 1.1 mycroft u_char opcode;
353 1.1 mycroft u_char len;
354 1.1 mycroft } cmd;
355 1.5 thorpej struct bha_setup_reply reply;
356 1.5 thorpej struct bus_setup_reply_wide reply_w; /* for wide controllers */
357 1.5 thorpej };
358 1.5 thorpej
359 1.5 thorpej struct bha_period_reply {
360 1.5 thorpej u_char period[8];
361 1.1 mycroft };
362 1.1 mycroft
363 1.1 mycroft struct bha_period {
364 1.1 mycroft struct {
365 1.1 mycroft u_char opcode;
366 1.1 mycroft u_char len;
367 1.1 mycroft } cmd;
368 1.5 thorpej struct bha_period_reply reply;
369 1.5 thorpej struct bha_period_reply reply_w; /* for wide controllers */
370 1.1 mycroft };
371 1.3 jonathan
372 1.3 jonathan struct bha_isadisable {
373 1.3 jonathan struct {
374 1.3 jonathan u_char opcode;
375 1.3 jonathan u_char modifier;
376 1.3 jonathan } cmd;
377 1.3 jonathan };
378 1.3 jonathan
379 1.3 jonathan /*
380 1.3 jonathan * bha_isadisable.modifier parameters
381 1.3 jonathan */
382 1.3 jonathan #define BHA_IOMODIFY_330 0x00
383 1.3 jonathan #define BHA_IOMODIFY_334 0x01
384 1.3 jonathan #define BHA_IOMODIFY_DISABLE1 0x06
385 1.3 jonathan #define BHA_IOMODIFY_DISABLE2 0x07
386 1.1 mycroft
387 1.1 mycroft #define INT9 0x01
388 1.1 mycroft #define INT10 0x02
389 1.1 mycroft #define INT11 0x04
390 1.1 mycroft #define INT12 0x08
391 1.1 mycroft #define INT14 0x20
392 1.1 mycroft #define INT15 0x40
393 1.1 mycroft
394 1.1 mycroft #define EISADMA 0x00
395 1.1 mycroft #define CHAN0 0x01
396 1.1 mycroft #define CHAN5 0x20
397 1.1 mycroft #define CHAN6 0x40
398 1.1 mycroft #define CHAN7 0x80
399