siopvar.h revision 1.11 1 /* $NetBSD: siopvar.h,v 1.11 1995/08/18 15:28:14 chopps 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 /*00*/ long scsi_addr; /* SCSI ID & sync */
56 /*04*/ long idlen; /* Identify message */
57 /*08*/ char *idbuf;
58 /*0c*/ long cmdlen; /* SCSI command */
59 /*10*/ char *cmdbuf;
60 /*14*/ long stslen; /* Status */
61 /*18*/ char *stsbuf;
62 /*1c*/ long msglen; /* Message */
63 /*20*/ char *msgbuf;
64 /*24*/ long msginlen; /* Message in */
65 /*28*/ char *msginbuf;
66 /*2c*/ long extmsglen; /* Extended message in */
67 /*30*/ char *extmsgbuf;
68 /*34*/ long synmsglen; /* Sync transfer request */
69 /*38*/ char *synmsgbuf;
70 struct {
71 /*3c*/ long datalen;
72 /*40*/ 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 /*00*/ TAILQ_ENTRY(siop_acb) chain;
86 /*08*/ struct scsi_xfer *xs; /* SCSI xfer ctrl block from above */
87 /*0c*/ int flags; /* Status */
88 #define ACB_FREE 0x00
89 #define ACB_ACTIVE 0x01
90 #define ACB_DONE 0x04
91 #define ACB_CHKSENSE 0x08
92 /*10*/ struct scsi_generic cmd; /* SCSI command block */
93 /*1c*/ struct siop_ds ds;
94 /*a0*/ void *iob_buf;
95 /*a4*/ u_long iob_curbuf;
96 /*a8*/ u_long iob_len, iob_curlen;
97 /*b0*/ u_char msgout[6];
98 /*b6*/ u_char msg[6];
99 /*bc*/ u_char stat[1];
100 /*bd*/ u_char status;
101 /*be*/ u_char dummy[2];
102 /*c0*/ int clen;
103 /*c4*/ char *daddr; /* Saved data pointer */
104 /*c8*/ 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 /*00*/ struct device sc_dev;
126 /*??*/ struct isr sc_isr;
127
128 /*38*/ u_char sc_istat;
129 /*39*/ u_char sc_dstat;
130 /*3a*/ u_char sc_sstat0;
131 /*3b*/ u_char sc_sstat1;
132 /*3c*/ u_long sc_intcode;
133 /*40*/ struct scsi_link sc_link; /* proto for sub devices */
134 /*58*/ u_long sc_scriptspa; /* physical address of scripts */
135 /*5c*/ siop_regmap_p sc_siopp; /* the SIOP */
136 /*60*/ u_long sc_active; /* number of active I/O's */
137
138 /* Lists of command blocks */
139 /*64*/ TAILQ_HEAD(acb_list, siop_acb) free_list,
140 /*6c*/ ready_list,
141 /*74*/ nexus_list;
142
143 /*7c*/ struct siop_acb *sc_nexus; /* current command */
144 /*80*/ struct siop_acb sc_acb[8]; /* the real command blocks */
145 /*6e0*/ struct siop_tinfo sc_tinfo[8];
146
147 /*7b0*/ u_long sc_clock_freq;
148 /*7b4*/ u_char sc_flags;
149 /*7b5*/ u_char sc_sien;
150 /*7b6*/ u_char sc_dien;
151 /* one for each target */
152 /*7b7*/ struct syncpar {
153 u_char state;
154 u_char period, offset;
155 } sc_sync[8];
156 };
157
158 /* sc_flags */
159 #define SIOP_INTSOFF 0x80 /* Interrupts turned off */
160 #define SIOP_INTDEFER 0x40 /* Level 6 interrupt has been deferred */
161 #define SIOP_ALIVE 0x01 /* controller initialized */
162 #define SIOP_SELECTED 0x04 /* bus is in selected state. Needed for
163 correct abort procedure. */
164
165 /* sync states */
166 #define SYNC_START 0 /* no sync handshake started */
167 #define SYNC_SENT 1 /* we sent sync request, no answer yet */
168 #define SYNC_DONE 2 /* target accepted our (or inferior) settings,
169 or it rejected the request and we stay async */
170
171 #define MSG_CMD_COMPLETE 0x00
172 #define MSG_EXT_MESSAGE 0x01
173 #define MSG_SAVE_DATA_PTR 0x02
174 #define MSG_RESTORE_PTR 0x03
175 #define MSG_DISCONNECT 0x04
176 #define MSG_INIT_DETECT_ERROR 0x05
177 #define MSG_ABORT 0x06
178 #define MSG_REJECT 0x07
179 #define MSG_NOOP 0x08
180 #define MSG_PARITY_ERROR 0x09
181 #define MSG_BUS_DEVICE_RESET 0x0C
182 #define MSG_IDENTIFY 0x80
183 #define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */
184 #define MSG_SYNC_REQ 0x01
185
186 #define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
187 #define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */
188 #define STS_BUSY 0x08
189 #define STS_INTERMED 0x10 /* Intermediate status sent */
190 #define STS_EXT 0x80 /* Extended status valid */
191
192 void siop_minphys __P((struct buf *bp));
193 int siop_scsicmd __P((struct scsi_xfer *));
194
195 #endif /* _SIOPVAR_H */
196