Home | History | Annotate | Line # | Download | only in ic
aic7xxxvar.h revision 1.3
      1  1.3  mycroft /*	$NetBSD: aic7xxxvar.h,v 1.3 1996/03/29 00:25:02 mycroft Exp $	*/
      2  1.2      cgd 
      3  1.1  mycroft /*
      4  1.1  mycroft  * Interface to the generic driver for the aic7xxx based adaptec
      5  1.1  mycroft  * SCSI controllers.  This is used to implement product specific
      6  1.1  mycroft  * probe and attach routines.
      7  1.1  mycroft  *
      8  1.1  mycroft  * Copyright (c) 1994, 1995 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.1  mycroft  * 3. Absolutely no warranty of function or purpose is made by the author
     21  1.1  mycroft  *    Justin T. Gibbs.
     22  1.1  mycroft  * 4. Modifications may be freely made to this file if the above conditions
     23  1.1  mycroft  *    are met.
     24  1.1  mycroft  */
     25  1.1  mycroft 
     26  1.1  mycroft #ifndef _AIC7XXX_H_
     27  1.1  mycroft #define _AIC7XXX_H_
     28  1.1  mycroft 
     29  1.1  mycroft #define	AHC_NSEG	256	/* number of dma segments supported */
     30  1.1  mycroft 
     31  1.1  mycroft #define AHC_SCB_MAX	16	/*
     32  1.1  mycroft 				 * Up to 16 SCBs on some types of aic7xxx based
     33  1.1  mycroft 				 * boards.  The aic7770 family only have 4
     34  1.1  mycroft 				 */
     35  1.1  mycroft 
     36  1.1  mycroft /* #define AHCDEBUG */
     37  1.1  mycroft 
     38  1.1  mycroft typedef u_long physaddr;
     39  1.1  mycroft typedef u_long physlen;
     40  1.1  mycroft 
     41  1.1  mycroft struct ahc_dma_seg {
     42  1.1  mycroft         physaddr seg_addr;
     43  1.1  mycroft 	physlen seg_len;
     44  1.1  mycroft };
     45  1.1  mycroft 
     46  1.1  mycroft typedef u_char ahc_type;
     47  1.1  mycroft #define	AHC_NONE	0x00
     48  1.1  mycroft #define	AHC_WIDE	0x02	/* Wide Channel */
     49  1.1  mycroft #define AHC_TWIN	0x08	/* Twin Channel */
     50  1.1  mycroft #define	AHC_274		0x10	/* EISA Based Controller */
     51  1.1  mycroft #define	AHC_284		0x20	/* VL/ISA Based Controller */
     52  1.1  mycroft #define	AHC_AIC7870	0x40	/* PCI Based Controller */
     53  1.1  mycroft #define	AHC_294		0xc0	/* PCI Based Controller */
     54  1.1  mycroft 
     55  1.1  mycroft /*
     56  1.1  mycroft  * The driver keeps up to MAX_SCB scb structures per card in memory.  Only the
     57  1.1  mycroft  * first 26 bytes of the structure are valid for the hardware, the rest used
     58  1.1  mycroft  * for driver level bookeeping.  The "__attribute ((packed))" tags ensure that
     59  1.1  mycroft  * gcc does not attempt to pad the long ints in the structure to word
     60  1.1  mycroft  * boundaries since the first 26 bytes of this structure must have the correct
     61  1.1  mycroft  * offsets for the hardware to find them.  The driver is further optimized
     62  1.1  mycroft  * so that we only have to download the first 19 bytes since as long
     63  1.1  mycroft  * as we always use S/G, the last fields should be zero anyway.
     64  1.1  mycroft  */
     65  1.1  mycroft #if __GNUC__ >= 2
     66  1.1  mycroft #if  __GNUC_MINOR__ <5
     67  1.1  mycroft #pragma pack(1)
     68  1.1  mycroft #endif
     69  1.1  mycroft #endif
     70  1.1  mycroft 
     71  1.1  mycroft struct ahc_scb {
     72  1.1  mycroft /* ------------    Begin hardware supported fields    ---------------- */
     73  1.1  mycroft /*1*/   u_char control;
     74  1.1  mycroft #define	SCB_NEEDWDTR 0x80			/* Initiate Wide Negotiation */
     75  1.1  mycroft #define SCB_NEEDSDTR 0x40			/* Initiate Sync Negotiation */
     76  1.1  mycroft #define	SCB_TE	     0x20			/* Tag enable */
     77  1.1  mycroft #define	SCB_NEEDDMA  0x08			/* Refresh SCB from host ram */
     78  1.1  mycroft #define	SCB_DIS 0x04
     79  1.1  mycroft #define	SCB_TAG_TYPE 0x3
     80  1.1  mycroft #define		SIMPLE_QUEUE 0x0
     81  1.1  mycroft #define		HEAD_QUEUE 0x1
     82  1.1  mycroft #define		OR_QUEUE 0x2
     83  1.1  mycroft /*2*/	u_char target_channel_lun;		/* 4/1/3 bits */
     84  1.1  mycroft /*3*/	u_char SG_segment_count;
     85  1.1  mycroft /*7*/	physaddr SG_list_pointer	__attribute__ ((packed));
     86  1.1  mycroft /*11*/	physaddr cmdpointer		__attribute__ ((packed));
     87  1.1  mycroft /*12*/	u_char cmdlen;
     88  1.1  mycroft /*14*/	u_char RESERVED[2];			/* must be zero */
     89  1.1  mycroft /*15*/	u_char target_status;
     90  1.1  mycroft /*18*/	u_char residual_data_count[3];
     91  1.1  mycroft /*19*/	u_char residual_SG_segment_count;
     92  1.1  mycroft #define	SCB_DOWN_SIZE 19		/* amount to actually download */
     93  1.1  mycroft #define SCB_BZERO_SIZE 19		/*
     94  1.1  mycroft 					 * amount we need to clear between
     95  1.1  mycroft 					 * commands
     96  1.1  mycroft 					 */
     97  1.1  mycroft /*23*/	physaddr data			 __attribute__ ((packed));
     98  1.1  mycroft /*26*/  u_char datalen[3];
     99  1.1  mycroft #define SCB_UP_SIZE 26			/*
    100  1.1  mycroft 					 * amount we need to upload to perform
    101  1.1  mycroft 					 * a request sense.
    102  1.1  mycroft 					 */
    103  1.1  mycroft /*30*/	physaddr host_scb			 __attribute__ ((packed));
    104  1.1  mycroft /*31*/	u_char next_waiting;		/* Used to thread SCBs awaiting
    105  1.1  mycroft 					 * selection
    106  1.1  mycroft 					 */
    107  1.1  mycroft #define SCB_LIST_NULL 0x10		/* SCB list equivelent to NULL */
    108  1.1  mycroft #if 0
    109  1.1  mycroft 	/*
    110  1.1  mycroft 	 *  No real point in transferring this to the
    111  1.1  mycroft 	 *  SCB registers.
    112  1.1  mycroft 	*/
    113  1.1  mycroft 	unsigned char RESERVED[1];
    114  1.1  mycroft #endif
    115  1.1  mycroft 	/*-----------------end of hardware supported fields----------------*/
    116  1.1  mycroft 	TAILQ_ENTRY(ahc_scb) chain;
    117  1.1  mycroft 	struct scsi_xfer *xs;	/* the scsi_xfer for this cmd */
    118  1.1  mycroft 	int flags;
    119  1.1  mycroft #define	SCB_FREE	0
    120  1.1  mycroft #define	SCB_ACTIVE	1
    121  1.1  mycroft #define	SCB_ABORTED	2
    122  1.1  mycroft #define	SCB_CHKSENSE	3
    123  1.1  mycroft #define	SCB_IMMED	4
    124  1.1  mycroft #define	SCB_IMMED_FAIL	8
    125  1.1  mycroft 	int	position;	/* Position in scbarray */
    126  1.1  mycroft 	struct ahc_dma_seg ahc_dma[AHC_NSEG] __attribute__ ((packed));
    127  1.1  mycroft 	struct scsi_sense sense_cmd;	/* SCSI command block */
    128  1.1  mycroft };
    129  1.1  mycroft 
    130  1.1  mycroft #if __GNUC__ >= 2
    131  1.1  mycroft #if  __GNUC_MINOR__ <5
    132  1.1  mycroft #pragma pack(4)
    133  1.1  mycroft #endif
    134  1.1  mycroft #endif
    135  1.1  mycroft 
    136  1.1  mycroft struct ahc_softc {
    137  1.1  mycroft         struct device sc_dev;
    138  1.1  mycroft         void *sc_ih;
    139  1.1  mycroft 
    140  1.1  mycroft 	int sc_iobase;
    141  1.1  mycroft 	int sc_irq;
    142  1.1  mycroft 
    143  1.1  mycroft 	ahc_type type;
    144  1.1  mycroft 
    145  1.1  mycroft 	struct	ahc_scb *scbarray[AHC_SCB_MAX]; /* Mirror boards scbarray */
    146  1.1  mycroft 	TAILQ_HEAD(, ahc_scb) free_scb;
    147  1.1  mycroft 	int	ahc_scsi_dev;		/* our scsi id */
    148  1.1  mycroft 	int	ahc_scsi_dev_b;		/* B channel scsi id */
    149  1.1  mycroft 	struct	ahc_scb *immed_ecb;	/* an outstanding immediete command */
    150  1.1  mycroft 	struct	scsi_link sc_link;
    151  1.1  mycroft 	struct	scsi_link sc_link_b;	/* Second bus for Twin channel cards */
    152  1.1  mycroft 	u_short	needsdtr_orig;		/* Targets we initiate sync neg with */
    153  1.1  mycroft 	u_short	needwdtr_orig;		/* Targets we initiate wide neg with */
    154  1.1  mycroft 	u_short	needsdtr;		/* Current list of negotiated targets */
    155  1.1  mycroft 	u_short needwdtr;		/* Current list of negotiated targets */
    156  1.1  mycroft 	u_short sdtrpending;		/* Pending SDTR to these targets */
    157  1.1  mycroft 	u_short wdtrpending;		/* Pending WDTR to these targets */
    158  1.1  mycroft 	u_short	tagenable;		/* Targets that can handle tagqueing */
    159  1.1  mycroft 	int	numscbs;
    160  1.1  mycroft 	int	activescbs;
    161  1.1  mycroft 	u_char	maxscbs;
    162  1.1  mycroft 	u_char	unpause;
    163  1.1  mycroft 	u_char	pause;
    164  1.1  mycroft };
    165  1.1  mycroft 
    166  1.1  mycroft #endif  /* _AIC7XXX_H_ */
    167