Home | History | Annotate | Line # | Download | only in dev
scsireg.h revision 1.8
      1 /*	$NetBSD: scsireg.h,v 1.8 2003/05/25 15:00:38 tsutsui 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		splbio		/* Lite2 used spl3 */
    180 #  define	splscon		spl2 XXX not used
    181 # else
    182 #  define	splsc		spl4
    183 #  define	splscon		spl3
    184 # endif
    185 #endif /* CPU_SINGLE */
    186 
    187 #define	SCSI_INTEN	1
    188 #define	SCSI_INTDIS	0
    189 
    190 
    191 /*
    192  *	other definition
    193  */
    194 #define	ON	1
    195 #define	OFF	0
    196 
    197 
    198 /*
    199  *	scsi map table format
    200  */
    201 #if defined(news3400)
    202 #define NSCMAP 120
    203 #endif
    204 
    205 #if defined(news3800)
    206 #define NSCMAP 129
    207 #endif
    208 
    209 struct sc_map {
    210 	u_int	mp_offset;
    211 	u_int	mp_pages;
    212 	u_int	mp_addr[NSCMAP];	/* page number */
    213 };
    214 
    215 struct sc_chan_stat {
    216 	struct sc_chan_stat *wb_next;	/* wait bus channel queue */
    217 	struct sc_scb	*scb;		/* scsi struct address */
    218 	u_int		stcnt;		/* save transfer count */
    219 	u_char		*spoint;	/* save transfer point */
    220 	u_int		stag;		/* save tag register */
    221 	u_int		soffset;	/* save offset register */
    222 	int		chan_num;	/* channel NO. */
    223 	u_char		comflg;		/* flag for save comand pointer */
    224 	u_char		intr_flg;	/* interrupt flag. SCSI_INTEN/INTDIS */
    225 };
    226 
    227 struct sc_scb {
    228 	TAILQ_ENTRY(sc_scb) chain;
    229 	struct scsipi_xfer *xs;
    230 	int	flags;
    231 
    232 	struct sc_softc *scb_softc;
    233 	struct sc_map *sc_map;
    234 	u_char	*sc_cpoint;		/* pointer to buffer address */
    235 	u_int	sc_ctrnscnt;		/* transfer count */
    236 	u_int	sc_ctag;
    237 	u_int	sc_coffset;
    238 
    239 	u_char	istatus;
    240 	u_char	tstatus;
    241 	u_char	identify;
    242 	u_char	message;
    243 	u_char	msgbuf[20];
    244 };
    245 
    246 #define	NTARGET 8
    247 
    248 struct sc_softc {
    249 	struct device sc_dev;
    250 	struct scsipi_channel sc_channel;
    251 	struct scsipi_adapter sc_adapter;
    252 
    253 	TAILQ_HEAD(scb_list, sc_scb) ready_list, free_list;
    254 	struct sc_scb sc_scb[3*NTARGET];
    255 
    256 	int inuse[NTARGET];
    257 	struct sc_map sc_map[NTARGET];
    258 	struct sc_chan_stat chan_stat[NTARGET];	/* SCSI channel status */
    259 	int sel_stat[NTARGET];			/* target select status */
    260 
    261 	int scsi_1185AQ;
    262 	int pad_start;
    263 
    264 	int	wbc;	/* # of channel that is waiting for scsi bus free */
    265 	int	wrc;	/* # of channel that is waiting for reselection */
    266 	struct sc_chan_stat *ip;
    267 			/* In progress channel. Same as ISTAT.IP */
    268 	int	ipc;		/* number of in progress channel. */
    269 	int	dma_stat;	/* OFF = DMAC is not used */
    270 #define SC_DMAC_RD	1
    271 #define SC_DMAC_WR	2
    272 
    273 	struct sc_chan_stat *wbq_actf;		/* forword active pointer */
    274 	struct sc_chan_stat *wbq_actl;		/* last active pointer */
    275 
    276 	u_char	*act_cmd_pointer;
    277 	u_char	*min_point[NTARGET];
    278 	int pad_cnt[NTARGET];
    279 	char min_cnt[NTARGET];
    280 	char sync_tr[NTARGET];			/* sync/async flag */
    281 	char mout_flag[NTARGET];
    282 	char perr_flag[NTARGET];
    283 	int int_stat1;
    284 	int int_stat2;
    285 	int min_flag;
    286 	int lastcmd;
    287 };
    288 
    289 /*
    290  * sel_stat values
    291  */
    292 #define	SEL_WAIT	0
    293 #define	SEL_START	1
    294 #define	SEL_TIMEOUT	2
    295 #define	SEL_ARBF	3
    296 #define	SEL_SUCCESS	4
    297 #define	SEL_RSLD	5
    298 #define	SEL_RSL_WAIT	6
    299 
    300 /*
    301  * mout_flag values
    302  */
    303 #define MOUT_IDENTIFY	1
    304 #define MOUT_SYNC_TR	2
    305 
    306 
    307 struct scintsw {
    308 /*00*/	int	(*sci_inthandler)(int);	/* pointer to interrupt handler */
    309 /*04*/	int	sci_ctlr;		/* controller number */
    310 /*08*/
    311 };
    312 
    313 #endif /* !__SCSIREG__ */
    314