scsireg.h revision 1.2 1 1.2 tsubai /* $NetBSD: scsireg.h,v 1.2 1998/06/10 16:27:30 tsubai Exp $ */
2 1.2 tsubai
3 1.1 tsubai /*
4 1.1 tsubai * Copyright (c) 1992, 1993
5 1.1 tsubai * The Regents of the University of California. All rights reserved.
6 1.1 tsubai *
7 1.1 tsubai * This code is derived from software contributed to Berkeley by
8 1.1 tsubai * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
9 1.1 tsubai *
10 1.1 tsubai * Redistribution and use in source and binary forms, with or without
11 1.1 tsubai * modification, are permitted provided that the following conditions
12 1.1 tsubai * are met:
13 1.1 tsubai * 1. Redistributions of source code must retain the above copyright
14 1.1 tsubai * notice, this list of conditions and the following disclaimer.
15 1.1 tsubai * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 tsubai * notice, this list of conditions and the following disclaimer in the
17 1.1 tsubai * documentation and/or other materials provided with the distribution.
18 1.1 tsubai * 3. All advertising materials mentioning features or use of this software
19 1.1 tsubai * must display the following acknowledgement:
20 1.1 tsubai * This product includes software developed by the University of
21 1.1 tsubai * California, Berkeley and its contributors.
22 1.1 tsubai * 4. Neither the name of the University nor the names of its contributors
23 1.1 tsubai * may be used to endorse or promote products derived from this software
24 1.1 tsubai * without specific prior written permission.
25 1.1 tsubai *
26 1.1 tsubai * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 1.1 tsubai * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 1.1 tsubai * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 1.1 tsubai * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 1.1 tsubai * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 1.1 tsubai * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 1.1 tsubai * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 1.1 tsubai * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 1.1 tsubai * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 1.1 tsubai * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 1.1 tsubai * SUCH DAMAGE.
37 1.1 tsubai *
38 1.1 tsubai * from: $Hdr: scsireg.h,v 4.300 91/06/09 06:38:12 root Rel41 $ SONY
39 1.1 tsubai *
40 1.1 tsubai * @(#)scsireg.h 8.1 (Berkeley) 6/11/93
41 1.1 tsubai */
42 1.1 tsubai
43 1.1 tsubai /*
44 1.1 tsubai * scsireg.h
45 1.1 tsubai */
46 1.1 tsubai
47 1.1 tsubai #ifndef __SCSIREG__
48 1.1 tsubai #define __SCSIREG__ 1
49 1.1 tsubai
50 1.1 tsubai /*
51 1.1 tsubai * initiator status byte bit image
52 1.1 tsubai */
53 1.1 tsubai #define INST_EP 0x80 /* End of Process */
54 1.1 tsubai #define INST_WR 0x40 /* Waiting Reselection */
55 1.1 tsubai #define INST_IP 0x20 /* In Process */
56 1.1 tsubai #define INST_WAIT 0x10 /* Waiting Bus free */
57 1.1 tsubai #define INST_LB 0x8 /* Loss of BUSY */
58 1.1 tsubai #define INST_TO 0x4 /* Time Out */
59 1.1 tsubai #define INST_PRE 0x2 /* PaRameter Error */
60 1.1 tsubai #define INST_HE 0x1 /* Hard Error */
61 1.1 tsubai
62 1.1 tsubai #define INSTERMASK 0x7
63 1.1 tsubai
64 1.1 tsubai
65 1.1 tsubai /*
66 1.1 tsubai * target status byte bit image
67 1.1 tsubai */
68 1.1 tsubai #define VENDOR 0x61
69 1.1 tsubai #define TGSTMASK 0x1e
70 1.1 tsubai #define TGST_RSVCFLCT 0x18
71 1.1 tsubai #define TGST_INTERMED 0x10
72 1.1 tsubai #define TGST_BUSY 0x8
73 1.1 tsubai #define TGST_CC 0x2
74 1.1 tsubai #define TGST_GOOD 0x0
75 1.1 tsubai
76 1.1 tsubai #define TS_MAPPED_PIO 0x01 /* program I/O with map */
77 1.1 tsubai #define TS_CONTR_ON 0x02 /* contiguous transfer on */
78 1.1 tsubai #define TS_CONTR_OFF 0x04 /* contiguous transfer off */
79 1.1 tsubai #define TS_BYTE_DMA 0x08 /* DMA transfer(byte access) */
80 1.1 tsubai #define TS_LONG_DMA 0x10 /* DMA transfer(long access) */
81 1.1 tsubai
82 1.1 tsubai
83 1.1 tsubai /*
84 1.1 tsubai * message byte
85 1.1 tsubai */
86 1.1 tsubai #define MSG_IDENT 0x80
87 1.1 tsubai #define MSG_RESELEN 0x40
88 1.1 tsubai #define MSG_CCOMP 0
89 1.1 tsubai #define MSG_EXTND 1
90 1.1 tsubai #define MSG_SDP 2
91 1.1 tsubai #define MSG_RDP 3
92 1.1 tsubai #define MSG_DCNT 4
93 1.1 tsubai #define MSG_IDE 5
94 1.1 tsubai /*#define MSG_ABORT 6*/
95 1.1 tsubai #define MSG_MREJ 7
96 1.1 tsubai #define MSG_NOP 8
97 1.1 tsubai #define MSG_PERROR 9
98 1.1 tsubai
99 1.1 tsubai
100 1.1 tsubai /*
101 1.1 tsubai * message identify byte bit image
102 1.1 tsubai */
103 1.1 tsubai #define IDT_DISCON 0x40
104 1.1 tsubai #define IDT_DRMASK 0x7
105 1.1 tsubai
106 1.1 tsubai
107 1.1 tsubai /*
108 1.1 tsubai * scsi command opcodes
109 1.1 tsubai */
110 1.1 tsubai #define SCOP_TST 0x00
111 1.1 tsubai #define SCOP_REZERO 0x01
112 1.1 tsubai #define SCOP_REWIND 0x01
113 1.1 tsubai #define SCOP_RSENSE 0x03
114 1.1 tsubai #define SCOP_FMT 0x04
115 1.1 tsubai #define SCOP_RBLIM 0x05
116 1.1 tsubai #define SCOP_SPARAM 0x06
117 1.1 tsubai #define SCOP_RASBLK 0x07
118 1.1 tsubai #define SCOP_READ 0x08
119 1.1 tsubai #define SCOP_MOERASE 0x09
120 1.1 tsubai #define SCOP_WRITE 0x0a
121 1.1 tsubai #define SCOP_SEEK 0x0b
122 1.1 tsubai #define SCOP_MERASE 0x0e
123 1.1 tsubai #define SCOP_WFMARK 0x10
124 1.1 tsubai #define SCOP_SPACE 0x11
125 1.1 tsubai #define SCOP_INQUIRY 0x12
126 1.1 tsubai #define SCOP_SVERIFY 0x13
127 1.1 tsubai #define SCOP_RBDATA 0x14
128 1.1 tsubai #define SCOP_MSELECT 0x15
129 1.1 tsubai #define SCOP_ERASE 0x19
130 1.1 tsubai #define SCOP_MSENSE 0x1a
131 1.1 tsubai #define SCOP_STST 0x1b
132 1.1 tsubai #define SCOP_LOAD 0x1b
133 1.1 tsubai #define SCOP_RECDIAG 0x1c
134 1.1 tsubai #define SCOP_SNDDIAG 0x1d
135 1.1 tsubai #define SCOP_MEDRMV 0x1e
136 1.1 tsubai #define SCOP_RCAP 0x25
137 1.1 tsubai #define SCOP_EREAD 0x28
138 1.1 tsubai #define SCOP_EWRITE 0x2a
139 1.1 tsubai #define SCOP_BSSRCH 0x2c
140 1.1 tsubai #define SCOP_WSSRCH 0x2d
141 1.1 tsubai #define SCOP_WRTVRFY 0x2e
142 1.1 tsubai #define SCOP_VERIFY 0x2f
143 1.1 tsubai #define SCOP_RDL 0x37
144 1.1 tsubai #define SCOP_WBUF 0x3b
145 1.1 tsubai #define SCOP_RBUF 0x3c
146 1.1 tsubai #define SCOP_EJECT 0xc0
147 1.1 tsubai #define SCOP_EESENSE 0xc1
148 1.1 tsubai #define SCOP_READTOC 0xc1
149 1.1 tsubai #define SCOP_READID 0xc2
150 1.1 tsubai #define SCOP_ADP 0xc2
151 1.1 tsubai #define SCOP_READQ 0xc2
152 1.1 tsubai #define SCOP_BLANKS 0xc3
153 1.1 tsubai #define SCOP_READHEAD 0xc3
154 1.1 tsubai #define SCOP_PBSTS 0xc4
155 1.1 tsubai #define SCOP_RCVDISK 0xc4
156 1.1 tsubai #define SCOP_PAUSE 0xc5
157 1.1 tsubai #define SCOP_PLAYTRACK 0xc6
158 1.1 tsubai #define SCOP_PLAYMSF 0xc7
159 1.1 tsubai #define SCOP_PLAYAUDIO 0xc8
160 1.1 tsubai #define SCOP_ERASED 0xe7
161 1.1 tsubai #define SCOP_RESET 0xff
162 1.1 tsubai
163 1.1 tsubai
164 1.2 tsubai #ifdef CPU_DOUBLE
165 1.2 tsubai # ifdef mips
166 1.2 tsubai # define ipc_phys(x) (caddr_t)K0_TT0(x)
167 1.2 tsubai # else
168 1.2 tsubai # define ipc_phys(x) (caddr_t)((int)(x) & ~0x80000000)
169 1.2 tsubai # endif
170 1.2 tsubai # ifdef news3800
171 1.2 tsubai # define splsc spl4
172 1.2 tsubai # define splscon spl3
173 1.2 tsubai # endif
174 1.2 tsubai #endif /* CPU_DOUBLE */
175 1.2 tsubai
176 1.2 tsubai #ifdef CPU_SINGLE
177 1.2 tsubai # define ipc_phys(x) (caddr_t)(x)
178 1.2 tsubai # ifdef news3400
179 1.2 tsubai # define splsc cpu_spl0 /* Lite2 used spl3 */
180 1.2 tsubai # define splscon spl2 XXX not used
181 1.2 tsubai extern int cpu_spl0 __P((void));
182 1.2 tsubai # else
183 1.2 tsubai # define splsc spl4
184 1.2 tsubai # define splscon spl3
185 1.2 tsubai # endif
186 1.2 tsubai #endif /* CPU_SINGLE */
187 1.2 tsubai
188 1.2 tsubai #define SCSI_INTEN 1
189 1.2 tsubai #define SCSI_INTDIS 0
190 1.2 tsubai
191 1.2 tsubai
192 1.1 tsubai /*
193 1.1 tsubai * other definition
194 1.1 tsubai */
195 1.1 tsubai #define ON 1
196 1.1 tsubai #define OFF 0
197 1.1 tsubai
198 1.1 tsubai
199 1.1 tsubai /*
200 1.1 tsubai * scsi map table format
201 1.1 tsubai */
202 1.2 tsubai #if defined(news3400)
203 1.2 tsubai #define NSCMAP 120
204 1.1 tsubai #endif
205 1.1 tsubai
206 1.2 tsubai #if defined(news3800)
207 1.2 tsubai #define NSCMAP 129
208 1.1 tsubai #endif
209 1.1 tsubai
210 1.1 tsubai struct sc_map {
211 1.2 tsubai u_int mp_offset;
212 1.2 tsubai u_int mp_pages;
213 1.2 tsubai u_int mp_addr[NSCMAP]; /* page number */
214 1.1 tsubai };
215 1.1 tsubai
216 1.2 tsubai struct sc_chan_stat {
217 1.2 tsubai struct sc_chan_stat *wb_next; /* wait bus channel queue */
218 1.2 tsubai struct sc_scb *scb; /* scsi struct address */
219 1.2 tsubai u_int stcnt; /* save transfer count */
220 1.2 tsubai u_char *spoint; /* save transfer point */
221 1.2 tsubai u_int stag; /* save tag register */
222 1.2 tsubai u_int soffset; /* save offset register */
223 1.2 tsubai int chan_num; /* channel NO. */
224 1.2 tsubai u_char comflg; /* flag for save comand pointer */
225 1.2 tsubai u_char intr_flg; /* interrupt flag. SCSI_INTEN/INTDIS */
226 1.1 tsubai };
227 1.1 tsubai
228 1.2 tsubai struct sc_scb {
229 1.2 tsubai TAILQ_ENTRY(sc_scb) chain;
230 1.2 tsubai struct scsipi_xfer *xs;
231 1.2 tsubai int flags;
232 1.2 tsubai
233 1.2 tsubai struct sc_softc *scb_softc;
234 1.2 tsubai struct sc_map *sc_map;
235 1.2 tsubai u_char *sc_cpoint; /* pointer to buffer address */
236 1.2 tsubai u_int sc_ctrnscnt; /* transfer count */
237 1.2 tsubai u_int sc_ctag;
238 1.2 tsubai u_int sc_coffset;
239 1.2 tsubai
240 1.2 tsubai u_char istatus;
241 1.2 tsubai u_char tstatus;
242 1.2 tsubai u_char identify;
243 1.2 tsubai u_char message;
244 1.2 tsubai u_char msgbuf[20];
245 1.1 tsubai };
246 1.1 tsubai
247 1.2 tsubai #define NTARGET 8
248 1.1 tsubai
249 1.2 tsubai struct sc_softc {
250 1.2 tsubai struct device sc_dev;
251 1.2 tsubai struct scsipi_link sc_link;
252 1.2 tsubai
253 1.2 tsubai TAILQ_HEAD(scb_list, sc_scb) ready_list, free_list;
254 1.2 tsubai struct sc_scb sc_scb[3*NTARGET];
255 1.2 tsubai
256 1.2 tsubai int inuse[NTARGET];
257 1.2 tsubai struct sc_map sc_map[NTARGET];
258 1.2 tsubai struct sc_chan_stat chan_stat[NTARGET]; /* SCSI channel status */
259 1.2 tsubai int sel_stat[NTARGET]; /* target select status */
260 1.2 tsubai
261 1.2 tsubai int scsi_1185AQ;
262 1.2 tsubai int pad_start;
263 1.2 tsubai
264 1.2 tsubai int wbc; /* # of channel that is waiting for scsi bus free */
265 1.2 tsubai int wrc; /* # of channel that is waiting for reselection */
266 1.2 tsubai struct sc_chan_stat *ip;
267 1.2 tsubai /* In progress channel. Same as ISTAT.IP */
268 1.2 tsubai int ipc; /* number of in progress channel. */
269 1.2 tsubai int dma_stat; /* OFF = DMAC is not used */
270 1.2 tsubai #define SC_DMAC_RD 1
271 1.2 tsubai #define SC_DMAC_WR 2
272 1.2 tsubai
273 1.2 tsubai struct sc_chan_stat *wbq_actf; /* forword active pointer */
274 1.2 tsubai struct sc_chan_stat *wbq_actl; /* last active pointer */
275 1.2 tsubai
276 1.2 tsubai u_char *act_cmd_pointer;
277 1.2 tsubai u_char *min_point[NTARGET];
278 1.2 tsubai int pad_cnt[NTARGET];
279 1.2 tsubai char min_cnt[NTARGET];
280 1.2 tsubai char sync_tr[NTARGET]; /* sync/async flag */
281 1.2 tsubai char mout_flag[NTARGET];
282 1.2 tsubai char perr_flag[NTARGET];
283 1.2 tsubai int int_stat1;
284 1.2 tsubai int int_stat2;
285 1.2 tsubai int min_flag;
286 1.2 tsubai int lastcmd;
287 1.1 tsubai };
288 1.1 tsubai
289 1.1 tsubai /*
290 1.2 tsubai * sel_stat values
291 1.1 tsubai */
292 1.2 tsubai #define SEL_WAIT 0
293 1.2 tsubai #define SEL_START 1
294 1.2 tsubai #define SEL_TIMEOUT 2
295 1.2 tsubai #define SEL_ARBF 3
296 1.2 tsubai #define SEL_SUCCESS 4
297 1.2 tsubai #define SEL_RSLD 5
298 1.2 tsubai #define SEL_RSL_WAIT 6
299 1.1 tsubai
300 1.1 tsubai /*
301 1.2 tsubai * mout_flag values
302 1.1 tsubai */
303 1.2 tsubai #define MOUT_IDENTIFY 1
304 1.2 tsubai #define MOUT_SYNC_TR 2
305 1.1 tsubai
306 1.1 tsubai
307 1.1 tsubai struct scintsw {
308 1.1 tsubai /*00*/ int (*sci_inthandler)(); /* pointer to interrupt handler */
309 1.1 tsubai /*04*/ int sci_ctlr; /* controller number */
310 1.1 tsubai /*08*/
311 1.1 tsubai };
312 1.1 tsubai
313 1.1 tsubai #endif /* !__SCSIREG__ */
314