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