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