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