ahareg.h revision 1.1 1 1.1 mycroft /* $NetBSD: ahareg.h,v 1.1 1997/02/07 17:37:29 mycroft Exp $ */
2 1.1 mycroft
3 1.1 mycroft /*
4 1.1 mycroft * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved.
5 1.1 mycroft *
6 1.1 mycroft * Redistribution and use in source and binary forms, with or without
7 1.1 mycroft * modification, are permitted provided that the following conditions
8 1.1 mycroft * are met:
9 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
10 1.1 mycroft * notice, this list of conditions and the following disclaimer.
11 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
13 1.1 mycroft * documentation and/or other materials provided with the distribution.
14 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
15 1.1 mycroft * must display the following acknowledgement:
16 1.1 mycroft * This product includes software developed by Charles M. Hannum.
17 1.1 mycroft * 4. The name of the author may not be used to endorse or promote products
18 1.1 mycroft * derived from this software without specific prior written permission.
19 1.1 mycroft *
20 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 mycroft */
31 1.1 mycroft
32 1.1 mycroft /*
33 1.1 mycroft * Originally written by Julian Elischer (julian (at) tfs.com)
34 1.1 mycroft * for TRW Financial Systems for use under the MACH(2.5) operating system.
35 1.1 mycroft *
36 1.1 mycroft * TRW Financial Systems, in accordance with their agreement with Carnegie
37 1.1 mycroft * Mellon University, makes this software available to CMU to distribute
38 1.1 mycroft * or use in any manner that they see fit as long as this message is kept with
39 1.1 mycroft * the software. For this reason TFS also grants any other persons or
40 1.1 mycroft * organisations permission to use or modify this software.
41 1.1 mycroft *
42 1.1 mycroft * TFS supplies this software to be publicly redistributed
43 1.1 mycroft * on the understanding that TFS is not responsible for the correct
44 1.1 mycroft * functioning of this software in any circumstances.
45 1.1 mycroft */
46 1.1 mycroft
47 1.1 mycroft typedef u_int8_t physaddr[3];
48 1.1 mycroft typedef u_int8_t physlen[3];
49 1.1 mycroft #define ltophys _lto3b
50 1.1 mycroft #define phystol _3btol
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 AHA_CTRL_PORT 0 /* control (wo) */
56 1.1 mycroft #define AHA_STAT_PORT 0 /* status (ro) */
57 1.1 mycroft #define AHA_CMD_PORT 1 /* command (wo) */
58 1.1 mycroft #define AHA_DATA_PORT 1 /* data (ro) */
59 1.1 mycroft #define AHA_INTR_PORT 2 /* interrupt status (ro) */
60 1.1 mycroft
61 1.1 mycroft /*
62 1.1 mycroft * AHA_CTRL bits
63 1.1 mycroft */
64 1.1 mycroft #define AHA_CTRL_HRST 0x80 /* Hardware reset */
65 1.1 mycroft #define AHA_CTRL_SRST 0x40 /* Software reset */
66 1.1 mycroft #define AHA_CTRL_IRST 0x20 /* Interrupt reset */
67 1.1 mycroft #define AHA_CTRL_SCRST 0x10 /* SCSI bus reset */
68 1.1 mycroft
69 1.1 mycroft /*
70 1.1 mycroft * AHA_STAT bits
71 1.1 mycroft */
72 1.1 mycroft #define AHA_STAT_STST 0x80 /* Self test in Progress */
73 1.1 mycroft #define AHA_STAT_DIAGF 0x40 /* Diagnostic Failure */
74 1.1 mycroft #define AHA_STAT_INIT 0x20 /* Mbx Init required */
75 1.1 mycroft #define AHA_STAT_IDLE 0x10 /* Host Adapter Idle */
76 1.1 mycroft #define AHA_STAT_CDF 0x08 /* cmd/data out port full */
77 1.1 mycroft #define AHA_STAT_DF 0x04 /* Data in port full */
78 1.1 mycroft #define AHA_STAT_INVDCMD 0x01 /* Invalid command */
79 1.1 mycroft
80 1.1 mycroft /*
81 1.1 mycroft * AHA_CMD opcodes
82 1.1 mycroft */
83 1.1 mycroft #define AHA_NOP 0x00 /* No operation */
84 1.1 mycroft #define AHA_MBX_INIT 0x01 /* Mbx initialization */
85 1.1 mycroft #define AHA_START_SCSI 0x02 /* start scsi command */
86 1.1 mycroft #define AHA_INQUIRE_REVISION 0x04 /* Adapter Inquiry */
87 1.1 mycroft #define AHA_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */
88 1.1 mycroft #if 0
89 1.1 mycroft #define AHA_SEL_TIMEOUT_SET 0x06 /* set selection time-out */
90 1.1 mycroft #define AHA_BUS_ON_TIME_SET 0x07 /* set bus-on time */
91 1.1 mycroft #define AHA_BUS_OFF_TIME_SET 0x08 /* set bus-off time */
92 1.1 mycroft #define AHA_SPEED_SET 0x09 /* set transfer speed */
93 1.1 mycroft #endif
94 1.1 mycroft #define AHA_INQUIRE_DEVICES 0x0a /* return installed devices 0-7 */
95 1.1 mycroft #define AHA_INQUIRE_CONFIG 0x0b /* return configuration data */
96 1.1 mycroft #define AHA_TARGET_EN 0x0c /* enable target mode */
97 1.1 mycroft #define AHA_INQUIRE_SETUP 0x0d /* return setup data */
98 1.1 mycroft #define AHA_ECHO 0x1e /* Echo command data */
99 1.1 mycroft #define AHA_INQUIRE_DEVICES_2 0x23 /* return installed devices 8-15 */
100 1.1 mycroft #define AHA_EXT_BIOS 0x28 /* return extended bios info */
101 1.1 mycroft #define AHA_MBX_ENABLE 0x29 /* enable mail box interface */
102 1.1 mycroft
103 1.1 mycroft /*
104 1.1 mycroft * AHA_INTR bits
105 1.1 mycroft */
106 1.1 mycroft #define AHA_INTR_ANYINTR 0x80 /* Any interrupt */
107 1.1 mycroft #define AHA_INTR_SCRD 0x08 /* SCSI reset detected */
108 1.1 mycroft #define AHA_INTR_HACC 0x04 /* Command complete */
109 1.1 mycroft #define AHA_INTR_MBOA 0x02 /* MBX out empty */
110 1.1 mycroft #define AHA_INTR_MBIF 0x01 /* MBX in full */
111 1.1 mycroft
112 1.1 mycroft struct aha_mbx_out {
113 1.1 mycroft u_char cmd;
114 1.1 mycroft physaddr ccb_addr;
115 1.1 mycroft };
116 1.1 mycroft
117 1.1 mycroft struct aha_mbx_in {
118 1.1 mycroft u_char stat;
119 1.1 mycroft physaddr ccb_addr;
120 1.1 mycroft };
121 1.1 mycroft
122 1.1 mycroft /*
123 1.1 mycroft * mbo.cmd values
124 1.1 mycroft */
125 1.1 mycroft #define AHA_MBO_FREE 0x0 /* MBO entry is free */
126 1.1 mycroft #define AHA_MBO_START 0x1 /* MBO activate entry */
127 1.1 mycroft #define AHA_MBO_ABORT 0x2 /* MBO abort entry */
128 1.1 mycroft
129 1.1 mycroft /*
130 1.1 mycroft * mbi.stat values
131 1.1 mycroft */
132 1.1 mycroft #define AHA_MBI_FREE 0x0 /* MBI entry is free */
133 1.1 mycroft #define AHA_MBI_OK 0x1 /* completed without error */
134 1.1 mycroft #define AHA_MBI_ABORT 0x2 /* aborted ccb */
135 1.1 mycroft #define AHA_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */
136 1.1 mycroft #define AHA_MBI_ERROR 0x4 /* Completed with error */
137 1.1 mycroft
138 1.1 mycroft /* FOR OLD VERSIONS OF THE !%$@ this may have to be 16 (yuk) */
139 1.1 mycroft #define AHA_NSEG 17 /* Number of scatter gather segments <= 16 */
140 1.1 mycroft /* allow 64 K i/o (min) */
141 1.1 mycroft
142 1.1 mycroft struct aha_scat_gath {
143 1.1 mycroft physlen seg_len;
144 1.1 mycroft physaddr seg_addr;
145 1.1 mycroft };
146 1.1 mycroft
147 1.1 mycroft struct aha_ccb {
148 1.1 mycroft u_char opcode;
149 1.1 mycroft u_char lun:3;
150 1.1 mycroft u_char data_in:1; /* must be 0 */
151 1.1 mycroft u_char data_out:1; /* must be 0 */
152 1.1 mycroft u_char target:3;
153 1.1 mycroft u_char scsi_cmd_length;
154 1.1 mycroft u_char req_sense_length;
155 1.1 mycroft physlen data_length;
156 1.1 mycroft physaddr data_addr;
157 1.1 mycroft physaddr link_addr;
158 1.1 mycroft u_char link_id;
159 1.1 mycroft u_char host_stat;
160 1.1 mycroft u_char target_stat;
161 1.1 mycroft u_char reserved[2];
162 1.1 mycroft struct scsi_generic scsi_cmd;
163 1.1 mycroft struct scsi_sense_data scsi_sense;
164 1.1 mycroft struct aha_scat_gath scat_gath[AHA_NSEG];
165 1.1 mycroft /*----------------------------------------------------------------*/
166 1.1 mycroft TAILQ_ENTRY(aha_ccb) chain;
167 1.1 mycroft struct aha_ccb *nexthash;
168 1.1 mycroft long hashkey;
169 1.1 mycroft struct scsi_xfer *xs; /* the scsi_xfer for this cmd */
170 1.1 mycroft int flags;
171 1.1 mycroft #define CCB_ALLOC 0x01
172 1.1 mycroft #define CCB_ABORT 0x02
173 1.1 mycroft #ifdef AHADIAG
174 1.1 mycroft #define CCB_SENDING 0x04
175 1.1 mycroft #endif
176 1.1 mycroft int timeout;
177 1.1 mycroft };
178 1.1 mycroft
179 1.1 mycroft /*
180 1.1 mycroft * opcode fields
181 1.1 mycroft */
182 1.1 mycroft #define AHA_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */
183 1.1 mycroft #define AHA_TARGET_CCB 0x01 /* SCSI Target CCB */
184 1.1 mycroft #define AHA_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scatter gather */
185 1.1 mycroft #define AHA_RESET_CCB 0x81 /* SCSI Bus reset */
186 1.1 mycroft
187 1.1 mycroft /*
188 1.1 mycroft * aha_ccb.host_stat values
189 1.1 mycroft */
190 1.1 mycroft #define AHA_OK 0x00 /* cmd ok */
191 1.1 mycroft #define AHA_LINK_OK 0x0a /* Link cmd ok */
192 1.1 mycroft #define AHA_LINK_IT 0x0b /* Link cmd ok + int */
193 1.1 mycroft #define AHA_SEL_TIMEOUT 0x11 /* Selection time out */
194 1.1 mycroft #define AHA_OVER_UNDER 0x12 /* Data over/under run */
195 1.1 mycroft #define AHA_BUS_FREE 0x13 /* Bus dropped at unexpected time */
196 1.1 mycroft #define AHA_INV_BUS 0x14 /* Invalid bus phase/sequence */
197 1.1 mycroft #define AHA_BAD_MBO 0x15 /* Incorrect MBO cmd */
198 1.1 mycroft #define AHA_BAD_CCB 0x16 /* Incorrect ccb opcode */
199 1.1 mycroft #define AHA_BAD_LINK 0x17 /* Not same values of LUN for links */
200 1.1 mycroft #define AHA_INV_TARGET 0x18 /* Invalid target direction */
201 1.1 mycroft #define AHA_CCB_DUP 0x19 /* Duplicate CCB received */
202 1.1 mycroft #define AHA_INV_CCB 0x1a /* Invalid CCB or segment list */
203 1.1 mycroft
204 1.1 mycroft struct aha_revision {
205 1.1 mycroft struct {
206 1.1 mycroft u_char opcode;
207 1.1 mycroft } cmd;
208 1.1 mycroft struct {
209 1.1 mycroft u_char boardid; /* type of board */
210 1.1 mycroft /* 0x31 = AHA-1540 */
211 1.1 mycroft /* 0x41 = AHA-1540A/1542A/1542B */
212 1.1 mycroft /* 0x42 = AHA-1640 */
213 1.1 mycroft /* 0x43 = AHA-1542C */
214 1.1 mycroft /* 0x44 = AHA-1542CF */
215 1.1 mycroft /* 0x45 = AHA-1542CF, BIOS v2.01 */
216 1.1 mycroft /* 0x46 = AHA-1542CP */
217 1.1 mycroft u_char spec_opts; /* special options ID */
218 1.1 mycroft /* 0x41 = Board is standard model */
219 1.1 mycroft u_char revision_1; /* firmware revision [0-9A-Z] */
220 1.1 mycroft u_char revision_2; /* firmware revision [0-9A-Z] */
221 1.1 mycroft } reply;
222 1.1 mycroft };
223 1.1 mycroft
224 1.1 mycroft struct aha_extbios {
225 1.1 mycroft struct {
226 1.1 mycroft u_char opcode;
227 1.1 mycroft } cmd;
228 1.1 mycroft struct {
229 1.1 mycroft u_char flags; /* Bit 3 == 1 extended bios enabled */
230 1.1 mycroft u_char mailboxlock; /* mail box lock code to unlock it */
231 1.1 mycroft } reply;
232 1.1 mycroft };
233 1.1 mycroft
234 1.1 mycroft struct aha_toggle {
235 1.1 mycroft struct {
236 1.1 mycroft u_char opcode;
237 1.1 mycroft u_char enable;
238 1.1 mycroft } cmd;
239 1.1 mycroft };
240 1.1 mycroft
241 1.1 mycroft struct aha_config {
242 1.1 mycroft struct {
243 1.1 mycroft u_char opcode;
244 1.1 mycroft } cmd;
245 1.1 mycroft struct {
246 1.1 mycroft u_char chan;
247 1.1 mycroft u_char intr;
248 1.1 mycroft u_char scsi_dev:3;
249 1.1 mycroft u_char :5;
250 1.1 mycroft } reply;
251 1.1 mycroft };
252 1.1 mycroft
253 1.1 mycroft struct aha_mailbox {
254 1.1 mycroft struct {
255 1.1 mycroft u_char opcode;
256 1.1 mycroft u_char nmbx;
257 1.1 mycroft physaddr addr;
258 1.1 mycroft } cmd;
259 1.1 mycroft };
260 1.1 mycroft
261 1.1 mycroft struct aha_unlock {
262 1.1 mycroft struct {
263 1.1 mycroft u_char opcode;
264 1.1 mycroft u_char junk;
265 1.1 mycroft u_char magic;
266 1.1 mycroft } cmd;
267 1.1 mycroft };
268 1.1 mycroft
269 1.1 mycroft struct aha_devices {
270 1.1 mycroft struct {
271 1.1 mycroft u_char opcode;
272 1.1 mycroft } cmd;
273 1.1 mycroft struct {
274 1.1 mycroft u_char junk[8];
275 1.1 mycroft } reply;
276 1.1 mycroft };
277 1.1 mycroft
278 1.1 mycroft struct aha_setup {
279 1.1 mycroft struct {
280 1.1 mycroft u_char opcode;
281 1.1 mycroft u_char len;
282 1.1 mycroft } cmd;
283 1.1 mycroft struct {
284 1.1 mycroft u_char sync_neg:1;
285 1.1 mycroft u_char parity:1;
286 1.1 mycroft u_char :6;
287 1.1 mycroft u_char speed;
288 1.1 mycroft u_char bus_on;
289 1.1 mycroft u_char bus_off;
290 1.1 mycroft u_char num_mbx;
291 1.1 mycroft u_char mbx[3];
292 1.1 mycroft struct {
293 1.1 mycroft u_char offset:4;
294 1.1 mycroft u_char period:3;
295 1.1 mycroft u_char valid:1;
296 1.1 mycroft } sync[8];
297 1.1 mycroft u_char disc_sts;
298 1.1 mycroft } reply;
299 1.1 mycroft };
300 1.1 mycroft
301 1.1 mycroft #define INT9 0x01
302 1.1 mycroft #define INT10 0x02
303 1.1 mycroft #define INT11 0x04
304 1.1 mycroft #define INT12 0x08
305 1.1 mycroft #define INT14 0x20
306 1.1 mycroft #define INT15 0x40
307 1.1 mycroft
308 1.1 mycroft #define EISADMA 0x00
309 1.1 mycroft #define CHAN0 0x01
310 1.1 mycroft #define CHAN5 0x20
311 1.1 mycroft #define CHAN6 0x40
312 1.1 mycroft #define CHAN7 0x80
313