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