Home | History | Annotate | Line # | Download | only in ic
aic7xxxvar.h revision 1.23.2.1
      1  1.23.2.1   minoura /*	$NetBSD: aic7xxxvar.h,v 1.23.2.1 2000/06/22 17:06:34 minoura 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.21      fvdl  * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999, 2000 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.21      fvdl  *    notice, this list of conditions, and the following disclaimer,
     16      1.21      fvdl  *    without modification.
     17      1.21      fvdl  * 2. The name of the author may not be used to endorse or promote products
     18       1.4   mycroft  *    derived from this software without specific prior written permission.
     19       1.4   mycroft  *
     20      1.21      fvdl  * Alternatively, this software may be distributed under the terms of the
     21      1.21      fvdl  * the GNU Public License ("GPL").
     22      1.21      fvdl  *
     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.21      fvdl  * $FreeBSD: src/sys/dev/aic7xxx/aic7xxx.h,v 1.16 2000/02/09 21:24: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.21      fvdl #ifndef MAX
     42      1.21      fvdl #define MAX(a,b) (((a) > (b)) ? (a) : (b))
     43       1.4   mycroft #endif
     44       1.4   mycroft 
     45      1.21      fvdl #ifndef MIN
     46      1.21      fvdl #define MIN(a,b) (((a) < (b)) ? (a) : (b))
     47      1.21      fvdl #endif
     48      1.17  sommerfe 
     49      1.21      fvdl #ifndef FALSE
     50      1.21      fvdl #define FALSE 0
     51      1.21      fvdl #endif
     52      1.21      fvdl 
     53      1.21      fvdl #ifndef TRUE
     54      1.21      fvdl #define TRUE 1
     55      1.21      fvdl #endif
     56      1.17  sommerfe 
     57       1.8  explorer /*
     58      1.21      fvdl  * The maximum transfer per S/G segment.
     59       1.8  explorer  */
     60      1.21      fvdl #define AHC_MAXTRANSFER_SIZE	ctob(AHC_NSEG - 1)
     61       1.8  explorer 
     62      1.21      fvdl /*
     63      1.21      fvdl  * Convert FreeBSD queue macro
     64      1.21      fvdl  */
     65      1.21      fvdl #define STAILQ_ENTRY SIMPLEQ_ENTRY
     66      1.16       leo 
     67      1.21      fvdl /*
     68      1.21      fvdl  * The number of dma segments supported.  The current implementation limits
     69      1.21      fvdl  * us to 255 S/G entries (this may change to be unlimited at some point).
     70      1.21      fvdl  * To reduce the driver's memory consumption, we further limit the number
     71      1.21      fvdl  * supported to be sufficient to handle the largest mapping supported by
     72      1.21      fvdl  * the kernel, MAXPHYS.  Assuming the transfer is as fragmented as possible
     73      1.21      fvdl  * and unaligned, this turns out to be the number of paged sized transfers
     74      1.21      fvdl  * in MAXPHYS plus an extra element to handle any unaligned residual.
     75      1.21      fvdl  */
     76      1.21      fvdl #define AHC_NSEG (MIN(btoc(MAXPHYS) + 1, 255))
     77       1.1   mycroft 
     78       1.4   mycroft #define AHC_SCB_MAX	255	/*
     79       1.4   mycroft 				 * Up to 255 SCBs on some types of aic7xxx
     80       1.4   mycroft 				 * based boards.  The aic7870 have 16 internal
     81       1.4   mycroft 				 * SCBs, but external SRAM bumps this to 255.
     82       1.4   mycroft 				 * The aic7770 family have only 4, and the
     83       1.4   mycroft 				 * aic7850 has only 3.
     84       1.1   mycroft 				 */
     85       1.1   mycroft 
     86      1.21      fvdl #define AHC_TMODE_CMDS	256    /*
     87      1.21      fvdl 				* Ring Buffer of incoming target commands.
     88      1.21      fvdl 				* We allocate 256 to simplify the logic
     89      1.21      fvdl 				* in the sequencer by using the natural
     90      1.21      fvdl 				* wrap point of an 8bit counter.
     91      1.21      fvdl 				*/
     92       1.1   mycroft 
     93       1.1   mycroft struct ahc_dma_seg {
     94      1.21      fvdl 	u_int32_t	addr;
     95       1.9     gibbs 	u_int32_t	len;
     96       1.1   mycroft };
     97       1.4   mycroft 
     98       1.4   mycroft typedef enum {
     99      1.21      fvdl 	AHC_NONE	= 0x0000,
    100      1.21      fvdl 	AHC_CHIPID_MASK	= 0x00FF,
    101      1.21      fvdl 	AHC_AIC7770	= 0x0001,
    102      1.21      fvdl 	AHC_AIC7850	= 0x0002,
    103      1.21      fvdl 	AHC_AIC7855	= 0x0003,
    104      1.21      fvdl 	AHC_AIC7859	= 0x0004,
    105      1.21      fvdl 	AHC_AIC7860	= 0x0005,
    106      1.21      fvdl 	AHC_AIC7870	= 0x0006,
    107      1.21      fvdl 	AHC_AIC7880	= 0x0007,
    108      1.21      fvdl 	AHC_AIC7890	= 0x0008,
    109      1.21      fvdl 	AHC_AIC7892	= 0x0009,
    110      1.21      fvdl 	AHC_AIC7895	= 0x000a,
    111      1.21      fvdl 	AHC_AIC7896	= 0x000b,
    112      1.21      fvdl 	AHC_AIC7899	= 0x000c,
    113      1.21      fvdl 	AHC_VL		= 0x0100,	/* Bus type VL */
    114      1.21      fvdl 	AHC_EISA	= 0x0200,	/* Bus type EISA */
    115      1.21      fvdl 	AHC_PCI		= 0x0400,	/* Bus type PCI */
    116      1.21      fvdl 	AHC_BUS_MASK	= 0x0F00
    117      1.21      fvdl } ahc_chip;
    118      1.21      fvdl 
    119      1.21      fvdl extern char *ahc_chip_names[];
    120      1.21      fvdl 
    121      1.21      fvdl typedef enum {
    122      1.21      fvdl 	AHC_FENONE	= 0x0000,
    123      1.21      fvdl 	AHC_ULTRA	= 0x0001,	/* Supports 20MHz Transfers */
    124      1.21      fvdl 	AHC_ULTRA2	= 0x0002,	/* Supports 40MHz Transfers */
    125      1.21      fvdl 	AHC_WIDE  	= 0x0004,	/* Wide Channel */
    126      1.21      fvdl 	AHC_TWIN	= 0x0008,	/* Twin Channel */
    127      1.21      fvdl 	AHC_MORE_SRAM	= 0x0010,	/* 80 bytes instead of 64 */
    128      1.21      fvdl 	AHC_CMD_CHAN	= 0x0020,	/* Has a Command DMA Channel */
    129      1.21      fvdl 	AHC_QUEUE_REGS	= 0x0040,	/* Has Queue management registers */
    130      1.21      fvdl 	AHC_SG_PRELOAD	= 0x0080,	/* Can perform auto-SG preload */
    131      1.21      fvdl 	AHC_SPIOCAP	= 0x0100,	/* Has a Serial Port I/O Cap Register */
    132      1.21      fvdl 	AHC_MULTI_TID	= 0x0200,	/* Has bitmask of TIDs for select-in */
    133      1.21      fvdl 	AHC_HS_MAILBOX	= 0x0400,	/* Has HS_MAILBOX register */
    134      1.21      fvdl 	AHC_DT		= 0x0800,	/* Double Transition transfers */
    135      1.21      fvdl 	AHC_NEW_TERMCTL	= 0x1000,
    136      1.21      fvdl 	AHC_MULTI_FUNC	= 0x2000,	/* Multi-Function Twin Channel Device */
    137      1.21      fvdl 	AHC_TARG_DMABUG	= 0x4000,	/* WideOdd Data-In bug in TMODE */
    138      1.21      fvdl 	AHC_AIC7770_FE	= AHC_TARG_DMABUG,
    139      1.21      fvdl 	AHC_AIC7850_FE	= AHC_TARG_DMABUG|AHC_SPIOCAP,
    140      1.21      fvdl 	AHC_AIC7855_FE	= AHC_AIC7850_FE,
    141      1.21      fvdl 	AHC_AIC7859_FE	= AHC_AIC7850_FE|AHC_ULTRA,
    142      1.21      fvdl 	AHC_AIC7860_FE	= AHC_AIC7859_FE,
    143      1.21      fvdl 	AHC_AIC7870_FE	= AHC_TARG_DMABUG,
    144      1.21      fvdl 	AHC_AIC7880_FE	= AHC_TARG_DMABUG|AHC_ULTRA,
    145      1.21      fvdl 	AHC_AIC7890_FE	= AHC_MORE_SRAM|AHC_CMD_CHAN|AHC_ULTRA2|AHC_QUEUE_REGS
    146      1.21      fvdl 			  |AHC_SG_PRELOAD|AHC_MULTI_TID|AHC_HS_MAILBOX
    147      1.21      fvdl 			  |AHC_NEW_TERMCTL,
    148      1.21      fvdl 	AHC_AIC7892_FE	= AHC_AIC7890_FE|AHC_DT,
    149      1.21      fvdl 	AHC_AIC7895_FE	= AHC_AIC7880_FE|AHC_MORE_SRAM
    150      1.21      fvdl 			  |AHC_CMD_CHAN|AHC_MULTI_FUNC,
    151      1.21      fvdl 	AHC_AIC7895C_FE	= AHC_AIC7895_FE|AHC_MULTI_TID,
    152      1.21      fvdl 	AHC_AIC7896_FE	= AHC_AIC7890_FE|AHC_MULTI_FUNC,
    153      1.21      fvdl 	AHC_AIC7899_FE	= AHC_AIC7892_FE|AHC_MULTI_FUNC
    154      1.21      fvdl } ahc_feature;
    155       1.4   mycroft 
    156       1.4   mycroft typedef enum {
    157      1.21      fvdl 	AHC_FNONE		= 0x000,
    158      1.21      fvdl 	AHC_PAGESCBS		= 0x001,/* Enable SCB paging */
    159      1.21      fvdl 	AHC_CHANNEL_B_PRIMARY	= 0x002,/*
    160       1.4   mycroft 					 * On twin channel adapters, probe
    161       1.4   mycroft 					 * channel B first since it is the
    162       1.4   mycroft 					 * primary bus.
    163       1.4   mycroft 					 */
    164      1.21      fvdl 	AHC_USEDEFAULTS		= 0x004,/*
    165       1.4   mycroft 					 * For cards without an seeprom
    166       1.4   mycroft 					 * or a BIOS to initialize the chip's
    167       1.4   mycroft 					 * SRAM, we use the default target
    168       1.4   mycroft 					 * settings.
    169       1.4   mycroft 					 */
    170      1.21      fvdl 	AHC_SHARED_SRAM		= 0x010,
    171      1.21      fvdl 	AHC_LARGE_SEEPROM	= 0x020,/* Uses C56_66 not C46 */
    172      1.21      fvdl 	AHC_RESET_BUS_A		= 0x040,
    173      1.21      fvdl 	AHC_RESET_BUS_B		= 0x080,
    174      1.21      fvdl 	AHC_EXTENDED_TRANS_A	= 0x100,
    175      1.21      fvdl 	AHC_EXTENDED_TRANS_B	= 0x200,
    176      1.21      fvdl 	AHC_TERM_ENB_A		= 0x400,
    177      1.21      fvdl 	AHC_TERM_ENB_B		= 0x800,
    178      1.21      fvdl 	AHC_INITIATORMODE	= 0x1000,/*
    179      1.21      fvdl 					  * Allow initiator operations on
    180      1.21      fvdl 					  * this controller.
    181      1.21      fvdl 					  */
    182      1.21      fvdl 	AHC_TARGETMODE		= 0x2000,/*
    183      1.21      fvdl 					  * Allow target operations on this
    184      1.21      fvdl 					  * controller.
    185      1.21      fvdl 					  */
    186      1.21      fvdl 	AHC_NEWEEPROM_FMT	= 0x4000,
    187      1.21      fvdl 	AHC_RESOURCE_SHORTAGE	= 0x8000,
    188      1.21      fvdl 	AHC_TQINFIFO_BLOCKED	= 0x10000,/* Blocked waiting for ATIOs */
    189      1.21      fvdl 	AHC_INT50_SPEEDFLEX	= 0x20000,/*
    190      1.21      fvdl 					   * Internal 50pin connector
    191      1.21      fvdl 					   * sits behind an aic3860
    192      1.21      fvdl 					   */
    193      1.21      fvdl } ahc_flag;
    194       1.4   mycroft 
    195       1.4   mycroft typedef enum {
    196       1.9     gibbs 	SCB_FREE		= 0x0000,
    197      1.21      fvdl 	SCB_OTHERTCL_TIMEOUT	= 0x0002,/*
    198      1.21      fvdl 					  * Another device was active
    199      1.21      fvdl 					  * during the first timeout for
    200      1.21      fvdl 					  * this SCB so we gave ourselves
    201      1.21      fvdl 					  * an additional timeout period
    202      1.21      fvdl 					  * in case it was hogging the
    203      1.21      fvdl 					  * bus.
    204      1.21      fvdl 				          */
    205       1.9     gibbs 	SCB_DEVICE_RESET	= 0x0004,
    206      1.21      fvdl 	SCB_SENSE		= 0x0008,
    207      1.21      fvdl 	SCB_FREEZE_QUEUE	= 0x0010,
    208      1.21      fvdl 	SCB_REQUEUE		= 0x0020,
    209      1.21      fvdl 	SCB_RECOVERY_SCB	= 0x0040,
    210      1.21      fvdl 	SCB_ABORT		= 0x1000,
    211      1.21      fvdl 	SCB_QUEUED_MSG		= 0x2000,
    212      1.21      fvdl 	SCB_ACTIVE		= 0x4000,
    213      1.21      fvdl 	SCB_TARGET_IMMEDIATE	= 0x8000
    214      1.21      fvdl } scb_flag;
    215      1.21      fvdl 
    216      1.21      fvdl typedef enum {
    217      1.21      fvdl 	MSGLOOP_IN_PROG,
    218      1.21      fvdl 	MSGLOOP_MSGCOMPLETE,
    219      1.21      fvdl 	MSGLOOP_TERMINATED
    220      1.21      fvdl } msg_loop_stat;
    221      1.21      fvdl 
    222      1.21      fvdl /*
    223      1.21      fvdl  * The driver keeps up to MAX_SCB scb structures per card in memory.  The SCB
    224      1.21      fvdl  * consists of a "hardware SCB" mirroring the fields availible on the card
    225      1.21      fvdl  * and additional information the kernel stores for each transaction.
    226       1.1   mycroft  */
    227      1.21      fvdl struct hardware_scb {
    228      1.21      fvdl /*0*/   u_int8_t  control;
    229      1.21      fvdl /*1*/	u_int8_t  tcl;		/* 4/1/3 bits */
    230      1.21      fvdl /*2*/	u_int8_t  status;
    231      1.21      fvdl /*3*/	u_int8_t  SG_count;
    232      1.21      fvdl /*4*/	u_int32_t SG_pointer;
    233      1.21      fvdl /*8*/	u_int8_t  residual_SG_count;
    234      1.21      fvdl /*9*/	u_int8_t  residual_data_count[3];
    235      1.21      fvdl /*12*/	u_int32_t data;
    236      1.21      fvdl /*16*/	u_int32_t datalen;		/* Really only three bytes, but its
    237       1.4   mycroft 					 * faster to treat it as a long on
    238       1.4   mycroft 					 * a quad boundary.
    239       1.4   mycroft 					 */
    240      1.21      fvdl /*20*/	u_int32_t cmdpointer;
    241      1.21      fvdl /*24*/	u_int8_t  cmdlen;
    242      1.21      fvdl /*25*/	u_int8_t  tag;			/* Index into our kernel SCB array.
    243       1.4   mycroft 					 * Also used as the tag for tagged I/O
    244       1.4   mycroft 					 */
    245      1.21      fvdl /*26*/	u_int8_t  next;			/* Used for threading SCBs in the
    246       1.4   mycroft 					 * "Waiting for Selection" and
    247       1.4   mycroft 					 * "Disconnected SCB" lists down
    248       1.4   mycroft 					 * in the sequencer.
    249       1.4   mycroft 					 */
    250      1.21      fvdl /*27*/	u_int8_t  scsirate;		/* Value for SCSIRATE register */
    251      1.21      fvdl /*28*/	u_int8_t  scsioffset;		/* Value for SCSIOFFSET register */
    252      1.21      fvdl /*29*/	u_int8_t  spare[3];		/*
    253      1.21      fvdl 					 * Spare space available on
    254      1.21      fvdl 					 * all controller types.
    255      1.21      fvdl 					 */
    256      1.21      fvdl /*32*/	u_int8_t  cmdstore[16];		/*
    257      1.21      fvdl 					 * CDB storage for controllers
    258      1.21      fvdl 					 * supporting 64 byte SCBs.
    259      1.21      fvdl 					 */
    260      1.21      fvdl /*48*/	u_int32_t cmdstore_busaddr;	/*
    261      1.21      fvdl 					 * Address of command store for
    262      1.21      fvdl 					 * 32byte SCB adapters
    263      1.21      fvdl 					 */
    264      1.21      fvdl /*48*/	u_int8_t  spare_64[12];		/*
    265      1.21      fvdl 					 * Pad to 64 bytes.
    266      1.21      fvdl 					 */
    267      1.21      fvdl };
    268      1.21      fvdl 
    269      1.21      fvdl struct scb {
    270      1.21      fvdl 	struct	hardware_scb	*hscb;
    271      1.21      fvdl 	SLIST_ENTRY(scb)	 links;	 /* for chaining */
    272      1.21      fvdl 	LIST_ENTRY(scb)	 	plinks; /* pending chain */
    273      1.21      fvdl 	struct scsipi_xfer	*xs;
    274      1.21      fvdl 	scb_flag		 flags;
    275      1.21      fvdl 	bus_dmamap_t		 dmamap;
    276      1.21      fvdl 	struct	ahc_dma_seg 	*sg_list;
    277      1.21      fvdl 	bus_addr_t		 sg_list_phys;
    278      1.21      fvdl 	u_int			 sg_count;/* How full ahc_dma_seg is */
    279      1.21      fvdl };
    280      1.21      fvdl 
    281      1.21      fvdl /*
    282      1.21      fvdl  * Connection desciptor for select-in requests in target mode.
    283      1.21      fvdl  * The first byte is the connecting target, followed by identify
    284      1.21      fvdl  * message and optional tag information, terminated by 0xFF.  The
    285      1.21      fvdl  * remainder is the command to execute.  The cmd_valid byte is on
    286      1.21      fvdl  * an 8 byte boundary to simplify setting it on aic7880 hardware
    287      1.21      fvdl  * which only has limited direct access to the DMA FIFO.
    288      1.21      fvdl  */
    289      1.21      fvdl struct target_cmd {
    290      1.21      fvdl 	u_int8_t initiator_channel;
    291      1.21      fvdl 	u_int8_t targ_id;	/* Target ID we were selected at */
    292      1.21      fvdl 	u_int8_t identify;	/* Identify message */
    293      1.21      fvdl 	u_int8_t bytes[21];
    294      1.21      fvdl 	u_int8_t cmd_valid;
    295      1.21      fvdl 	u_int8_t pad[7];
    296      1.21      fvdl };
    297      1.21      fvdl 
    298      1.21      fvdl /*
    299      1.21      fvdl  * Number of events we can buffer up if we run out
    300      1.21      fvdl  * of immediate notify ccbs.
    301      1.21      fvdl  */
    302      1.21      fvdl #define AHC_TMODE_EVENT_BUFFER_SIZE 8
    303      1.21      fvdl struct ahc_tmode_event {
    304      1.21      fvdl 	u_int8_t initiator_id;
    305      1.21      fvdl 	u_int8_t event_type;	/* MSG type or EVENT_TYPE_BUS_RESET */
    306      1.21      fvdl #define	EVENT_TYPE_BUS_RESET 0xFF
    307      1.21      fvdl 	u_int8_t event_arg;
    308      1.21      fvdl };
    309      1.21      fvdl 
    310      1.21      fvdl /*
    311      1.21      fvdl  * Per lun target mode state including accept TIO CCB
    312      1.21      fvdl  * and immediate notify CCB pools.
    313      1.21      fvdl  */
    314      1.21      fvdl struct tmode_lstate {
    315      1.21      fvdl #ifdef maybe_later
    316      1.21      fvdl 	struct cam_path *path;
    317      1.21      fvdl 	struct ccb_hdr_slist accept_tios;
    318      1.21      fvdl 	struct ccb_hdr_slist immed_notifies;
    319      1.21      fvdl 	struct ahc_tmode_event event_buffer[AHC_TMODE_EVENT_BUFFER_SIZE];
    320      1.21      fvdl 	u_int8_t event_r_idx;
    321      1.21      fvdl 	u_int8_t event_w_idx;
    322      1.21      fvdl #else
    323      1.21      fvdl 	u_int8_t dummy;
    324      1.21      fvdl #endif
    325      1.21      fvdl };
    326      1.21      fvdl 
    327      1.21      fvdl #define AHC_TRANS_CUR		0x01	/* Modify current neogtiation status */
    328      1.21      fvdl #define AHC_TRANS_ACTIVE	0x03	/* Assume this is the active target */
    329      1.21      fvdl #define AHC_TRANS_GOAL		0x04	/* Modify negotiation goal */
    330      1.21      fvdl #define AHC_TRANS_USER		0x08	/* Modify user negotiation settings */
    331      1.21      fvdl 
    332      1.21      fvdl struct ahc_transinfo {
    333      1.21      fvdl 	u_int8_t width;
    334      1.21      fvdl 	u_int8_t period;
    335      1.21      fvdl 	u_int8_t offset;
    336      1.21      fvdl 	u_int8_t ppr_flags;
    337      1.21      fvdl };
    338      1.21      fvdl 
    339      1.21      fvdl struct ahc_initiator_tinfo {
    340      1.21      fvdl 	u_int8_t scsirate;
    341      1.21      fvdl 	struct ahc_transinfo current;
    342      1.21      fvdl 	struct ahc_transinfo goal;
    343      1.21      fvdl 	struct ahc_transinfo user;
    344      1.21      fvdl };
    345      1.21      fvdl 
    346      1.21      fvdl /*
    347      1.21      fvdl  * Per target mode enabled target state.  Esentially just an array of
    348      1.21      fvdl  * pointers to lun target state as well as sync/wide negotiation information
    349      1.21      fvdl  * for each initiator<->target mapping (including the mapping for when we
    350      1.21      fvdl  * are the initiator).
    351      1.21      fvdl  */
    352      1.21      fvdl struct tmode_tstate {
    353      1.21      fvdl #if 0
    354      1.21      fvdl 	struct tmode_lstate*		enabled_luns[8];
    355      1.21      fvdl #endif
    356      1.21      fvdl 	struct ahc_initiator_tinfo	transinfo[16];
    357      1.15       leo 
    358      1.15       leo 	/*
    359      1.21      fvdl 	 * Per initiator state bitmasks.
    360      1.15       leo 	 */
    361      1.21      fvdl 	u_int16_t		 ultraenb;	/* Using ultra sync rate  */
    362      1.21      fvdl 	u_int16_t	 	 discenable;	/* Disconnection allowed  */
    363      1.21      fvdl 	u_int16_t		 tagenable;	/* Tagged Queuing allowed */
    364      1.23      fvdl 	u_int16_t		 tagdisable;	/* TQ explicity disallowed */
    365      1.21      fvdl };
    366      1.21      fvdl 
    367      1.21      fvdl #define AHC_TARGET_WILDCARD -1
    368      1.21      fvdl #define AHC_LUN_WILDCARD -1
    369      1.15       leo 
    370      1.21      fvdl /*
    371      1.21      fvdl  * XXX translate FreeBSD SCSI status byte values to NetBSD, and define
    372      1.21      fvdl  * a few more.
    373      1.21      fvdl  */
    374      1.21      fvdl #define SCSI_STATUS_OK			SCSI_OK
    375      1.21      fvdl #define SCSI_STATUS_CHECK_COND		SCSI_CHECK
    376      1.21      fvdl #define SCSI_STATUS_COND_MET		0x04
    377      1.21      fvdl #define SCSI_STATUS_BUSY		SCSI_BUSY
    378      1.21      fvdl #define SCSI_STATUS_INTERMED		SCSI_INTERM
    379      1.21      fvdl #define SCSI_STATUS_INTERMED_COND_MET	0x14
    380      1.21      fvdl #define SCSI_STATUS_RESERV_CONFLICT	0x18
    381      1.21      fvdl #define SCSI_STATUS_CMD_TERMINATED	0x22
    382      1.21      fvdl #define SCSI_STATUS_QUEUE_FULL		SCSI_QUEUE_FULL
    383      1.21      fvdl 
    384      1.21      fvdl /*
    385      1.21      fvdl  * Define the format of the aic7XXX SEEPROM registers (16 bits).
    386      1.21      fvdl  */
    387      1.21      fvdl 
    388      1.21      fvdl struct seeprom_config {
    389      1.21      fvdl /*
    390      1.21      fvdl  * SCSI ID Configuration Flags
    391      1.21      fvdl  */
    392      1.21      fvdl 	u_int16_t device_flags[16];	/* words 0-15 */
    393      1.21      fvdl #define		CFXFER		0x0007	/* synchronous transfer rate */
    394      1.21      fvdl #define		CFSYNCH		0x0008	/* enable synchronous transfer */
    395      1.21      fvdl #define		CFDISC		0x0010	/* enable disconnection */
    396      1.21      fvdl #define		CFWIDEB		0x0020	/* wide bus device */
    397      1.21      fvdl #define		CFSYNCHISULTRA	0x0040	/* CFSYNCH is an ultra offset (2940AU)*/
    398      1.21      fvdl #define		CFSYNCSINGLE	0x0080	/* Single-Transition signalling */
    399      1.21      fvdl #define		CFSTART		0x0100	/* send start unit SCSI command */
    400      1.21      fvdl #define		CFINCBIOS	0x0200	/* include in BIOS scan */
    401      1.21      fvdl #define		CFRNFOUND	0x0400	/* report even if not found */
    402      1.21      fvdl #define		CFMULTILUN	0x0800	/* Probe multiple luns in BIOS scan */
    403      1.21      fvdl #define		CFWBCACHEENB	0x4000	/* Enable W-Behind Cache on disks */
    404      1.21      fvdl #define		CFWBCACHENOP	0xc000	/* Don't touch W-Behind Cache */
    405      1.21      fvdl 
    406      1.21      fvdl /*
    407      1.21      fvdl  * BIOS Control Bits
    408      1.21      fvdl  */
    409      1.21      fvdl 	u_int16_t bios_control;		/* word 16 */
    410      1.21      fvdl #define		CFSUPREM	0x0001	/* support all removeable drives */
    411      1.21      fvdl #define		CFSUPREMB	0x0002	/* support removeable boot drives */
    412      1.21      fvdl #define		CFBIOSEN	0x0004	/* BIOS enabled */
    413      1.21      fvdl /*		UNUSED		0x0008	*/
    414      1.21      fvdl #define		CFSM2DRV	0x0010	/* support more than two drives */
    415      1.21      fvdl #define		CF284XEXTEND	0x0020	/* extended translation (284x cards) */
    416      1.21      fvdl /*		UNUSED		0x0040	*/
    417      1.21      fvdl #define		CFEXTEND	0x0080	/* extended translation enabled */
    418      1.21      fvdl /*		UNUSED		0xff00	*/
    419      1.21      fvdl 
    420      1.21      fvdl /*
    421      1.21      fvdl  * Host Adapter Control Bits
    422      1.21      fvdl  */
    423      1.21      fvdl 	u_int16_t adapter_control;	/* word 17 */
    424      1.21      fvdl #define		CFAUTOTERM	0x0001	/* Perform Auto termination */
    425      1.21      fvdl #define		CFULTRAEN	0x0002	/* Ultra SCSI speed enable */
    426      1.21      fvdl #define		CF284XSELTO     0x0003	/* Selection timeout (284x cards) */
    427      1.21      fvdl #define		CF284XFIFO      0x000C	/* FIFO Threshold (284x cards) */
    428      1.21      fvdl #define		CFSTERM		0x0004	/* SCSI low byte termination */
    429      1.21      fvdl #define		CFWSTERM	0x0008	/* SCSI high byte termination */
    430      1.21      fvdl #define		CFSPARITY	0x0010	/* SCSI parity */
    431      1.21      fvdl #define		CF284XSTERM     0x0020	/* SCSI low byte term (284x cards) */
    432      1.21      fvdl #define		CFRESETB	0x0040	/* reset SCSI bus at boot */
    433      1.21      fvdl #define		CFCHNLBPRIMARY	0x0100	/* aic7895 probe B channel first */
    434      1.21      fvdl #define		CFSEAUTOTERM	0x0400	/* aic7890 Perform SE Auto Termination*/
    435      1.21      fvdl #define		CFLVDSTERM	0x0800	/* aic7890 LVD Termination */
    436      1.21      fvdl /*		UNUSED		0xf280	*/
    437      1.21      fvdl 
    438      1.21      fvdl /*
    439      1.21      fvdl  * Bus Release, Host Adapter ID
    440      1.21      fvdl  */
    441      1.21      fvdl 	u_int16_t brtime_id;		/* word 18 */
    442      1.21      fvdl #define		CFSCSIID	0x000f	/* host adapter SCSI ID */
    443      1.21      fvdl /*		UNUSED		0x00f0	*/
    444      1.21      fvdl #define		CFBRTIME	0xff00	/* bus release time */
    445      1.21      fvdl 
    446      1.21      fvdl /*
    447      1.21      fvdl  * Maximum targets
    448      1.21      fvdl  */
    449      1.21      fvdl 	u_int16_t max_targets;		/* word 19 */
    450      1.21      fvdl #define		CFMAXTARG	0x00ff	/* maximum targets */
    451      1.21      fvdl /*		UNUSED		0xff00	*/
    452      1.21      fvdl 	u_int16_t res_1[11];		/* words 20-30 */
    453      1.21      fvdl 	u_int16_t checksum;		/* word 31 */
    454      1.21      fvdl };
    455      1.21      fvdl 
    456      1.21      fvdl struct ahc_syncrate {
    457      1.21      fvdl 	int sxfr_u2;
    458      1.21      fvdl 	int sxfr;
    459      1.21      fvdl 	/* Rates in Ultra mode have bit 8 of sxfr set */
    460      1.21      fvdl #define		ULTRA_SXFR 0x100
    461      1.21      fvdl #define		ST_SXFR	   0x010
    462      1.21      fvdl 	u_int8_t period; /* Period to send to SCSI target */
    463      1.21      fvdl 	char *rate;
    464      1.21      fvdl };
    465      1.21      fvdl 
    466      1.21      fvdl typedef enum {
    467      1.21      fvdl 	MSG_TYPE_NONE			= 0x00,
    468      1.21      fvdl 	MSG_TYPE_INITIATOR_MSGOUT	= 0x01,
    469      1.21      fvdl 	MSG_TYPE_INITIATOR_MSGIN	= 0x02,
    470      1.21      fvdl 	MSG_TYPE_TARGET_MSGOUT		= 0x03,
    471      1.21      fvdl 	MSG_TYPE_TARGET_MSGIN		= 0x04
    472      1.21      fvdl } ahc_msg_type;
    473      1.21      fvdl 
    474      1.21      fvdl struct sg_map_node {
    475      1.21      fvdl 	bus_dmamap_t		 sg_dmamap;
    476      1.21      fvdl 	bus_addr_t		 sg_physaddr;
    477      1.21      fvdl 	bus_dma_segment_t	 sg_dmasegs;
    478      1.21      fvdl 	int			 sg_nseg;
    479      1.21      fvdl 	struct ahc_dma_seg*	 sg_vaddr;
    480      1.21      fvdl 	SLIST_ENTRY(sg_map_node) links;
    481      1.21      fvdl };
    482      1.21      fvdl 
    483      1.21      fvdl struct scb_data {
    484      1.21      fvdl 	struct	hardware_scb	*hscbs;	    /* Array of hardware SCBs */
    485      1.21      fvdl 	struct	scb *scbarray;		    /* Array of kernel SCBs */
    486      1.21      fvdl 	SLIST_HEAD(, scb) free_scbs;	/*
    487      1.21      fvdl 					 * Pool of SCBs ready to be assigned
    488      1.21      fvdl 					 * commands to execute.
    489      1.21      fvdl 					 */
    490      1.21      fvdl 	struct	scsipi_sense_data *sense; /* Per SCB sense data */
    491      1.21      fvdl 
    492      1.21      fvdl 	/*
    493      1.21      fvdl 	 * "Bus" addresses of our data structures.
    494      1.21      fvdl 	 */
    495      1.21      fvdl 	bus_dmamap_t	  hscb_dmamap;
    496      1.21      fvdl 	bus_addr_t	  hscb_busaddr;
    497      1.21      fvdl 	bus_dma_segment_t hscb_seg;
    498      1.21      fvdl 	int		  hscb_nseg;
    499      1.21      fvdl 	int		  hscb_size;
    500      1.21      fvdl 
    501      1.21      fvdl 	bus_dmamap_t	  sense_dmamap;
    502      1.21      fvdl 	bus_addr_t	  sense_busaddr;
    503      1.21      fvdl 	bus_dma_segment_t sense_seg;
    504      1.21      fvdl 	int		  sense_nseg;
    505      1.21      fvdl 	int		  sense_size;
    506      1.21      fvdl 
    507      1.21      fvdl 	SLIST_HEAD(, sg_map_node) sg_maps;
    508      1.21      fvdl 	u_int8_t	  numscbs;
    509      1.21      fvdl 	u_int8_t	  maxhscbs;	/* Number of SCBs on the card */
    510      1.21      fvdl 	u_int8_t	  init_level;	/*
    511      1.21      fvdl 					 * How far we've initialized
    512      1.21      fvdl 					 * this structure.
    513      1.21      fvdl 					 */
    514       1.1   mycroft };
    515       1.1   mycroft 
    516      1.21      fvdl typedef TAILQ_HEAD(, scsipi_xfer) xs_list_t;
    517      1.15       leo 
    518      1.21      fvdl struct ahc_softc {
    519      1.21      fvdl 	struct device		sc_dev;
    520      1.21      fvdl 
    521      1.21      fvdl 	struct  scsipi_link sc_link;
    522      1.21      fvdl 	struct  scsipi_link sc_link_b;
    523      1.21      fvdl 	struct  scsipi_adapter sc_adapter;
    524      1.21      fvdl 
    525      1.21      fvdl 	bus_space_tag_t		 tag;
    526      1.21      fvdl 	bus_space_handle_t	 bsh;
    527      1.21      fvdl 	struct scb_data		*scb_data;
    528      1.21      fvdl 
    529      1.21      fvdl 	xs_list_t		sc_q;
    530      1.21      fvdl 	int			queue_blocked;
    531      1.21      fvdl 	u_int16_t		devqueue_blocked[16];
    532      1.21      fvdl #define AHC_NEG_PENDING		0x01
    533      1.21      fvdl #define AHC_NEG_SDTRDONE	0x02
    534      1.21      fvdl #define AHC_NEG_WDTRDONE	0x04
    535      1.21      fvdl 	u_int8_t		inited_targets[16];
    536  1.23.2.1   minoura 	u_int8_t		inited_channels[2];
    537      1.21      fvdl 
    538      1.21      fvdl 	/*
    539      1.21      fvdl 	 * SCBs that have been send to the controller
    540      1.21      fvdl 	 */
    541      1.21      fvdl 	LIST_HEAD(, scb) pending_ccbs;
    542      1.21      fvdl 
    543      1.21      fvdl 	/*
    544      1.21      fvdl 	 * Target mode related state kept on a per enabled lun basis.
    545      1.21      fvdl 	 * Targets that are not enabled will have null entries.
    546      1.21      fvdl 	 * As an initiator, we keep one target entry for our initiator
    547      1.21      fvdl 	 * ID to store our sync/wide transfer settings.
    548      1.21      fvdl 	 */
    549      1.21      fvdl 	struct tmode_tstate*	 enabled_targets[16];
    550      1.21      fvdl 
    551      1.21      fvdl 	/*
    552      1.21      fvdl 	 * The black hole device responsible for handling requests for
    553      1.21      fvdl 	 * disabled luns on enabled targets.
    554      1.21      fvdl 	 */
    555      1.21      fvdl 	struct tmode_lstate*	 black_hole;
    556      1.21      fvdl 
    557      1.21      fvdl 	/*
    558      1.21      fvdl 	 * Device instance currently on the bus awaiting a continue TIO
    559      1.21      fvdl 	 * for a command that was not given the disconnect priveledge.
    560      1.21      fvdl 	 */
    561      1.21      fvdl 	struct tmode_lstate*	 pending_device;
    562      1.21      fvdl 
    563      1.21      fvdl 	/*
    564      1.21      fvdl 	 * Card characteristics
    565      1.21      fvdl 	 */
    566      1.21      fvdl 	ahc_chip		 chip;
    567      1.21      fvdl 	ahc_feature		 features;
    568      1.21      fvdl 	ahc_flag		 flags;
    569      1.21      fvdl 
    570      1.21      fvdl 	/* Values to store in the SEQCTL register for pause and unpause */
    571      1.21      fvdl 	u_int8_t		 unpause;
    572      1.21      fvdl 	u_int8_t		 pause;
    573      1.21      fvdl 
    574      1.21      fvdl 	/* Command Queues */
    575      1.21      fvdl 	u_int8_t		 qoutfifonext;
    576      1.21      fvdl 	u_int8_t		 qinfifonext;
    577      1.21      fvdl 	u_int8_t		*qoutfifo;
    578      1.21      fvdl 	u_int8_t		*qinfifo;
    579      1.21      fvdl 
    580      1.21      fvdl 	/*
    581      1.21      fvdl 	 * 256 byte array storing the SCBID of outstanding
    582      1.21      fvdl 	 * untagged SCBs indexed by TCL.
    583      1.21      fvdl 	 */
    584      1.21      fvdl 	u_int8_t		 *untagged_scbs;
    585      1.21      fvdl 
    586      1.21      fvdl 	/* Channel Names ('A', 'B', etc.) */
    587      1.21      fvdl 	char			 channel;
    588      1.21      fvdl 	char			 channel_b;
    589      1.21      fvdl 
    590      1.21      fvdl 	/* Initiator Bus ID */
    591      1.21      fvdl 	u_int8_t		 our_id;
    592      1.21      fvdl 	u_int8_t		 our_id_b;
    593      1.21      fvdl 
    594      1.21      fvdl 	/* Targets that need negotiation messages */
    595      1.21      fvdl 	u_int16_t		 targ_msg_req;
    596      1.21      fvdl 
    597      1.21      fvdl 	/*
    598      1.21      fvdl 	 * PCI error detection and data for running the
    599      1.21      fvdl 	 * PCI error interrupt handler.
    600      1.21      fvdl 	 */
    601      1.21      fvdl 	int			 unsolicited_ints;
    602      1.21      fvdl 
    603      1.21      fvdl 	/*
    604      1.21      fvdl 	 * Target incoming command FIFO.
    605      1.21      fvdl 	 */
    606      1.21      fvdl 	struct target_cmd	*targetcmds;
    607      1.21      fvdl 	u_int8_t		 tqinfifonext;
    608      1.21      fvdl 
    609      1.21      fvdl 	/*
    610      1.21      fvdl 	 * Incoming and outgoing message handling.
    611      1.21      fvdl 	 */
    612      1.21      fvdl 	u_int8_t		 send_msg_perror;
    613      1.21      fvdl 	ahc_msg_type		 msg_type;
    614      1.21      fvdl 	u_int8_t		 msgout_buf[8];	/* Message we are sending */
    615      1.21      fvdl 	u_int8_t		 msgin_buf[8];	/* Message we are receiving */
    616      1.21      fvdl 	u_int			 msgout_len;	/* Length of message to send */
    617      1.21      fvdl 	u_int			 msgout_index;	/* Current index in msgout */
    618      1.21      fvdl 	u_int			 msgin_index;	/* Current index in msgin */
    619      1.21      fvdl 
    620      1.21      fvdl 	void			*ih;
    621      1.21      fvdl 	bus_dma_tag_t		 parent_dmat;
    622      1.21      fvdl 	int			 sc_dmaflags;
    623      1.21      fvdl 	bus_dmamap_t		 shared_data_dmamap;
    624      1.21      fvdl 	bus_addr_t		 shared_data_busaddr;
    625      1.21      fvdl 	bus_dma_segment_t	 shared_data_seg;
    626      1.21      fvdl 	int			 shared_data_nseg;
    627      1.21      fvdl 	int			 shared_data_size;
    628      1.21      fvdl 	bus_addr_t		 dma_bug_buf;
    629      1.21      fvdl 
    630      1.21      fvdl 	/* Number of enabled target mode device on this card */
    631      1.21      fvdl 	u_int			 enabled_luns;
    632      1.21      fvdl 
    633      1.21      fvdl 	/* Initialization level of this data structure */
    634      1.21      fvdl 	u_int			 init_level;
    635      1.21      fvdl 
    636      1.21      fvdl 	u_int16_t	 	 user_discenable;/* Disconnection allowed  */
    637      1.21      fvdl 	u_int16_t		 user_tagenable;/* Tagged Queuing allowed */
    638      1.21      fvdl 
    639      1.21      fvdl 	void			*bus_data;
    640      1.22      fvdl 	int			(*bus_intr)(struct ahc_softc *);
    641      1.21      fvdl };
    642      1.21      fvdl 
    643      1.21      fvdl struct full_ahc_softc {
    644      1.21      fvdl 	struct ahc_softc softc;
    645      1.21      fvdl 	struct scb_data  scb_data_storage;
    646       1.1   mycroft };
    647       1.4   mycroft 
    648      1.21      fvdl /* #define AHC_DEBUG 0x019f */
    649      1.21      fvdl 
    650       1.4   mycroft #ifdef AHC_DEBUG
    651       1.4   mycroft /* Different debugging levels used when AHC_DEBUG is defined */
    652      1.21      fvdl #define AHC_SHOWMISC		0x0001
    653      1.21      fvdl #define AHC_SHOWCMDS		0x0002
    654      1.21      fvdl #define AHC_SHOWSCBS		0x0004
    655      1.21      fvdl #define AHC_SHOWABORTS		0x0008
    656      1.21      fvdl #define AHC_SHOWSENSE		0x0010
    657      1.21      fvdl #define AHC_SHOWSCBCNT		0x0020
    658      1.21      fvdl #define AHC_SHOWSCBALLOC	0x0040
    659      1.21      fvdl #define AHC_SHOWINTR		0x0080
    660      1.21      fvdl #define AHC_SHOWMSG		0x0100
    661       1.4   mycroft 
    662       1.4   mycroft extern int ahc_debug; /* Initialized in i386/scsi/aic7xxx.c */
    663       1.4   mycroft #endif
    664       1.4   mycroft 
    665      1.21      fvdl char *ahc_name(struct ahc_softc *ahc);
    666      1.21      fvdl 
    667      1.21      fvdl int	ahc_alloc(struct ahc_softc *ahc, bus_space_handle_t sh,
    668      1.21      fvdl 		  bus_space_tag_t st, bus_dma_tag_t parent_dmat,
    669      1.21      fvdl 		  ahc_chip chip, ahc_feature features, ahc_flag flags);
    670      1.21      fvdl int	ahc_reset(struct ahc_softc *ahc);
    671      1.21      fvdl void	ahc_free(struct ahc_softc *);
    672      1.21      fvdl int	ahc_probe_scbs(struct ahc_softc *);
    673      1.21      fvdl int	ahc_init(struct ahc_softc *);
    674      1.21      fvdl int	ahc_attach(struct ahc_softc *);
    675      1.21      fvdl int	ahc_intr(void *arg);
    676      1.21      fvdl 
    677      1.21      fvdl /*
    678      1.21      fvdl  * SEEPROM related functions.
    679      1.21      fvdl  */
    680      1.21      fvdl void	check_extport(struct ahc_softc *ahc, u_int *sxfrctl1);
    681       1.4   mycroft 
    682       1.4   mycroft 
    683      1.21      fvdl #define ahc_inb(ahc, port)				\
    684      1.21      fvdl 	bus_space_read_1((ahc)->tag, (ahc)->bsh, port)
    685       1.4   mycroft 
    686      1.21      fvdl #define ahc_outb(ahc, port, value)			\
    687      1.21      fvdl 	bus_space_write_1((ahc)->tag, (ahc)->bsh, port, value)
    688       1.4   mycroft 
    689      1.21      fvdl #define ahc_outsb(ahc, port, valp, count)		\
    690      1.21      fvdl 	bus_space_write_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
    691      1.20   thorpej 
    692      1.21      fvdl #define ahc_insb(ahc, port, valp, count)		\
    693      1.21      fvdl 	bus_space_read_multi_1((ahc)->tag, (ahc)->bsh, port, valp, count)
    694       1.1   mycroft 
    695       1.1   mycroft #endif  /* _AIC7XXX_H_ */
    696