Home | History | Annotate | Line # | Download | only in ic
isp_netbsd.h revision 1.6
      1  1.6  mjacob /* $NetBSD: isp_netbsd.h,v 1.6 1998/12/05 19:48:23 mjacob Exp $	*/
      2  1.6  mjacob /* isp_netbsd.h 1.16 */
      3  1.1  mjacob /*
      4  1.1  mjacob  * NetBSD Specific definitions for the Qlogic ISP Host Adapter
      5  1.1  mjacob  *
      6  1.1  mjacob  *---------------------------------------
      7  1.1  mjacob  * Copyright (c) 1997, 1998 by Matthew Jacob
      8  1.1  mjacob  * NASA/Ames Research Center
      9  1.1  mjacob  * All rights reserved.
     10  1.1  mjacob  *---------------------------------------
     11  1.1  mjacob  *
     12  1.1  mjacob  * Redistribution and use in source and binary forms, with or without
     13  1.1  mjacob  * modification, are permitted provided that the following conditions
     14  1.1  mjacob  * are met:
     15  1.1  mjacob  * 1. Redistributions of source code must retain the above copyright
     16  1.1  mjacob  *    notice immediately at the beginning of the file, without modification,
     17  1.1  mjacob  *    this list of conditions, and the following disclaimer.
     18  1.1  mjacob  * 2. Redistributions in binary form must reproduce the above copyright
     19  1.1  mjacob  *    notice, this list of conditions and the following disclaimer in the
     20  1.1  mjacob  *    documentation and/or other materials provided with the distribution.
     21  1.1  mjacob  * 3. The name of the author may not be used to endorse or promote products
     22  1.1  mjacob  *    derived from this software without specific prior written permission.
     23  1.1  mjacob  *
     24  1.1  mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     25  1.1  mjacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     26  1.1  mjacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     27  1.1  mjacob  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     28  1.1  mjacob  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     29  1.1  mjacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     30  1.1  mjacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     31  1.1  mjacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     32  1.1  mjacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     33  1.1  mjacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     34  1.1  mjacob  * SUCH DAMAGE.
     35  1.1  mjacob  *
     36  1.1  mjacob  */
     37  1.1  mjacob 
     38  1.1  mjacob #ifndef	_ISP_NETBSD_H
     39  1.1  mjacob #define	_ISP_NETBSD_H
     40  1.1  mjacob 
     41  1.1  mjacob #include <sys/types.h>
     42  1.1  mjacob #include <sys/param.h>
     43  1.1  mjacob #include <sys/systm.h>
     44  1.1  mjacob #include <sys/kernel.h>
     45  1.1  mjacob #include <sys/errno.h>
     46  1.1  mjacob #include <sys/ioctl.h>
     47  1.1  mjacob #include <sys/device.h>
     48  1.1  mjacob #include <sys/malloc.h>
     49  1.1  mjacob #include <sys/buf.h>
     50  1.1  mjacob #include <sys/proc.h>
     51  1.1  mjacob #include <sys/user.h>
     52  1.1  mjacob 
     53  1.1  mjacob 
     54  1.1  mjacob #include <dev/scsipi/scsi_all.h>
     55  1.1  mjacob #include <dev/scsipi/scsipi_all.h>
     56  1.1  mjacob #include <dev/scsipi/scsiconf.h>
     57  1.1  mjacob 
     58  1.1  mjacob #include <dev/scsipi/scsi_message.h>
     59  1.1  mjacob #include <dev/scsipi/scsipi_debug.h>
     60  1.1  mjacob 
     61  1.1  mjacob #include <vm/vm.h>
     62  1.1  mjacob #include <vm/vm_param.h>
     63  1.1  mjacob #include <vm/pmap.h>
     64  1.1  mjacob 
     65  1.2  mjacob #define	ISP_PLATFORM_VERSION_MAJOR	0
     66  1.6  mjacob #define	ISP_PLATFORM_VERSION_MINOR	99
     67  1.1  mjacob 
     68  1.1  mjacob #define	ISP_SCSI_XFER_T		struct scsipi_xfer
     69  1.1  mjacob struct isposinfo {
     70  1.1  mjacob 	struct device		_dev;
     71  1.1  mjacob 	struct scsipi_link	_link;
     72  1.6  mjacob 	struct scsipi_adapter   _adapter;
     73  1.1  mjacob };
     74  1.1  mjacob #define	MAXISPREQUEST	256
     75  1.1  mjacob 
     76  1.1  mjacob #include <dev/ic/ispreg.h>
     77  1.1  mjacob #include <dev/ic/ispvar.h>
     78  1.1  mjacob #include <dev/ic/ispmbox.h>
     79  1.1  mjacob 
     80  1.1  mjacob #define	PRINTF			printf
     81  1.1  mjacob #define	IDPRINTF(lev, x)	if (isp->isp_dblev >= lev) printf x
     82  1.3  mjacob 
     83  1.3  mjacob #if	defined(SCSIDEBUG)
     84  1.3  mjacob #define	DFLT_DBLEVEL		3
     85  1.3  mjacob #else
     86  1.3  mjacob #if	defined(DEBUG)
     87  1.1  mjacob #define	DFLT_DBLEVEL		2
     88  1.1  mjacob #else
     89  1.1  mjacob #define	DFLT_DBLEVEL		1
     90  1.1  mjacob #endif
     91  1.3  mjacob #endif
     92  1.1  mjacob 
     93  1.1  mjacob #define	ISP_LOCKVAL_DECL	int isp_spl_save
     94  1.1  mjacob #define	ISP_LOCK(x)		isp_spl_save = splbio()
     95  1.1  mjacob #define	ISP_UNLOCK(x)		(void) splx(isp_spl_save)
     96  1.1  mjacob #define	ISP_ILOCK		ISP_LOCK
     97  1.1  mjacob #define	ISP_IUNLOCK		ISP_UNLOCK
     98  1.1  mjacob 
     99  1.1  mjacob 
    100  1.1  mjacob #define	XS_NULL(xs)		xs == NULL || xs->sc_link == NULL
    101  1.1  mjacob #define	XS_ISP(xs)		(xs)->sc_link->adapter_softc
    102  1.1  mjacob #define	XS_LUN(xs)		(xs)->sc_link->scsipi_scsi.lun
    103  1.1  mjacob #define	XS_TGT(xs)		(xs)->sc_link->scsipi_scsi.target
    104  1.1  mjacob #define	XS_RESID(xs)		(xs)->resid
    105  1.1  mjacob #define	XS_XFRLEN(xs)		(xs)->datalen
    106  1.1  mjacob #define	XS_CDBLEN(xs)		(xs)->cmdlen
    107  1.1  mjacob #define	XS_CDBP(xs)		(xs)->cmd
    108  1.1  mjacob #define	XS_STS(xs)		(xs)->status
    109  1.1  mjacob #define	XS_TIME(xs)		(xs)->timeout
    110  1.1  mjacob #define	XS_SNSP(xs)		(&(xs)->sense.scsi_sense)
    111  1.1  mjacob #define	XS_SNSLEN(xs)		(sizeof (xs)->sense.scsi_sense)
    112  1.1  mjacob #define	XS_SNSKEY(xs)		((xs)->sense.scsi_sense.flags)
    113  1.1  mjacob 
    114  1.1  mjacob #define	HBA_NOERROR		XS_NOERROR
    115  1.1  mjacob #define	HBA_BOTCH		XS_DRIVER_STUFFUP
    116  1.1  mjacob #define	HBA_CMDTIMEOUT		XS_TIMEOUT
    117  1.1  mjacob #define	HBA_SELTIMEOUT		XS_SELTIMEOUT
    118  1.1  mjacob #define	HBA_TGTBSY		XS_BUSY
    119  1.3  mjacob #ifdef	XS_RESET
    120  1.3  mjacob #define	HBA_BUSRESET		XS_RESET
    121  1.3  mjacob #else
    122  1.1  mjacob #define	HBA_BUSRESET		XS_DRIVER_STUFFUP
    123  1.3  mjacob #endif
    124  1.1  mjacob #define	HBA_ABORTED		XS_DRIVER_STUFFUP
    125  1.1  mjacob #define	HBA_DATAOVR		XS_DRIVER_STUFFUP
    126  1.1  mjacob #define	HBA_ARQFAIL		XS_DRIVER_STUFFUP
    127  1.1  mjacob 
    128  1.1  mjacob #define	XS_SNS_IS_VALID(xs)	(xs)->error = XS_SENSE
    129  1.1  mjacob #define	XS_IS_SNS_VALID(xs)	((xs)->error == XS_SENSE)
    130  1.1  mjacob 
    131  1.1  mjacob #define	XS_INITERR(xs)		(xs)->error = 0
    132  1.1  mjacob #define	XS_SETERR(xs, v)	(xs)->error = v
    133  1.1  mjacob #define	XS_ERR(xs)		(xs)->error
    134  1.1  mjacob #define	XS_NOERR(xs)		(xs)->error == XS_NOERROR
    135  1.1  mjacob 
    136  1.1  mjacob #define	XS_CMD_DONE(xs)		(xs)->flags |= ITSDONE, scsipi_done(xs)
    137  1.1  mjacob #define	XS_IS_CMD_DONE(xs)	(((xs)->flags & ITSDONE) != 0)
    138  1.1  mjacob 
    139  1.1  mjacob /*
    140  1.1  mjacob  * We use whether or not we're a polled command to decide about tagging.
    141  1.1  mjacob  */
    142  1.1  mjacob #define	XS_CANTAG(xs)		(((xs)->flags & SCSI_POLL) != 0)
    143  1.1  mjacob 
    144  1.1  mjacob /*
    145  1.1  mjacob  * This is our default tag (ordered).
    146  1.1  mjacob  */
    147  1.1  mjacob #define	XS_KINDOF_TAG(xs)	\
    148  1.3  mjacob 	(((xs)->flags & SCSI_URGENT)? REQFLAG_HTAG : REQFLAG_STAG)
    149  1.1  mjacob 
    150  1.1  mjacob #define	CMD_COMPLETE		COMPLETE
    151  1.1  mjacob #define	CMD_EAGAIN		TRY_AGAIN_LATER
    152  1.1  mjacob #define	CMD_QUEUED		SUCCESSFULLY_QUEUED
    153  1.1  mjacob 
    154  1.1  mjacob 
    155  1.1  mjacob 
    156  1.1  mjacob #define	isp_name	isp_osinfo._dev.dv_xname
    157  1.1  mjacob 
    158  1.1  mjacob 
    159  1.1  mjacob #define	SYS_DELAY(x)	delay(x)
    160  1.1  mjacob 
    161  1.1  mjacob #define	WATCH_INTERVAL		30
    162  1.1  mjacob #define	START_WATCHDOG(f, s)	\
    163  1.1  mjacob 	timeout(f, s, WATCH_INTERVAL * hz), s->isp_dogactive = 1
    164  1.1  mjacob 
    165  1.1  mjacob #define	RESTART_WATCHDOG(f, s)		START_WATCHDOG(f, s)
    166  1.1  mjacob #define	STOP_WATCHDOG(f, s)		untimeout(f, s), s->isp_dogactive = 0
    167  1.1  mjacob 
    168  1.1  mjacob 
    169  1.1  mjacob extern void isp_attach __P((struct ispsoftc *));
    170  1.1  mjacob 
    171  1.1  mjacob #endif	/* _ISP_NETBSD_H */
    172