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