Home | History | Annotate | Line # | Download | only in dev
siopvar.h revision 1.19.8.3
      1  1.19.8.3  nathanw /*	$NetBSD: siopvar.h,v 1.19.8.3 2002/06/20 03:37:55 nathanw Exp $	*/
      2  1.19.8.2  nathanw 
      3  1.19.8.2  nathanw /*
      4  1.19.8.2  nathanw  * Copyright (c) 1990 The Regents of the University of California.
      5  1.19.8.2  nathanw  * All rights reserved.
      6  1.19.8.2  nathanw  *
      7  1.19.8.2  nathanw  * This code is derived from software contributed to Berkeley by
      8  1.19.8.2  nathanw  * Van Jacobson of Lawrence Berkeley Laboratory.
      9  1.19.8.2  nathanw  *
     10  1.19.8.2  nathanw  * Redistribution and use in source and binary forms, with or without
     11  1.19.8.2  nathanw  * modification, are permitted provided that the following conditions
     12  1.19.8.2  nathanw  * are met:
     13  1.19.8.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     14  1.19.8.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     15  1.19.8.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.19.8.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     17  1.19.8.2  nathanw  *    documentation and/or other materials provided with the distribution.
     18  1.19.8.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     19  1.19.8.2  nathanw  *    must display the following acknowledgement:
     20  1.19.8.2  nathanw  *	This product includes software developed by the University of
     21  1.19.8.2  nathanw  *	California, Berkeley and its contributors.
     22  1.19.8.2  nathanw  * 4. Neither the name of the University nor the names of its contributors
     23  1.19.8.2  nathanw  *    may be used to endorse or promote products derived from this software
     24  1.19.8.2  nathanw  *    without specific prior written permission.
     25  1.19.8.2  nathanw  *
     26  1.19.8.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  1.19.8.2  nathanw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  1.19.8.2  nathanw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  1.19.8.2  nathanw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  1.19.8.2  nathanw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  1.19.8.2  nathanw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  1.19.8.2  nathanw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  1.19.8.2  nathanw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  1.19.8.2  nathanw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  1.19.8.2  nathanw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  1.19.8.2  nathanw  * SUCH DAMAGE.
     37  1.19.8.2  nathanw  *
     38  1.19.8.2  nathanw  *	@(#)siopvar.h	7.1 (Berkeley) 5/8/90
     39  1.19.8.2  nathanw  */
     40  1.19.8.2  nathanw #ifndef _SIOPVAR_H_
     41  1.19.8.2  nathanw #define _SIOPVAR_H_
     42  1.19.8.2  nathanw 
     43  1.19.8.2  nathanw /*
     44  1.19.8.2  nathanw  * The largest single request will be MAXPHYS bytes which will require
     45  1.19.8.2  nathanw  * at most MAXPHYS/NBPG+1 chain elements to describe, i.e. if none of
     46  1.19.8.2  nathanw  * the buffer pages are physically contiguous (MAXPHYS/NBPG) and the
     47  1.19.8.2  nathanw  * buffer is not page aligned (+1).
     48  1.19.8.2  nathanw  */
     49  1.19.8.2  nathanw #define	DMAMAXIO	(MAXPHYS/NBPG+1)
     50  1.19.8.2  nathanw 
     51  1.19.8.2  nathanw /*
     52  1.19.8.2  nathanw  * Data Structure for SCRIPTS program
     53  1.19.8.2  nathanw  */
     54  1.19.8.2  nathanw struct siop_ds {
     55  1.19.8.2  nathanw 	long	scsi_addr;		/* SCSI ID & sync */
     56  1.19.8.2  nathanw 	long	idlen;			/* Identify message */
     57  1.19.8.2  nathanw 	char	*idbuf;
     58  1.19.8.2  nathanw 	long	cmdlen;			/* SCSI command */
     59  1.19.8.2  nathanw 	char	*cmdbuf;
     60  1.19.8.2  nathanw 	long	stslen;			/* Status */
     61  1.19.8.2  nathanw 	char	*stsbuf;
     62  1.19.8.2  nathanw 	long	msglen;			/* Message */
     63  1.19.8.2  nathanw 	char	*msgbuf;
     64  1.19.8.2  nathanw 	long	msginlen;		/* Message in */
     65  1.19.8.2  nathanw 	char	*msginbuf;
     66  1.19.8.2  nathanw 	long	extmsglen;		/* Extended message in */
     67  1.19.8.2  nathanw 	char	*extmsgbuf;
     68  1.19.8.2  nathanw 	long	synmsglen;		/* Sync transfer request */
     69  1.19.8.2  nathanw 	char	*synmsgbuf;
     70  1.19.8.2  nathanw 	struct {
     71  1.19.8.2  nathanw 		long datalen;
     72  1.19.8.2  nathanw 		char *databuf;
     73  1.19.8.2  nathanw 	} chain[DMAMAXIO];
     74  1.19.8.2  nathanw };
     75  1.19.8.2  nathanw 
     76  1.19.8.2  nathanw /*
     77  1.19.8.2  nathanw  * ACB. Holds additional information for each SCSI command Comments: We
     78  1.19.8.2  nathanw  * need a separate scsi command block because we may need to overwrite it
     79  1.19.8.2  nathanw  * with a request sense command.  Basicly, we refrain from fiddling with
     80  1.19.8.2  nathanw  * the scsi_xfer struct (except do the expected updating of return values).
     81  1.19.8.2  nathanw  * We'll generally update: xs->{flags,resid,error,sense,status} and
     82  1.19.8.2  nathanw  * occasionally xs->retries.
     83  1.19.8.2  nathanw  */
     84  1.19.8.2  nathanw struct siop_acb {
     85  1.19.8.2  nathanw 	TAILQ_ENTRY(siop_acb) chain;
     86  1.19.8.2  nathanw 	struct scsipi_xfer *xs;	/* SCSI xfer ctrl block from above */
     87  1.19.8.2  nathanw 	int		flags;	/* Status */
     88  1.19.8.2  nathanw #define ACB_FREE	0x00
     89  1.19.8.2  nathanw #define ACB_ACTIVE	0x01
     90  1.19.8.2  nathanw #define ACB_DONE	0x04
     91  1.19.8.2  nathanw 	struct scsi_generic cmd;  /* SCSI command block */
     92  1.19.8.2  nathanw 	struct siop_ds ds;
     93  1.19.8.2  nathanw 	void	*iob_buf;
     94  1.19.8.2  nathanw 	u_long	iob_curbuf;
     95  1.19.8.2  nathanw 	u_long	iob_len, iob_curlen;
     96  1.19.8.2  nathanw 	u_char	msgout[6];
     97  1.19.8.2  nathanw 	u_char	msg[6];
     98  1.19.8.2  nathanw 	u_char	stat[1];
     99  1.19.8.2  nathanw 	u_char	status;
    100  1.19.8.2  nathanw 	u_char	dummy[2];
    101  1.19.8.2  nathanw 	int	 clen;
    102  1.19.8.2  nathanw 	char	*daddr;		/* Saved data pointer */
    103  1.19.8.2  nathanw 	int	 dleft;		/* Residue */
    104  1.19.8.2  nathanw };
    105  1.19.8.2  nathanw 
    106  1.19.8.2  nathanw /*
    107  1.19.8.2  nathanw  * Some info about each (possible) target on the SCSI bus.  This should
    108  1.19.8.2  nathanw  * probably have been a "per target+lunit" structure, but we'll leave it at
    109  1.19.8.2  nathanw  * this for now.  Is there a way to reliably hook it up to sc->fordriver??
    110  1.19.8.2  nathanw  */
    111  1.19.8.2  nathanw struct siop_tinfo {
    112  1.19.8.2  nathanw 	int	cmds;		/* #commands processed */
    113  1.19.8.2  nathanw 	int	dconns;		/* #disconnects */
    114  1.19.8.2  nathanw 	int	touts;		/* #timeouts */
    115  1.19.8.2  nathanw 	int	perrs;		/* #parity errors */
    116  1.19.8.2  nathanw 	ushort	lubusy;		/* What local units/subr. are busy? */
    117  1.19.8.2  nathanw 	u_char  flags;
    118  1.19.8.2  nathanw 	u_char  period;		/* Period suggestion */
    119  1.19.8.2  nathanw 	u_char  offset;		/* Offset suggestion */
    120  1.19.8.3  nathanw };
    121  1.19.8.2  nathanw 
    122  1.19.8.2  nathanw struct	siop_softc {
    123  1.19.8.2  nathanw 	struct	device sc_dev;
    124  1.19.8.2  nathanw 	struct	isr sc_isr;
    125  1.19.8.2  nathanw 
    126  1.19.8.2  nathanw 	u_char	sc_istat;
    127  1.19.8.2  nathanw 	u_char	sc_dstat;
    128  1.19.8.2  nathanw #ifndef ARCH_720
    129  1.19.8.2  nathanw 	u_char	sc_sstat0;
    130  1.19.8.2  nathanw #endif
    131  1.19.8.2  nathanw 	u_char	sc_sstat1;
    132  1.19.8.2  nathanw #ifdef ARCH_720
    133  1.19.8.2  nathanw 	u_short	sc_sist;
    134  1.19.8.2  nathanw #endif
    135  1.19.8.2  nathanw 	u_long	sc_intcode;
    136  1.19.8.2  nathanw 	struct	scsipi_adapter sc_adapter;
    137  1.19.8.2  nathanw 	struct	scsipi_channel sc_channel;
    138  1.19.8.2  nathanw 	u_long	sc_scriptspa;		/* physical address of scripts */
    139  1.19.8.2  nathanw 	siop_regmap_p	sc_siopp;	/* the SIOP */
    140  1.19.8.2  nathanw 	u_long	sc_active;		/* number of active I/O's */
    141  1.19.8.2  nathanw 
    142  1.19.8.2  nathanw 	/* Lists of command blocks */
    143  1.19.8.2  nathanw 	TAILQ_HEAD(acb_list, siop_acb) free_list,
    144  1.19.8.2  nathanw 				       ready_list,
    145  1.19.8.2  nathanw 				       nexus_list;
    146  1.19.8.2  nathanw 
    147  1.19.8.2  nathanw 	struct siop_acb *sc_nexus;	/* current command */
    148  1.19.8.2  nathanw #define SIOP_NACB 16
    149  1.19.8.2  nathanw 	struct siop_acb *sc_acb;	/* the real command blocks */
    150  1.19.8.2  nathanw #ifndef ARCH_720
    151  1.19.8.2  nathanw 	struct siop_tinfo sc_tinfo[8];
    152  1.19.8.2  nathanw #else
    153  1.19.8.2  nathanw 	struct siop_tinfo sc_tinfo[16];
    154  1.19.8.2  nathanw #endif
    155  1.19.8.2  nathanw 
    156  1.19.8.2  nathanw 	u_short	sc_clock_freq;
    157  1.19.8.2  nathanw 	u_char	sc_dcntl;
    158  1.19.8.2  nathanw 	u_char	sc_ctest7;
    159  1.19.8.2  nathanw 	u_short	sc_tcp[4];
    160  1.19.8.2  nathanw 	u_char	sc_flags;
    161  1.19.8.2  nathanw 	u_char	sc_dien;
    162  1.19.8.2  nathanw 	u_char	sc_minsync;
    163  1.19.8.2  nathanw #ifndef ARCH_720
    164  1.19.8.2  nathanw 	u_char	sc_sien;
    165  1.19.8.2  nathanw #else
    166  1.19.8.2  nathanw 	u_short	sc_sien;
    167  1.19.8.2  nathanw #endif
    168  1.19.8.2  nathanw 	/* one for each target */
    169  1.19.8.2  nathanw 	struct syncpar {
    170  1.19.8.2  nathanw 		u_char state;
    171  1.19.8.2  nathanw 		u_char sxfer;
    172  1.19.8.2  nathanw #ifndef ARCH_720
    173  1.19.8.2  nathanw 		u_char sbcl;
    174  1.19.8.2  nathanw #else
    175  1.19.8.2  nathanw 		u_char scntl3;
    176  1.19.8.2  nathanw #endif
    177  1.19.8.2  nathanw 	} sc_sync[16];
    178  1.19.8.2  nathanw };
    179  1.19.8.2  nathanw 
    180  1.19.8.2  nathanw /* sc_flags */
    181  1.19.8.2  nathanw #define	SIOP_INTSOFF	0x80	/* Interrupts turned off */
    182  1.19.8.2  nathanw #define	SIOP_INTDEFER	0x40	/* Level 6 interrupt has been deferred */
    183  1.19.8.2  nathanw #define	SIOP_ALIVE	0x01	/* controller initialized */
    184  1.19.8.2  nathanw #define SIOP_SELECTED	0x04	/* bus is in selected state. Needed for
    185  1.19.8.2  nathanw 				   correct abort procedure. */
    186  1.19.8.2  nathanw 
    187  1.19.8.2  nathanw /* negotiation states */
    188  1.19.8.2  nathanw #define NEG_WIDE	0	/* Negotiate wide transfers */
    189  1.19.8.2  nathanw #define	NEG_WAITW	1	/* Waiting for wide negotation response */
    190  1.19.8.2  nathanw #define NEG_SYNC	2	/* Negotiate synch transfers */
    191  1.19.8.2  nathanw #define	NEG_WAITS	3	/* Waiting for synch negoation response */
    192  1.19.8.2  nathanw #define NEG_DONE	4	/* Wide and/or sync negotation done */
    193  1.19.8.2  nathanw 
    194  1.19.8.2  nathanw #define	MSG_CMD_COMPLETE	0x00
    195  1.19.8.2  nathanw #define MSG_EXT_MESSAGE		0x01
    196  1.19.8.2  nathanw #define	MSG_SAVE_DATA_PTR	0x02
    197  1.19.8.2  nathanw #define	MSG_RESTORE_PTR		0x03
    198  1.19.8.2  nathanw #define	MSG_DISCONNECT		0x04
    199  1.19.8.2  nathanw #define	MSG_INIT_DETECT_ERROR	0x05
    200  1.19.8.2  nathanw #define	MSG_ABORT		0x06
    201  1.19.8.2  nathanw #define	MSG_REJECT		0x07
    202  1.19.8.2  nathanw #define	MSG_NOOP		0x08
    203  1.19.8.2  nathanw #define	MSG_PARITY_ERROR	0x09
    204  1.19.8.2  nathanw #define	MSG_BUS_DEVICE_RESET	0x0C
    205  1.19.8.2  nathanw #define	MSG_IDENTIFY		0x80
    206  1.19.8.2  nathanw #define	MSG_IDENTIFY_DR		0xc0	/* (disconnect/reconnect allowed) */
    207  1.19.8.2  nathanw #define	MSG_SYNC_REQ		0x01
    208  1.19.8.2  nathanw #define	MSG_WIDE_REQ		0x03
    209  1.19.8.2  nathanw 
    210  1.19.8.2  nathanw #define	STS_CHECKCOND	0x02	/* Check Condition (ie., read sense) */
    211  1.19.8.2  nathanw #define	STS_CONDMET	0x04	/* Condition Met (ie., search worked) */
    212  1.19.8.2  nathanw #define	STS_BUSY	0x08
    213  1.19.8.2  nathanw #define	STS_INTERMED	0x10	/* Intermediate status sent */
    214  1.19.8.2  nathanw #define	STS_EXT		0x80	/* Extended status valid */
    215  1.19.8.2  nathanw 
    216  1.19.8.2  nathanw #ifdef ARCH_720
    217  1.19.8.2  nathanw void siopng_minphys(struct buf *bp);
    218  1.19.8.2  nathanw void siopng_scsipi_request(struct scsipi_channel *,
    219  1.19.8.2  nathanw 			scsipi_adapter_req_t, void *);
    220  1.19.8.2  nathanw void siopnginitialize(struct siop_softc *);
    221  1.19.8.2  nathanw void siopngintr(struct siop_softc *);
    222  1.19.8.2  nathanw void siopng_dump_registers(struct siop_softc *);
    223  1.19.8.2  nathanw #ifdef DEBUG
    224  1.19.8.2  nathanw void siopng_dump(struct siop_softc *);
    225  1.19.8.2  nathanw #endif
    226  1.19.8.2  nathanw 
    227  1.19.8.2  nathanw #else
    228  1.19.8.2  nathanw 
    229  1.19.8.2  nathanw void siop_minphys(struct buf *bp);
    230  1.19.8.2  nathanw void siop_scsipi_request(struct scsipi_channel *,
    231  1.19.8.2  nathanw 			scsipi_adapter_req_t, void *);
    232  1.19.8.2  nathanw void siopinitialize(struct siop_softc *);
    233  1.19.8.2  nathanw void siopintr(struct siop_softc *);
    234  1.19.8.2  nathanw void siop_dump_registers(struct siop_softc *);
    235  1.19.8.2  nathanw #ifdef DEBUG
    236  1.19.8.2  nathanw void siop_dump(struct siop_softc *);
    237  1.19.8.2  nathanw #endif
    238  1.19.8.2  nathanw #endif
    239  1.19.8.2  nathanw 
    240  1.19.8.2  nathanw #endif /* _SIOPVAR_H */
    241