Home | History | Annotate | Line # | Download | only in ic
aic7xxxvar.h revision 1.19.10.1
      1  1.19.10.1   thorpej /*	$NetBSD: aic7xxxvar.h,v 1.19.10.1 1999/10/19 17:47:36 thorpej Exp $	*/
      2        1.7   thorpej 
      3        1.1   mycroft /*
      4        1.4   mycroft  * Interface to the generic driver for the aic7xxx based adaptec
      5        1.4   mycroft  * SCSI controllers.  This is used to implement product specific
      6        1.1   mycroft  * probe and attach routines.
      7        1.1   mycroft  *
      8        1.4   mycroft  * Copyright (c) 1994, 1995, 1996 Justin T. Gibbs.
      9        1.1   mycroft  * All rights reserved.
     10        1.1   mycroft  *
     11        1.1   mycroft  * Redistribution and use in source and binary forms, with or without
     12        1.1   mycroft  * modification, are permitted provided that the following conditions
     13        1.1   mycroft  * are met:
     14        1.1   mycroft  * 1. Redistributions of source code must retain the above copyright
     15        1.1   mycroft  *    notice immediately at the beginning of the file, without modification,
     16        1.1   mycroft  *    this list of conditions, and the following disclaimer.
     17        1.1   mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     18        1.1   mycroft  *    notice, this list of conditions and the following disclaimer in the
     19        1.1   mycroft  *    documentation and/or other materials provided with the distribution.
     20        1.4   mycroft  * 3. The name of the author may not be used to endorse or promote products
     21        1.4   mycroft  *    derived from this software without specific prior written permission.
     22        1.4   mycroft  *
     23        1.4   mycroft  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     24        1.4   mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25        1.4   mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26        1.4   mycroft  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     27        1.4   mycroft  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28        1.4   mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29        1.4   mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30        1.4   mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31        1.4   mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32        1.4   mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33        1.4   mycroft  * SUCH DAMAGE.
     34        1.8  explorer  *
     35        1.8  explorer  * from	Id: aic7xxx.h,v 1.28 1996/05/30 07:19:59 gibbs Exp
     36        1.1   mycroft  */
     37        1.1   mycroft 
     38        1.1   mycroft #ifndef _AIC7XXX_H_
     39        1.1   mycroft #define _AIC7XXX_H_
     40        1.1   mycroft 
     41        1.4   mycroft #if defined(__FreeBSD__)
     42        1.4   mycroft #include "ahc.h"                /* for NAHC from config */
     43        1.4   mycroft #endif
     44        1.4   mycroft 
     45        1.8  explorer #if defined(__NetBSD__)
     46       1.17  sommerfe 
     47       1.17  sommerfe #include "opt_ahc.h"		/* For AHC_DEBUG, AHC_TAGENABLE, AHC_BROKEN_CACHE */
     48       1.17  sommerfe 
     49        1.8  explorer /*
     50        1.8  explorer  * convert FreeBSD's <sys/queue.h> symbols to NetBSD's
     51        1.8  explorer  */
     52        1.8  explorer #define	STAILQ_ENTRY		SIMPLEQ_ENTRY
     53        1.8  explorer #define	STAILQ_HEAD		SIMPLEQ_HEAD
     54        1.8  explorer #define	STAILQ_INIT		SIMPLEQ_INIT
     55        1.8  explorer #define	STAILQ_INSERT_HEAD	SIMPLEQ_INSERT_HEAD
     56        1.8  explorer #define	STAILQ_INSERT_TAIL	SIMPLEQ_INSERT_TAIL
     57        1.8  explorer #define	STAILQ_REMOVE_HEAD(head, field)	\
     58        1.8  explorer 	SIMPLEQ_REMOVE_HEAD(head, (head)->sqh_first, field)
     59        1.8  explorer #define	stqh_first		sqh_first
     60        1.8  explorer #define	stqe_next		sqe_next
     61        1.8  explorer #endif
     62        1.8  explorer 
     63        1.4   mycroft #if defined(__FreeBSD__)
     64        1.4   mycroft #define	AHC_INB(ahc, port)	\
     65        1.4   mycroft 	inb((ahc)->baseport+(port))
     66        1.4   mycroft #define	AHC_INSB(ahc, port, valp, size)	\
     67        1.4   mycroft 	insb((ahc)->baseport+(port), valp, size)
     68        1.4   mycroft #define	AHC_OUTB(ahc, port, val)	\
     69        1.4   mycroft 	outb((ahc)->baseport+(port), val)
     70        1.4   mycroft #define	AHC_OUTSB(ahc, port, valp, size)	\
     71        1.4   mycroft 	outsb((ahc)->baseport+(port), valp, size)
     72        1.4   mycroft #define	AHC_OUTSL(ahc, port, valp, size)	\
     73        1.4   mycroft 	outsl((ahc)->baseport+(port), valp, size)
     74        1.4   mycroft #elif defined(__NetBSD__)
     75       1.16       leo 
     76       1.16       leo #ifndef __BUS_SPACE_HAS_STREAM_METHODS
     77       1.16       leo #define	bus_space_write_multi_stream_4	bus_space_write_multi_4
     78       1.16       leo #endif
     79       1.16       leo 
     80        1.4   mycroft #define	AHC_INB(ahc, port)	\
     81       1.13       cgd 	bus_space_read_1((ahc)->sc_st, (ahc)->sc_sh, port)
     82        1.4   mycroft #define	AHC_INSB(ahc, port, valp, size)	\
     83       1.13       cgd 	bus_space_read_multi_1((ahc)->sc_st, (ahc)->sc_sh, port, (u_int8_t *) valp, size)
     84        1.4   mycroft #define	AHC_OUTB(ahc, port, val)	\
     85       1.13       cgd 	bus_space_write_1((ahc)->sc_st, (ahc)->sc_sh, port, val)
     86        1.4   mycroft #define	AHC_OUTSB(ahc, port, valp, size)	\
     87       1.13       cgd 	bus_space_write_multi_1((ahc)->sc_st, (ahc)->sc_sh, port, (u_int8_t *) valp, size)
     88        1.4   mycroft #define	AHC_OUTSL(ahc, port, valp, size)	\
     89       1.16       leo 	bus_space_write_multi_stream_4((ahc)->sc_st, (ahc)->sc_sh, port, (u_int32_t *) valp, size)
     90        1.4   mycroft #endif
     91        1.4   mycroft 
     92        1.1   mycroft #define	AHC_NSEG	256	/* number of dma segments supported */
     93        1.1   mycroft 
     94        1.4   mycroft #define AHC_SCB_MAX	255	/*
     95        1.4   mycroft 				 * Up to 255 SCBs on some types of aic7xxx
     96        1.4   mycroft 				 * based boards.  The aic7870 have 16 internal
     97        1.4   mycroft 				 * SCBs, but external SRAM bumps this to 255.
     98        1.4   mycroft 				 * The aic7770 family have only 4, and the
     99        1.4   mycroft 				 * aic7850 has only 3.
    100        1.1   mycroft 				 */
    101        1.1   mycroft 
    102        1.1   mycroft 
    103        1.9     gibbs typedef u_int32_t physaddr;
    104        1.4   mycroft #if defined(__FreeBSD__)
    105        1.4   mycroft extern u_long ahc_unit;
    106        1.4   mycroft #endif
    107        1.1   mycroft 
    108        1.1   mycroft struct ahc_dma_seg {
    109        1.9     gibbs 	physaddr	addr;
    110        1.9     gibbs 	u_int32_t	len;
    111        1.1   mycroft };
    112        1.4   mycroft 
    113        1.4   mycroft typedef enum {
    114        1.4   mycroft 	AHC_NONE	= 0x000,
    115        1.4   mycroft 	AHC_ULTRA	= 0x001,	/* Supports 20MHz Transfers */
    116        1.4   mycroft 	AHC_WIDE  	= 0x002,	/* Wide Channel */
    117        1.4   mycroft 	AHC_TWIN	= 0x008,	/* Twin Channel */
    118        1.4   mycroft 	AHC_AIC7770	= 0x010,
    119        1.4   mycroft 	AHC_AIC7850	= 0x020,
    120        1.4   mycroft 	AHC_AIC7860	= 0x021,	/* ULTRA version of the aic7850 */
    121        1.4   mycroft 	AHC_AIC7870	= 0x040,
    122        1.4   mycroft 	AHC_AIC7880	= 0x041,
    123        1.4   mycroft 	AHC_AIC78X0	= 0x060,	/* PCI Based Controller */
    124        1.4   mycroft 	AHC_274		= 0x110,	/* EISA Based Controller */
    125        1.4   mycroft 	AHC_284		= 0x210,	/* VL/ISA Based Controller */
    126        1.9     gibbs 	AHC_294AU	= 0x421,	/* aic7860 based '2940' */
    127        1.4   mycroft 	AHC_294		= 0x440,	/* PCI Based Controller */
    128        1.4   mycroft 	AHC_294U	= 0x441,	/* ULTRA PCI Based Controller */
    129        1.4   mycroft 	AHC_394		= 0x840,	/* Twin Channel PCI Controller */
    130        1.4   mycroft 	AHC_394U	= 0x841,	/* Twin, ULTRA Channel PCI Controller */
    131        1.4   mycroft }ahc_type;
    132        1.4   mycroft 
    133        1.4   mycroft typedef enum {
    134        1.4   mycroft 	AHC_FNONE		= 0x00,
    135        1.4   mycroft 	AHC_INIT		= 0x01,
    136        1.4   mycroft 	AHC_RUNNING		= 0x02,
    137        1.4   mycroft 	AHC_PAGESCBS		= 0x04,	/* Enable SCB paging */
    138        1.4   mycroft 	AHC_CHANNEL_B_PRIMARY	= 0x08,	/*
    139        1.4   mycroft 					 * On twin channel adapters, probe
    140        1.4   mycroft 					 * channel B first since it is the
    141        1.4   mycroft 					 * primary bus.
    142        1.4   mycroft 					 */
    143        1.4   mycroft 	AHC_USEDEFAULTS		= 0x10,	/*
    144        1.4   mycroft 					 * For cards without an seeprom
    145        1.4   mycroft 					 * or a BIOS to initialize the chip's
    146        1.4   mycroft 					 * SRAM, we use the default target
    147        1.4   mycroft 					 * settings.
    148        1.4   mycroft 					 */
    149        1.4   mycroft 	AHC_CHNLB		= 0x20,	/*
    150        1.4   mycroft 					 * Second controller on 3940
    151        1.4   mycroft 					 * Also encodes the offset in the
    152        1.4   mycroft 					 * SEEPROM for CHNLB info (32)
    153        1.4   mycroft 					 */
    154        1.4   mycroft }ahc_flag;
    155        1.4   mycroft 
    156        1.4   mycroft typedef enum {
    157        1.9     gibbs 	SCB_FREE		= 0x0000,
    158        1.9     gibbs 	SCB_ACTIVE		= 0x0001,
    159        1.9     gibbs 	SCB_ABORTED		= 0x0002,
    160        1.9     gibbs 	SCB_DEVICE_RESET	= 0x0004,
    161        1.9     gibbs 	SCB_IMMED		= 0x0008,
    162        1.9     gibbs 	SCB_SENSE		= 0x0010,
    163        1.9     gibbs 	SCB_TIMEDOUT		= 0x0020,
    164        1.9     gibbs 	SCB_QUEUED_FOR_DONE	= 0x0040,
    165        1.9     gibbs 	SCB_PAGED_OUT		= 0x0080,
    166        1.9     gibbs 	SCB_WAITINGQ		= 0x0100,
    167        1.9     gibbs 	SCB_ASSIGNEDQ		= 0x0200,
    168        1.9     gibbs 	SCB_SENTORDEREDTAG	= 0x0400,
    169        1.9     gibbs 	SCB_MSGOUT_SDTR		= 0x0800,
    170        1.9     gibbs 	SCB_MSGOUT_WDTR		= 0x1000
    171        1.4   mycroft }scb_flag;
    172        1.1   mycroft 
    173        1.1   mycroft /*
    174        1.1   mycroft  * The driver keeps up to MAX_SCB scb structures per card in memory.  Only the
    175        1.4   mycroft  * first 28 bytes of the structure need to be transfered to the card during
    176        1.4   mycroft  * normal operation.  The fields starting at byte 28 are used for kernel level
    177        1.4   mycroft  * bookkeeping.
    178        1.1   mycroft  */
    179        1.4   mycroft struct scb {
    180        1.1   mycroft /* ------------    Begin hardware supported fields    ---------------- */
    181        1.4   mycroft /*0*/   u_char control;
    182        1.4   mycroft /*1*/	u_char tcl;		/* 4/1/3 bits */
    183        1.4   mycroft /*2*/	u_char status;
    184        1.1   mycroft /*3*/	u_char SG_segment_count;
    185        1.4   mycroft /*4*/	physaddr SG_list_pointer;
    186        1.4   mycroft /*8*/	u_char residual_SG_segment_count;
    187        1.4   mycroft /*9*/	u_char residual_data_count[3];
    188        1.4   mycroft /*12*/	physaddr data;
    189        1.9     gibbs /*16*/  u_int32_t datalen;		/* Really only three bits, but its
    190        1.4   mycroft 					 * faster to treat it as a long on
    191        1.4   mycroft 					 * a quad boundary.
    192        1.4   mycroft 					 */
    193        1.4   mycroft /*20*/	physaddr cmdpointer;
    194        1.4   mycroft /*24*/	u_char cmdlen;
    195        1.4   mycroft /*25*/	u_char tag;			/* Index into our kernel SCB array.
    196        1.4   mycroft 					 * Also used as the tag for tagged I/O
    197        1.4   mycroft 					 */
    198        1.4   mycroft #define SCB_PIO_TRANSFER_SIZE	26 	/* amount we need to upload/download
    199        1.4   mycroft 					 * via PIO to initialize a transaction.
    200        1.4   mycroft 					 */
    201        1.4   mycroft /*26*/	u_char next;			/* Used for threading SCBs in the
    202        1.4   mycroft 					 * "Waiting for Selection" and
    203        1.4   mycroft 					 * "Disconnected SCB" lists down
    204        1.4   mycroft 					 * in the sequencer.
    205        1.4   mycroft 					 */
    206        1.4   mycroft /*27*/	u_char prev;
    207        1.4   mycroft /*-----------------end of hardware supported fields----------------*/
    208        1.8  explorer 	STAILQ_ENTRY(scb)	links;	/* for chaining */
    209       1.14    bouyer 	struct scsipi_xfer *xs;	/* the scsipi_xfer for this cmd */
    210        1.4   mycroft 	scb_flag flags;
    211        1.4   mycroft 	u_char	position;	/* Position in card's scbarray */
    212       1.12       cgd 	struct ahc_dma_seg ahc_dma[AHC_NSEG];
    213       1.14    bouyer 	struct scsipi_sense sense_cmd;	/* SCSI command block */
    214       1.15       leo 
    215       1.15       leo #if defined(__NetBSD__)
    216       1.15       leo 	/*
    217       1.15       leo 	 * This DMA map maps the buffer involved in the transfer.
    218       1.15       leo 	 * Its contents are loaded into "ahc_dma" above.
    219       1.15       leo 	 */
    220       1.15       leo 	bus_dmamap_t dmamap_xfer;
    221       1.15       leo 
    222       1.15       leo 	struct scsi_generic scsi_cmd;	/* dma-able copy of xs->cmd */
    223       1.15       leo 	struct scsipi_sense_data scsi_sense;
    224       1.15       leo #endif
    225        1.1   mycroft };
    226        1.1   mycroft 
    227        1.4   mycroft struct ahc_data {
    228        1.4   mycroft #if defined(__FreeBSD__)
    229        1.4   mycroft 	int	unit;
    230        1.4   mycroft #elif defined(__NetBSD__)
    231        1.4   mycroft 	struct device sc_dev;
    232        1.4   mycroft 	void	*sc_ih;
    233       1.13       cgd 	bus_space_tag_t sc_st;
    234       1.13       cgd 	bus_space_handle_t sc_sh;
    235       1.15       leo 	bus_dma_tag_t sc_dt;
    236       1.15       leo 	int	sc_dmaflags;
    237       1.15       leo 
    238       1.15       leo 	bus_dmamap_t sc_dmamap_control;		/* Maps the control blocks */
    239        1.1   mycroft #endif
    240        1.4   mycroft 	ahc_type type;
    241        1.4   mycroft 	ahc_flag flags;
    242        1.4   mycroft #if defined(__FreeBSD__)
    243        1.4   mycroft 	u_long	baseport;
    244        1.1   mycroft #endif
    245        1.4   mycroft 	struct	scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */
    246        1.4   mycroft 	struct	scb *pagedout_ntscbs[16];/*
    247        1.4   mycroft 					  * Paged out, non-tagged scbs
    248        1.4   mycroft 					  * indexed by target.
    249        1.4   mycroft 					  */
    250        1.8  explorer 	STAILQ_HEAD(, scb) free_scbs;	/*
    251        1.4   mycroft 					 * SCBs assigned to free slots
    252        1.4   mycroft 					 * on the card. (no paging required)
    253        1.4   mycroft 					 */
    254        1.8  explorer 	STAILQ_HEAD(, scb) page_scbs;	/*
    255        1.4   mycroft 					 * SCBs that will require paging
    256        1.4   mycroft 					 * before use (no assigned slot)
    257        1.4   mycroft 					 */
    258        1.8  explorer 	STAILQ_HEAD(, scb) waiting_scbs;/*
    259        1.4   mycroft 					 * SCBs waiting to be paged in
    260        1.4   mycroft 					 * and started.
    261        1.4   mycroft 					 */
    262        1.8  explorer 	STAILQ_HEAD(, scb)assigned_scbs;/*
    263        1.4   mycroft 					 * SCBs that were waiting but have
    264        1.4   mycroft 					 * now been assigned a slot by
    265        1.4   mycroft 					 * ahc_free_scb.
    266        1.4   mycroft 					 */
    267  1.19.10.1   thorpej 
    268       1.18   thorpej 	struct	scsipi_adapter sc_adapter;
    269  1.19.10.1   thorpej 	struct	scsipi_channel sc_channels[2];
    270  1.19.10.1   thorpej 
    271        1.1   mycroft 	u_short	needsdtr_orig;		/* Targets we initiate sync neg with */
    272        1.1   mycroft 	u_short	needwdtr_orig;		/* Targets we initiate wide neg with */
    273        1.1   mycroft 	u_short	needsdtr;		/* Current list of negotiated targets */
    274        1.1   mycroft 	u_short needwdtr;		/* Current list of negotiated targets */
    275        1.1   mycroft 	u_short sdtrpending;		/* Pending SDTR to these targets */
    276        1.1   mycroft 	u_short wdtrpending;		/* Pending WDTR to these targets */
    277        1.1   mycroft 	u_short	tagenable;		/* Targets that can handle tagqueing */
    278        1.4   mycroft 	u_short	orderedtag;		/* Targets to use ordered tag on */
    279        1.4   mycroft 	u_short	discenable;		/* Targets allowed to disconnect */
    280        1.4   mycroft 	u_char	our_id;			/* our scsi id */
    281        1.4   mycroft 	u_char	our_id_b;		/* B channel scsi id */
    282        1.4   mycroft 	u_char	numscbs;
    283        1.4   mycroft 	u_char	activescbs;
    284        1.4   mycroft 	u_char  maxhscbs;		/* Number of SCBs on the card */
    285        1.4   mycroft 	u_char	maxscbs;		/*
    286        1.4   mycroft 					 * Max SCBs we allocate total including
    287        1.4   mycroft 					 * any that will force us to page SCBs
    288        1.4   mycroft 					 */
    289        1.4   mycroft 	u_char	qcntmask;
    290        1.1   mycroft 	u_char	unpause;
    291        1.1   mycroft 	u_char	pause;
    292        1.4   mycroft 	u_char	in_timeout;
    293        1.1   mycroft };
    294        1.4   mycroft 
    295        1.4   mycroft /* #define AHC_DEBUG */
    296        1.4   mycroft #ifdef AHC_DEBUG
    297        1.4   mycroft /* Different debugging levels used when AHC_DEBUG is defined */
    298        1.4   mycroft #define AHC_SHOWMISC	0x0001
    299        1.4   mycroft #define AHC_SHOWCMDS	0x0002
    300        1.4   mycroft #define AHC_SHOWSCBS	0x0004
    301        1.4   mycroft #define AHC_SHOWABORTS	0x0008
    302        1.4   mycroft #define AHC_SHOWSENSE	0x0010
    303        1.4   mycroft #define AHC_SHOWSCBCNT	0x0020
    304        1.4   mycroft 
    305        1.4   mycroft extern int ahc_debug; /* Initialized in i386/scsi/aic7xxx.c */
    306        1.4   mycroft #endif
    307        1.4   mycroft 
    308        1.4   mycroft #if defined(__FreeBSD__)
    309        1.4   mycroft 
    310        1.4   mycroft char *ahc_name __P((struct ahc_data *ahc));
    311        1.4   mycroft 
    312        1.4   mycroft void ahc_reset __P((u_long iobase));
    313        1.4   mycroft struct ahc_data *ahc_alloc __P((int unit, u_long io_base, ahc_type type, ahc_flag flags));
    314        1.4   mycroft #elif defined(__NetBSD__)
    315        1.4   mycroft 
    316        1.4   mycroft #define	ahc_name(ahc)	(ahc)->sc_dev.dv_xname
    317        1.4   mycroft 
    318       1.13       cgd void	ahc_reset __P((char *devname, bus_space_tag_t st,
    319       1.13       cgd 	    bus_space_handle_t sh));
    320       1.13       cgd void	ahc_construct __P((struct ahc_data *ahc, bus_space_tag_t st,
    321       1.15       leo 	    bus_space_handle_t sh, bus_dma_tag_t dt, ahc_type type,
    322       1.15       leo 	    ahc_flag flags));
    323        1.4   mycroft #endif
    324       1.10   thorpej void	ahc_free __P((struct ahc_data *));
    325       1.10   thorpej int	ahc_init __P((struct ahc_data *));
    326       1.10   thorpej int	ahc_attach __P((struct ahc_data *));
    327        1.4   mycroft #if defined(__FreeBSD__)
    328       1.10   thorpej void	ahc_intr __P((void *arg));
    329        1.4   mycroft #elif defined(__NetBSD__)
    330       1.10   thorpej int	ahc_intr __P((void *arg));
    331        1.4   mycroft #endif
    332        1.1   mycroft 
    333        1.1   mycroft #endif  /* _AIC7XXX_H_ */
    334