siopvar.h revision 1.18.8.1 1 /* $NetBSD: siopvar.h,v 1.18.8.1 2000/11/20 19:58:44 bouyer Exp $ */
2
3 /*
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Van Jacobson of Lawrence Berkeley Laboratory.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)siopvar.h 7.1 (Berkeley) 5/8/90
39 */
40 #ifndef _SIOPVAR_H_
41 #define _SIOPVAR_H_
42
43 /*
44 * The largest single request will be MAXPHYS bytes which will require
45 * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
46 * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
47 * buffer is not page aligned (+1).
48 */
49 #define DMAMAXIO (MAXPHYS/NBPG+1)
50
51 /*
52 * Data Structure for SCRIPTS program
53 */
54 struct siop_ds {
55 long scsi_addr; /* SCSI ID & sync */
56 long idlen; /* Identify message */
57 char *idbuf;
58 long cmdlen; /* SCSI command */
59 char *cmdbuf;
60 long stslen; /* Status */
61 char *stsbuf;
62 long msglen; /* Message */
63 char *msgbuf;
64 long msginlen; /* Message in */
65 char *msginbuf;
66 long extmsglen; /* Extended message in */
67 char *extmsgbuf;
68 long synmsglen; /* Sync transfer request */
69 char *synmsgbuf;
70 struct {
71 long datalen;
72 char *databuf;
73 } chain[DMAMAXIO];
74 };
75
76 /*
77 * ACB. Holds additional information for each SCSI command Comments: We
78 * need a separate scsi command block because we may need to overwrite it
79 * with a request sense command. Basicly, we refrain from fiddling with
80 * the scsi_xfer struct (except do the expected updating of return values).
81 * We'll generally update: xs->{flags,resid,error,sense,status} and
82 * occasionally xs->retries.
83 */
84 struct siop_acb {
85 TAILQ_ENTRY(siop_acb) chain;
86 struct scsipi_xfer *xs; /* SCSI xfer ctrl block from above */
87 int flags; /* Status */
88 #define ACB_FREE 0x00
89 #define ACB_ACTIVE 0x01
90 #define ACB_DONE 0x04
91 #define ACB_CHKSENSE 0x08
92 struct scsi_generic cmd; /* SCSI command block */
93 struct siop_ds ds;
94 void *iob_buf;
95 u_long iob_curbuf;
96 u_long iob_len, iob_curlen;
97 u_char msgout[6];
98 u_char msg[6];
99 u_char stat[1];
100 u_char status;
101 u_char dummy[2];
102 int clen;
103 char *daddr; /* Saved data pointer */
104 int dleft; /* Residue */
105 };
106
107 /*
108 * Some info about each (possible) target on the SCSI bus. This should
109 * probably have been a "per target+lunit" structure, but we'll leave it at
110 * this for now. Is there a way to reliably hook it up to sc->fordriver??
111 */
112 struct siop_tinfo {
113 int cmds; /* #commands processed */
114 int dconns; /* #disconnects */
115 int touts; /* #timeouts */
116 int perrs; /* #parity errors */
117 int senses; /* #request sense commands sent */
118 ushort lubusy; /* What local units/subr. are busy? */
119 u_char flags;
120 u_char period; /* Period suggestion */
121 u_char offset; /* Offset suggestion */
122 } tinfo_t;
123
124 struct siop_softc {
125 struct device sc_dev;
126 struct isr sc_isr;
127
128 u_char sc_istat;
129 u_char sc_dstat;
130 #ifndef ARCH_720
131 u_char sc_sstat0;
132 #endif
133 u_char sc_sstat1;
134 #ifdef ARCH_720
135 u_short sc_sist;
136 #endif
137 u_long sc_intcode;
138 struct scsipi_adapter sc_adapter;
139 struct scsipi_channel sc_channel;
140 u_long sc_scriptspa; /* physical address of scripts */
141 siop_regmap_p sc_siopp; /* the SIOP */
142 u_long sc_active; /* number of active I/O's */
143
144 /* Lists of command blocks */
145 TAILQ_HEAD(acb_list, siop_acb) free_list,
146 ready_list,
147 nexus_list;
148
149 struct siop_acb *sc_nexus; /* current command */
150 #define SIOP_NACB 16
151 struct siop_acb *sc_acb; /* the real command blocks */
152 #ifndef ARCH_720
153 struct siop_tinfo sc_tinfo[8];
154 #else
155 struct siop_tinfo sc_tinfo[16];
156 #endif
157
158 u_short sc_clock_freq;
159 u_char sc_dcntl;
160 u_char sc_ctest7;
161 u_short sc_tcp[4];
162 u_char sc_flags;
163 u_char sc_dien;
164 u_char sc_minsync;
165 #ifndef ARCH_720
166 u_char sc_sien;
167 #else
168 u_short sc_sien;
169 #endif
170 /* one for each target */
171 struct syncpar {
172 u_char state;
173 u_char sxfer;
174 #ifndef ARCH_720
175 u_char sbcl;
176 #else
177 u_char scntl3;
178 #endif
179 } sc_sync[16];
180 };
181
182 /* sc_flags */
183 #define SIOP_INTSOFF 0x80 /* Interrupts turned off */
184 #define SIOP_INTDEFER 0x40 /* Level 6 interrupt has been deferred */
185 #define SIOP_ALIVE 0x01 /* controller initialized */
186 #define SIOP_SELECTED 0x04 /* bus is in selected state. Needed for
187 correct abort procedure. */
188
189 /* negotiation states */
190 #define NEG_WIDE 0 /* Negotiate wide transfers */
191 #define NEG_WAITW 1 /* Waiting for wide negotation response */
192 #define NEG_SYNC 2 /* Negotiate synch transfers */
193 #define NEG_WAITS 3 /* Waiting for synch negoation response */
194 #define NEG_DONE 4 /* Wide and/or sync negotation done */
195
196 #define MSG_CMD_COMPLETE 0x00
197 #define MSG_EXT_MESSAGE 0x01
198 #define MSG_SAVE_DATA_PTR 0x02
199 #define MSG_RESTORE_PTR 0x03
200 #define MSG_DISCONNECT 0x04
201 #define MSG_INIT_DETECT_ERROR 0x05
202 #define MSG_ABORT 0x06
203 #define MSG_REJECT 0x07
204 #define MSG_NOOP 0x08
205 #define MSG_PARITY_ERROR 0x09
206 #define MSG_BUS_DEVICE_RESET 0x0C
207 #define MSG_IDENTIFY 0x80
208 #define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */
209 #define MSG_SYNC_REQ 0x01
210 #define MSG_WIDE_REQ 0x03
211
212 #define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
213 #define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */
214 #define STS_BUSY 0x08
215 #define STS_INTERMED 0x10 /* Intermediate status sent */
216 #define STS_EXT 0x80 /* Extended status valid */
217
218 #ifdef ARCH_720
219 void siopng_minphys __P((struct buf *bp));
220 void siopng_scsipi_request __P((struct scsipi_channel *,
221 scsipi_adapter_req_t, void *));
222 void siopnginitialize __P((struct siop_softc *));
223 void siopngintr __P((struct siop_softc *));
224 void siopng_dump_registers __P((struct siop_softc *));
225 #ifdef DEBUG
226 void siopng_dump __P((struct siop_softc *));
227 #endif
228
229 #else
230
231 void siop_minphys __P((struct buf *bp));
232 void siop_scsipi_request __P((struct scsipi_channel *,
233 scsipi_adapter_req_t, void *));
234 void siopinitialize __P((struct siop_softc *));
235 void siopintr __P((struct siop_softc *));
236 void siop_dump_registers __P((struct siop_softc *));
237 #ifdef DEBUG
238 void siop_dump __P((struct siop_softc *));
239 #endif
240 #endif
241
242 #endif /* _SIOPVAR_H */
243