1 /* $FreeBSD$ */ 2 /* $Id: isp_freebsd.h,v 1.12 1998/09/08 01:01:53 mjacob Exp $ */ 3 /* 4 * Qlogic ISP SCSI Host Adapter FreeBSD Wrapper Definitions (non CAM version) 5 *--------------------------------------- 6 * Copyright (c) 1997, 1998 by Matthew Jacob 7 * NASA/Ames Research Center 8 * All rights reserved. 9 *--------------------------------------- 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice immediately at the beginning of the file, without modification, 16 * this list of conditions, and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 3. The name of the author may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 #ifndef _ISP_FREEBSD_H 36 #define _ISP_FREEBSD_H 37 38 #define ISP_PLATFORM_VERSION_MAJOR 0 39 #define ISP_PLATFORM_VERSION_MINOR 95 40 41 #include "opt_scsi.h" 42 #ifdef SCSI_CAM 43 #include <dev/isp/isp_freebsd_cam.h> 44 #else 45 46 #include <sys/param.h> 47 #include <sys/systm.h> 48 #include <sys/malloc.h> 49 #include <sys/buf.h> 50 #include <sys/proc.h> 51 52 #include <scsi/scsiconf.h> 53 #include <machine/clock.h> 54 #include <vm/vm.h> 55 #include <vm/vm_param.h> 56 #include <vm/pmap.h> 57 #include <sys/kernel.h> 58 59 /* 60 * Now that __FreeBSD_version is in sys/param.h, we can 61 * automatically handle pre-3.0 cases. 62 */ 63 64 #ifndef __FreeBSD_version 65 #define __FreeBSD_version 226000 66 #endif 67 68 #define ISP_SCSI_XFER_T struct scsi_xfer 69 struct isposinfo { 70 char name[8]; 71 int unit; 72 struct scsi_link _link; 73 #if __FreeBSD_version >= 300001 74 struct callout_handle watchid; 75 #endif 76 }; 77 78 /* 79 * XXXX: UNTIL WE PUT CODE IN THAT CHECKS RETURNS FROM MALLOC 80 * XXXX: FOR CONTIGOUS PAGES, WE LIMIT TO PAGE_SIZE THE SIZE 81 * XXXX: OF MAILBOXES. 82 */ 83 #define MAXISPREQUEST 64 84 85 86 #include <dev/isp/ispreg.h> 87 #include <dev/isp/ispvar.h> 88 #include <dev/isp/ispmbox.h> 89 90 #define PRINTF printf 91 #define IDPRINTF(lev, x) if (isp->isp_dblev >= lev) printf x 92 #define DFLT_DBLEVEL 1 93 94 #define ISP_LOCKVAL_DECL int isp_spl_save 95 #define ISP_UNLOCK(isp) (void) splx(isp_spl_save) 96 #define ISP_LOCK(isp) isp_spl_save = splbio() 97 #define ISP_ILOCK(isp) ISP_LOCK(isp) 98 #define ISP_IUNLOCK(isp) ISP_UNLOCK(isp) 99 #define IMASK bio_imask 100 101 #define XS_NULL(xs) xs == NULL || xs->sc_link == NULL 102 #define XS_ISP(xs) \ 103 ((struct ispsoftc *) (xs)->sc_link->adapter_softc) 104 #define XS_LUN(xs) (xs)->sc_link->lun 105 #define XS_TGT(xs) (xs)->sc_link->target 106 #define XS_RESID(xs) (xs)->resid 107 #define XS_XFRLEN(xs) (xs)->datalen 108 #define XS_CDBLEN(xs) (xs)->cmdlen 109 #define XS_CDBP(xs) (xs)->cmd 110 #define XS_STS(xs) (xs)->status 111 #define XS_TIME(xs) (xs)->timeout 112 #define XS_SNSP(xs) (&(xs)->sense) 113 #define XS_SNSLEN(xs) (sizeof (xs)->sense) 114 #define XS_SNSKEY(xs) ((xs)->sense.ext.extended.flags) 115 116 #define HBA_NOERROR XS_NOERROR 117 #define HBA_BOTCH XS_DRIVER_STUFFUP 118 #define HBA_CMDTIMEOUT XS_TIMEOUT 119 #define HBA_SELTIMEOUT XS_SELTIMEOUT 120 #define HBA_TGTBSY XS_BUSY 121 #define HBA_BUSRESET XS_DRIVER_STUFFUP 122 #define HBA_ABORTED XS_DRIVER_STUFFUP 123 #define HBA_DATAOVR XS_DRIVER_STUFFUP 124 #define HBA_ARQFAIL XS_DRIVER_STUFFUP 125 126 #define XS_SNS_IS_VALID(xs) (xs)->error = XS_SENSE 127 #define XS_IS_SNS_VALID(xs) ((xs)->error == XS_SENSE) 128 129 #define XS_INITERR(xs) (xs)->error = 0 130 #define XS_SETERR(xs, v) (xs)->error = v 131 #define XS_ERR(xs) (xs)->error 132 #define XS_NOERR(xs) (xs)->error == XS_NOERROR 133 134 #define XS_CMD_DONE(xs) (xs)->flags |= ITSDONE, scsi_done(xs) 135 #define XS_IS_CMD_DONE(xs) (((xs)->flags & ITSDONE) != 0) 136 137 /* 138 * We decide whether to use tags based upon whether we're polling. 139 */ 140 #define XS_CANTAG(xs) (((xs)->flags & SCSI_NOMASK) != 0) 141 142 /* 143 * Our default tag 144 */ 145 #define XS_KINDOF_TAG(xs) REQFLAG_OTAG 146 147 148 #define CMD_COMPLETE COMPLETE 149 #define CMD_EAGAIN TRY_AGAIN_LATER 150 #define CMD_QUEUED SUCCESSFULLY_QUEUED 151 152 153 154 #define isp_name isp_osinfo.name 155 156 157 #define SYS_DELAY(x) DELAY(x) 158 159 #define WATCH_INTERVAL 30 160 #if __FreeBSD_version >= 300001 161 #define START_WATCHDOG(f, s) \ 162 (s)->isp_osinfo.watchid = timeout(f, s, WATCH_INTERVAL * hz), \ 163 s->isp_dogactive = 1 164 #define STOP_WATCHDOG(f, s) untimeout(f, s, (s)->isp_osinfo.watchid),\ 165 (s)->isp_dogactive = 0 166 #else 167 #define START_WATCHDOG(f, s) \ 168 timeout(f, s, WATCH_INTERVAL * hz), s->isp_dogactive = 1 169 #define STOP_WATCHDOG(f, s) untimeout(f, s), (s)->isp_dogactive = 0 170 #endif 171 172 #define RESTART_WATCHDOG(f, s) START_WATCHDOG(f, s) 173 extern void isp_attach __P((struct ispsoftc *)); 174 175 #define PVS "Qlogic ISP Driver, FreeBSD Non-Cam" 176 177 #endif /* !SCSI_CAM */ 178 #endif /* _ISP_FREEBSD_H */ 179