Annotation of sys/dev/ic/aic6360var.h, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: aic6360var.h,v 1.6 2006/06/03 01:51:54 martin Exp $ */
2: /* $NetBSD: aic6360.c,v 1.52 1996/12/10 21:27:51 thorpej Exp $ */
3:
4: /*
5: * Copyright (c) 1994, 1995, 1996 Charles Hannum. All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed by Charles M. Hannum.
18: * 4. The name of the author may not be used to endorse or promote products
19: * derived from this software without specific prior written permission.
20: *
21: * Copyright (c) 1994 Jarle Greipsland
22: * All rights reserved.
23: *
24: * Redistribution and use in source and binary forms, with or without
25: * modification, are permitted provided that the following conditions
26: * are met:
27: * 1. Redistributions of source code must retain the above copyright
28: * notice, this list of conditions and the following disclaimer.
29: * 2. Redistributions in binary form must reproduce the above copyright
30: * notice, this list of conditions and the following disclaimer in the
31: * documentation and/or other materials provided with the distribution.
32: * 3. The name of the author may not be used to endorse or promote products
33: * derived from this software without specific prior written permission.
34: *
35: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
36: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
37: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
39: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
44: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45: * POSSIBILITY OF SUCH DAMAGE.
46: */
47:
48: /*
49: * Acknowledgements: Many of the algorithms used in this driver are
50: * inspired by the work of Julian Elischer (julian@tfs.com) and
51: * Charles Hannum (mycroft@duality.gnu.ai.mit.edu). Thanks a million!
52: */
53:
54: #define AIC_NPORTS 0x20 /* I/O port space used */
55:
56: typedef u_long physaddr;
57: typedef u_long physlen;
58:
59: #ifdef notyet
60: struct aic_dma_seg {
61: physaddr seg_addr;
62: physlen seg_len;
63: };
64:
65: #define AIC_NSEG 16
66: #endif
67:
68: /*
69: * ACB. Holds additional information for each SCSI command Comments: We
70: * need a separate scsi command block because we may need to overwrite it
71: * with a request sense command. Basicly, we refrain from fiddling with
72: * the scsi_xfer struct (except do the expected updating of return values).
73: * We'll generally update: xs->{flags,resid,error,sense,status} and
74: * occasionally xs->retries.
75: */
76: struct aic_acb {
77: struct scsi_generic scsi_cmd;
78: int scsi_cmd_length;
79: u_char *data_addr; /* Saved data pointer */
80: int data_length; /* Residue */
81:
82: u_char target_stat; /* SCSI status byte */
83:
84: #ifdef notdef
85: struct aic_dma_seg dma[AIC_NSEG]; /* Physical addresses+len */
86: #endif
87:
88: TAILQ_ENTRY(aic_acb) chain;
89: struct scsi_xfer *xs; /* SCSI xfer ctrl block from above */
90: int flags;
91: #define ACB_ALLOC 0x01
92: #define ACB_NEXUS 0x02
93: #define ACB_SENSE 0x04
94: #define ACB_ABORT 0x40
95: #define ACB_RESET 0x80
96: int timeout;
97: };
98:
99: /*
100: * Some info about each (possible) target on the SCSI bus. This should
101: * probably have been a "per target+lunit" structure, but we'll leave it at
102: * this for now.
103: */
104: struct aic_tinfo {
105: int cmds; /* #commands processed */
106: int dconns; /* #disconnects */
107: int touts; /* #timeouts */
108: int perrs; /* #parity errors */
109: int senses; /* #request sense commands sent */
110: ushort lubusy; /* What local units/subr. are busy? */
111: u_char flags;
112: #define DO_SYNC 0x01 /* (Re)Negotiate synchronous options */
113: #define DO_WIDE 0x02 /* (Re)Negotiate wide options */
114: u_char period; /* Period suggestion */
115: u_char offset; /* Offset suggestion */
116: u_char width; /* Width suggestion */
117: };
118:
119: struct aic_softc {
120: struct device sc_dev;
121: void *sc_ih;
122:
123: bus_space_tag_t sc_iot;
124: bus_space_handle_t sc_ioh;
125: int sc_irq, sc_drq;
126:
127: struct scsi_link sc_link; /* prototype for subdevs */
128:
129: TAILQ_HEAD(, aic_acb) free_list, ready_list, nexus_list;
130: struct aic_acb *sc_nexus; /* current command */
131: struct aic_acb sc_acb[8];
132: struct aic_tinfo sc_tinfo[8];
133:
134: /* Data about the current nexus (updated for every cmd switch) */
135: u_char *sc_dp; /* Current data pointer */
136: size_t sc_dleft; /* Data bytes left to transfer */
137: u_char *sc_cp; /* Current command pointer */
138: size_t sc_cleft; /* Command bytes left to transfer */
139:
140: /* Adapter state */
141: u_char sc_phase; /* Current bus phase */
142: u_char sc_prevphase; /* Previous bus phase */
143: u_char sc_state; /* State applicable to the adapter */
144: #define AIC_INIT 0
145: #define AIC_IDLE 1
146: #define AIC_SELECTING 2 /* SCSI command is arbiting */
147: #define AIC_RESELECTED 3 /* Has been reselected */
148: #define AIC_CONNECTED 4 /* Actively using the SCSI bus */
149: #define AIC_DISCONNECT 5 /* MSG_DISCONNECT received */
150: #define AIC_CMDCOMPLETE 6 /* MSG_CMDCOMPLETE received */
151: #define AIC_CLEANING 7
152: u_char sc_flags;
153: #define AIC_DROP_MSGIN 0x01 /* Discard all msgs (parity err detected) */
154: #define AIC_ABORTING 0x02 /* Bailing out */
155: #define AIC_DOINGDMA 0x04 /* The FIFO data path is active! */
156: u_char sc_selid; /* Reselection ID */
157:
158: /* Message stuff */
159: u_char sc_msgpriq; /* Messages we want to send */
160: u_char sc_msgoutq; /* Messages sent during last MESSAGE OUT */
161: u_char sc_lastmsg; /* Message last transmitted */
162: u_char sc_currmsg; /* Message currently ready to transmit */
163: #define SEND_DEV_RESET 0x01
164: #define SEND_PARITY_ERROR 0x02
165: #define SEND_INIT_DET_ERR 0x04
166: #define SEND_REJECT 0x08
167: #define SEND_IDENTIFY 0x10
168: #define SEND_ABORT 0x20
169: #define SEND_SDTR 0x40
170: #define SEND_WDTR 0x80
171: #define AIC_MAX_MSG_LEN 8
172: u_char sc_omess[AIC_MAX_MSG_LEN];
173: u_char *sc_omp; /* Outgoing message pointer */
174: u_char sc_imess[AIC_MAX_MSG_LEN];
175: u_char *sc_imp; /* Incoming message pointer */
176:
177: /* Hardware stuff */
178: int sc_initiator; /* Our scsi id */
179: int sc_freq; /* Clock frequency in MHz */
180: int sc_minsync; /* Minimum sync period / 4 */
181: int sc_maxsync; /* Maximum sync period / 4 */
182: };
183:
184: #if AIC_DEBUG
185: #define AIC_SHOWACBS 0x01
186: #define AIC_SHOWINTS 0x02
187: #define AIC_SHOWCMDS 0x04
188: #define AIC_SHOWMISC 0x08
189: #define AIC_SHOWTRACE 0x10
190: #define AIC_SHOWSTART 0x20
191: #define AIC_DOBREAK 0x40
192: #define AIC_PRINT(b, s) do {if ((aic_debug & (b)) != 0) printf s;} while (0)
193: #define AIC_BREAK() \
194: do { if ((aic_debug & AIC_DOBREAK) != 0) Debugger(); } while (0)
195: #define AIC_ASSERT(x) \
196: do { \
197: if (!x) { \
198: printf("%s at line %d: assertion failed\n", \
199: sc->sc_dev.dv_xname, __LINE__); \
200: Debugger(); \
201: } \
202: } while (0)
203: #else
204: #define AIC_PRINT(b, s)
205: #define AIC_BREAK()
206: #define AIC_ASSERT(x)
207: #endif
208:
209: #define AIC_ACBS(s) AIC_PRINT(AIC_SHOWACBS, s)
210: #define AIC_INTS(s) AIC_PRINT(AIC_SHOWINTS, s)
211: #define AIC_CMDS(s) AIC_PRINT(AIC_SHOWCMDS, s)
212: #define AIC_MISC(s) AIC_PRINT(AIC_SHOWMISC, s)
213: #define AIC_TRACE(s) AIC_PRINT(AIC_SHOWTRACE, s)
214: #define AIC_START(s) AIC_PRINT(AIC_SHOWSTART, s)
215:
216: void aicattach(struct aic_softc *);
217: int aic_detach(struct device *, int);
218: int aicintr(void *);
219: int aic_find(bus_space_tag_t, bus_space_handle_t);
CVSweb