Home | History | Annotate | Line # | Download | only in ic
aic6360var.h revision 1.4.6.1
      1  1.4.6.1  wrstuden /*	$NetBSD: aic6360var.h,v 1.4.6.1 1999/12/27 18:34:43 wrstuden Exp $	*/
      2      1.1  christos 
      3      1.1  christos /*
      4      1.1  christos  * Copyright (c) 1994, 1995, 1996 Charles M. Hannum.  All rights reserved.
      5      1.1  christos  *
      6      1.1  christos  * Redistribution and use in source and binary forms, with or without
      7      1.1  christos  * modification, are permitted provided that the following conditions
      8      1.1  christos  * are met:
      9      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     10      1.1  christos  *    notice, this list of conditions and the following disclaimer.
     11      1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     12      1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     13      1.1  christos  *    documentation and/or other materials provided with the distribution.
     14      1.1  christos  * 3. All advertising materials mentioning features or use of this software
     15      1.1  christos  *    must display the following acknowledgement:
     16      1.1  christos  *	This product includes software developed by Charles M. Hannum.
     17      1.1  christos  * 4. The name of the author may not be used to endorse or promote products
     18      1.1  christos  *    derived from this software without specific prior written permission.
     19      1.1  christos  *
     20      1.1  christos  * Copyright (c) 1994 Jarle Greipsland
     21      1.1  christos  * All rights reserved.
     22      1.1  christos  *
     23      1.1  christos  * Redistribution and use in source and binary forms, with or without
     24      1.1  christos  * modification, are permitted provided that the following conditions
     25      1.1  christos  * are met:
     26      1.1  christos  * 1. Redistributions of source code must retain the above copyright
     27      1.1  christos  *    notice, this list of conditions and the following disclaimer.
     28      1.1  christos  * 2. Redistributions in binary form must reproduce the above copyright
     29      1.1  christos  *    notice, this list of conditions and the following disclaimer in the
     30      1.1  christos  *    documentation and/or other materials provided with the distribution.
     31      1.1  christos  * 3. The name of the author may not be used to endorse or promote products
     32      1.1  christos  *    derived from this software without specific prior written permission.
     33      1.1  christos  *
     34      1.1  christos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     35      1.1  christos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     36      1.1  christos  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     37      1.1  christos  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     38      1.1  christos  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     39      1.1  christos  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     40      1.1  christos  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     41      1.1  christos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     42      1.1  christos  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     43      1.1  christos  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     44      1.1  christos  * POSSIBILITY OF SUCH DAMAGE.
     45      1.1  christos  */
     46      1.1  christos 
     47      1.1  christos /*
     48      1.1  christos  * Acknowledgements: Many of the algorithms used in this driver are
     49      1.1  christos  * inspired by the work of Julian Elischer (julian (at) tfs.com) and
     50      1.1  christos  * Charles Hannum (mycroft (at) duality.gnu.ai.mit.edu).  Thanks a million!
     51      1.1  christos  */
     52      1.1  christos 
     53      1.1  christos typedef u_long physaddr;
     54      1.1  christos typedef u_long physlen;
     55      1.1  christos 
     56      1.1  christos struct aic_dma_seg {
     57      1.1  christos 	physaddr seg_addr;
     58      1.1  christos 	physlen seg_len;
     59      1.1  christos };
     60      1.1  christos 
     61      1.1  christos #define AIC_NSEG	16
     62      1.1  christos 
     63      1.1  christos /*
     64      1.1  christos  * ACB. Holds additional information for each SCSI command Comments: We
     65      1.1  christos  * need a separate scsi command block because we may need to overwrite it
     66      1.1  christos  * with a request sense command.  Basicly, we refrain from fiddling with
     67      1.1  christos  * the scsipi_xfer struct (except do the expected updating of return values).
     68      1.1  christos  * We'll generally update: xs->{flags,resid,error,sense,status} and
     69      1.1  christos  * occasionally xs->retries.
     70      1.1  christos  */
     71      1.1  christos struct aic_acb {
     72      1.1  christos 	struct scsi_generic scsipi_cmd;
     73      1.1  christos 	int scsipi_cmd_length;
     74      1.1  christos 	u_char *data_addr;		/* Saved data pointer */
     75      1.1  christos 	int data_length;		/* Residue */
     76      1.1  christos 
     77      1.1  christos 	u_char target_stat;		/* SCSI status byte */
     78      1.1  christos 
     79      1.1  christos #ifdef notdef
     80      1.1  christos 	struct aic_dma_seg dma[AIC_NSEG]; /* Physical addresses+len */
     81      1.1  christos #endif
     82      1.1  christos 
     83      1.1  christos 	TAILQ_ENTRY(aic_acb) chain;
     84      1.1  christos 	struct scsipi_xfer *xs;	/* SCSI xfer ctrl block from above */
     85      1.1  christos 	int flags;
     86      1.1  christos #define ACB_ALLOC	0x01
     87      1.1  christos #define	ACB_NEXUS	0x02
     88      1.1  christos #define ACB_SENSE	0x04
     89      1.1  christos #define	ACB_ABORT	0x40
     90      1.1  christos #define	ACB_RESET	0x80
     91      1.1  christos 	int timeout;
     92      1.1  christos };
     93      1.1  christos 
     94      1.1  christos /*
     95      1.1  christos  * Some info about each (possible) target on the SCSI bus.  This should
     96      1.1  christos  * probably have been a "per target+lunit" structure, but we'll leave it at
     97      1.1  christos  * this for now.
     98      1.1  christos  */
     99      1.1  christos struct aic_tinfo {
    100      1.1  christos 	int	cmds;		/* #commands processed */
    101      1.1  christos 	int	dconns;		/* #disconnects */
    102      1.1  christos 	int	touts;		/* #timeouts */
    103      1.1  christos 	int	perrs;		/* #parity errors */
    104      1.1  christos 	int	senses;		/* #request sense commands sent */
    105      1.1  christos 	ushort	lubusy;		/* What local units/subr. are busy? */
    106      1.1  christos 	u_char  flags;
    107      1.1  christos #define DO_SYNC		0x01	/* (Re)Negotiate synchronous options */
    108      1.1  christos #define	DO_WIDE		0x02	/* (Re)Negotiate wide options */
    109      1.1  christos 	u_char  period;		/* Period suggestion */
    110      1.1  christos 	u_char  offset;		/* Offset suggestion */
    111      1.1  christos 	u_char	width;		/* Width suggestion */
    112      1.1  christos } tinfo_t;
    113      1.1  christos 
    114      1.1  christos struct aic_softc {
    115      1.1  christos 	struct device sc_dev;
    116      1.1  christos 
    117      1.1  christos 	bus_space_tag_t sc_iot;
    118      1.1  christos 	bus_space_handle_t sc_ioh;
    119      1.1  christos 
    120      1.1  christos 	struct scsipi_link sc_link;	/* prototype for subdevs */
    121      1.3   thorpej 	struct scsipi_adapter sc_adapter;
    122      1.1  christos 
    123      1.1  christos 	TAILQ_HEAD(, aic_acb) free_list, ready_list, nexus_list;
    124      1.1  christos 	struct aic_acb *sc_nexus;	/* current command */
    125      1.1  christos 	struct aic_acb sc_acb[8];
    126      1.1  christos 	struct aic_tinfo sc_tinfo[8];
    127      1.1  christos 
    128      1.1  christos 	/* Data about the current nexus (updated for every cmd switch) */
    129      1.1  christos 	u_char	*sc_dp;		/* Current data pointer */
    130      1.1  christos 	size_t	sc_dleft;	/* Data bytes left to transfer */
    131      1.1  christos 	u_char	*sc_cp;		/* Current command pointer */
    132      1.1  christos 	size_t	sc_cleft;	/* Command bytes left to transfer */
    133      1.1  christos 
    134      1.1  christos 	/* Adapter state */
    135      1.1  christos 	u_char	 sc_phase;	/* Current bus phase */
    136      1.1  christos 	u_char	 sc_prevphase;	/* Previous bus phase */
    137      1.1  christos 	u_char	 sc_state;	/* State applicable to the adapter */
    138      1.1  christos #define	AIC_INIT	0
    139      1.1  christos #define AIC_IDLE	1
    140      1.1  christos #define AIC_SELECTING	2	/* SCSI command is arbiting  */
    141      1.1  christos #define AIC_RESELECTED	3	/* Has been reselected */
    142      1.1  christos #define AIC_CONNECTED	4	/* Actively using the SCSI bus */
    143      1.1  christos #define	AIC_DISCONNECT	5	/* MSG_DISCONNECT received */
    144      1.1  christos #define	AIC_CMDCOMPLETE	6	/* MSG_CMDCOMPLETE received */
    145      1.1  christos #define AIC_CLEANING	7
    146      1.1  christos 	u_char	 sc_flags;
    147      1.1  christos #define AIC_DROP_MSGIN	0x01	/* Discard all msgs (parity err detected) */
    148      1.1  christos #define	AIC_ABORTING	0x02	/* Bailing out */
    149      1.1  christos #define AIC_DOINGDMA	0x04	/* The FIFO data path is active! */
    150      1.1  christos 	u_char	sc_selid;	/* Reselection ID */
    151  1.4.6.1  wrstuden 	struct device *sc_child;/* Our child */
    152  1.4.6.1  wrstuden 	u_char	sc_dying;	/* true if device is going */
    153      1.1  christos 
    154      1.1  christos 	/* Message stuff */
    155      1.1  christos 	u_char	sc_msgpriq;	/* Messages we want to send */
    156      1.1  christos 	u_char	sc_msgoutq;	/* Messages sent during last MESSAGE OUT */
    157      1.1  christos 	u_char	sc_lastmsg;	/* Message last transmitted */
    158      1.1  christos 	u_char	sc_currmsg;	/* Message currently ready to transmit */
    159      1.1  christos #define SEND_DEV_RESET		0x01
    160      1.1  christos #define SEND_PARITY_ERROR	0x02
    161      1.1  christos #define SEND_INIT_DET_ERR	0x04
    162      1.1  christos #define SEND_REJECT		0x08
    163      1.1  christos #define SEND_IDENTIFY  		0x10
    164      1.1  christos #define SEND_ABORT		0x20
    165      1.1  christos #define SEND_SDTR		0x40
    166      1.1  christos #define	SEND_WDTR		0x80
    167      1.1  christos #define AIC_MAX_MSG_LEN 8
    168      1.1  christos 	u_char  sc_omess[AIC_MAX_MSG_LEN];
    169      1.1  christos 	u_char	*sc_omp;		/* Outgoing message pointer */
    170      1.1  christos 	u_char	sc_imess[AIC_MAX_MSG_LEN];
    171      1.1  christos 	u_char	*sc_imp;		/* Incoming message pointer */
    172      1.1  christos 
    173      1.1  christos 	/* Hardware stuff */
    174      1.1  christos 	int	sc_initiator;		/* Our scsi id */
    175      1.1  christos 	int	sc_freq;		/* Clock frequency in MHz */
    176      1.1  christos 	int	sc_minsync;		/* Minimum sync period / 4 */
    177      1.1  christos 	int	sc_maxsync;		/* Maximum sync period / 4 */
    178      1.1  christos };
    179      1.1  christos 
    180      1.1  christos #if AIC_DEBUG
    181      1.1  christos #define AIC_SHOWACBS	0x01
    182      1.1  christos #define AIC_SHOWINTS	0x02
    183      1.1  christos #define AIC_SHOWCMDS	0x04
    184      1.1  christos #define AIC_SHOWMISC	0x08
    185      1.1  christos #define AIC_SHOWTRACE	0x10
    186      1.1  christos #define AIC_SHOWSTART	0x20
    187      1.1  christos #define AIC_DOBREAK	0x40
    188      1.1  christos extern int aic_debug; /* AIC_SHOWSTART|AIC_SHOWMISC|AIC_SHOWTRACE; */
    189      1.1  christos #define	AIC_PRINT(b, s)	do {if ((aic_debug & (b)) != 0) printf s;} while (0)
    190      1.1  christos #define	AIC_BREAK()	do {if ((aic_debug & AIC_DOBREAK) != 0) Debugger();} while (0)
    191      1.1  christos #define	AIC_ASSERT(x)	do {if (x) {} else {printf("%s at line %d: assertion failed\n", sc->sc_dev.dv_xname, __LINE__); Debugger();}} while (0)
    192      1.1  christos #else
    193      1.1  christos #define	AIC_PRINT(b, s)
    194      1.1  christos #define	AIC_BREAK()
    195      1.1  christos #define	AIC_ASSERT(x)
    196      1.1  christos #endif
    197      1.1  christos 
    198      1.1  christos #define AIC_ACBS(s)	AIC_PRINT(AIC_SHOWACBS, s)
    199      1.1  christos #define AIC_INTS(s)	AIC_PRINT(AIC_SHOWINTS, s)
    200      1.1  christos #define AIC_CMDS(s)	AIC_PRINT(AIC_SHOWCMDS, s)
    201      1.1  christos #define AIC_MISC(s)	AIC_PRINT(AIC_SHOWMISC, s)
    202      1.1  christos #define AIC_TRACE(s)	AIC_PRINT(AIC_SHOWTRACE, s)
    203      1.1  christos #define AIC_START(s)	AIC_PRINT(AIC_SHOWSTART, s)
    204      1.1  christos 
    205      1.1  christos #define AIC_ISA_IOSIZE	0x20	/* XXX */
    206      1.1  christos 
    207      1.1  christos void	aicattach	__P((struct aic_softc *));
    208      1.4     enami int	aic_activate	__P((struct device *, enum devact));
    209      1.4     enami int	aic_detach	__P((struct device *, int));
    210      1.1  christos int	aicintr		__P((void *));
    211      1.1  christos int	aic_find	__P((bus_space_tag_t, bus_space_handle_t));
    212      1.1  christos void	aic_isa_attach	__P((struct device *, struct device *, void *));
    213      1.4     enami void	aic_init	__P((struct aic_softc *, int));
    214