Home | History | Annotate | Line # | Download | only in ic
      1  1.76  christos /* $NetBSD: isp_netbsd.h,v 1.76 2019/09/20 14:20:45 christos Exp $ */
      2   1.1    mjacob /*
      3   1.1    mjacob  * NetBSD Specific definitions for the Qlogic ISP Host Adapter
      4  1.15    mjacob  */
      5  1.15    mjacob /*
      6  1.15    mjacob  * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
      7   1.1    mjacob  * All rights reserved.
      8   1.1    mjacob  *
      9  1.59    mjacob  * Additional Copyright (C) 2000-2007 by Matthew Jacob
     10  1.59    mjacob  * All rights reserved.
     11  1.59    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.15    mjacob  *    notice, this list of conditions and the following disclaimer.
     17   1.1    mjacob  * 2. Redistributions in binary form must reproduce the above copyright
     18   1.1    mjacob  *    notice, this list of conditions and the following disclaimer in the
     19   1.1    mjacob  *    documentation and/or other materials provided with the distribution.
     20   1.1    mjacob  * 3. The name of the author may not be used to endorse or promote products
     21  1.15    mjacob  *    derived from this software without specific prior written permission
     22   1.1    mjacob  *
     23  1.15    mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  1.15    mjacob  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.15    mjacob  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.15    mjacob  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  1.15    mjacob  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  1.15    mjacob  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  1.15    mjacob  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  1.15    mjacob  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  1.15    mjacob  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  1.15    mjacob  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33   1.1    mjacob  */
     34   1.1    mjacob #ifndef	_ISP_NETBSD_H
     35   1.1    mjacob #define	_ISP_NETBSD_H
     36   1.1    mjacob 
     37   1.1    mjacob #include <sys/types.h>
     38   1.1    mjacob #include <sys/param.h>
     39   1.1    mjacob #include <sys/systm.h>
     40   1.1    mjacob #include <sys/kernel.h>
     41  1.53     perry #include <sys/errno.h>
     42   1.1    mjacob #include <sys/ioctl.h>
     43   1.1    mjacob #include <sys/device.h>
     44   1.1    mjacob #include <sys/malloc.h>
     45  1.53     perry #include <sys/buf.h>
     46   1.1    mjacob #include <sys/proc.h>
     47  1.43    mjacob #include <sys/kthread.h>
     48   1.1    mjacob 
     49  1.63        ad #include <sys/bus.h>
     50   1.1    mjacob 
     51   1.1    mjacob #include <dev/scsipi/scsi_all.h>
     52   1.1    mjacob #include <dev/scsipi/scsipi_all.h>
     53   1.1    mjacob #include <dev/scsipi/scsiconf.h>
     54   1.1    mjacob 
     55   1.1    mjacob #include <dev/scsipi/scsi_message.h>
     56   1.1    mjacob #include <dev/scsipi/scsipi_debug.h>
     57   1.1    mjacob 
     58  1.15    mjacob #include "opt_isp.h"
     59  1.26    mjacob 
     60  1.47    mjacob /*
     61  1.47    mjacob  * Efficiency- get rid of SBus code && tests unless we need them.
     62  1.47    mjacob  */
     63  1.47    mjacob #if	defined(__sparcv9__ ) || defined(__sparc__)
     64  1.47    mjacob #define	ISP_SBUS_SUPPORTED	1
     65  1.47    mjacob #else
     66  1.47    mjacob #define	ISP_SBUS_SUPPORTED	0
     67  1.47    mjacob #endif
     68  1.15    mjacob 
     69  1.67    mjacob #define	ISP_PLATFORM_VERSION_MAJOR	5
     70  1.59    mjacob #define	ISP_PLATFORM_VERSION_MINOR	0
     71   1.1    mjacob 
     72   1.1    mjacob struct isposinfo {
     73  1.68   tsutsui 	device_t		dev;
     74  1.64    mjacob 	struct scsipi_adapter   adapter;
     75  1.64    mjacob 	struct scsipi_channel * chan;
     76  1.47    mjacob 	bus_dma_tag_t		dmatag;
     77  1.47    mjacob 	bus_dmamap_t		rqdmap;
     78  1.47    mjacob 	bus_dmamap_t		rsdmap;
     79  1.71    mjacob 	bus_dmamap_t		scdmap;		/* FC only */
     80  1.71    mjacob 	uint64_t 		wwns[256];	/* FC only */
     81  1.47    mjacob 	int			splsaved;
     82  1.47    mjacob 	int			mboxwaiting;
     83  1.59    mjacob 	uint32_t		islocked;
     84  1.59    mjacob 	uint32_t		onintstack;
     85  1.59    mjacob 	uint32_t		loop_down_time;
     86  1.59    mjacob 	uint32_t		loop_down_limit;
     87  1.59    mjacob 	uint32_t		gone_device_time;
     88  1.59    mjacob 	unsigned int		: 16,
     89  1.59    mjacob 				: 8,
     90  1.59    mjacob 		gdt_running	: 1,
     91  1.43    mjacob 		loop_checked	: 1,
     92  1.59    mjacob 		mbox_sleeping	: 1,
     93  1.59    mjacob 		mbox_sleep_ok	: 1,
     94  1.59    mjacob 		mboxcmd_done	: 1,
     95  1.59    mjacob 		mboxbsy		: 1,
     96  1.43    mjacob 		paused		: 1,
     97  1.41    mjacob 		blocked		: 1;
     98  1.59    mjacob 	struct callout		ldt;	/* loop down timer */
     99  1.59    mjacob 	struct callout		gdt;	/* gone device timer */
    100  1.64    mjacob 	uint64_t		wwn;
    101  1.64    mjacob 	uint16_t		framesize;
    102  1.64    mjacob 	uint16_t		exec_throttle;
    103  1.62        ad 	struct lwp *		thread;
    104   1.1    mjacob };
    105  1.47    mjacob #define	isp_dmatag		isp_osinfo.dmatag
    106  1.47    mjacob #define	isp_rqdmap		isp_osinfo.rqdmap
    107  1.47    mjacob #define	isp_rsdmap		isp_osinfo.rsdmap
    108  1.47    mjacob #define	isp_scdmap		isp_osinfo.scdmap
    109  1.47    mjacob 
    110  1.32    mjacob #define	ISP_MUSTPOLL(isp)	\
    111  1.59    mjacob  	(isp->isp_osinfo.onintstack || isp->isp_osinfo.mbox_sleep_ok == 0)
    112  1.43    mjacob 
    113  1.27    mjacob /*
    114  1.27    mjacob  * Required Macros/Defines
    115  1.27    mjacob  */
    116  1.27    mjacob 
    117  1.64    mjacob #define	ISP_FC_SCRLEN		0x1000
    118   1.1    mjacob 
    119  1.67    mjacob #define	ISP_MEMZERO(dst, a)	memset((dst), 0, (a))
    120  1.67    mjacob #define	ISP_MEMCPY(dst, src, a)	memcpy((dst), (src), (a))
    121  1.67    mjacob #define	ISP_SNPRINTF		snprintf
    122  1.67    mjacob #define	ISP_DELAY		DELAY
    123  1.67    mjacob #define	ISP_SLEEP(isp, x)		\
    124  1.32    mjacob 	if (!ISP_MUSTPOLL(isp))		\
    125  1.32    mjacob 		ISP_UNLOCK(isp);	\
    126  1.32    mjacob 	DELAY(x);			\
    127  1.32    mjacob 	if (!ISP_MUSTPOLL(isp))		\
    128  1.32    mjacob 		ISP_LOCK(isp)
    129  1.27    mjacob 
    130  1.73    mjacob #define	ISP_MIN	imin
    131  1.67    mjacob #define	ISP_INLINE
    132  1.67    mjacob 
    133  1.27    mjacob #define	NANOTIME_T		struct timeval
    134  1.27    mjacob #define	GET_NANOTIME		microtime
    135  1.27    mjacob #define	GET_NANOSEC(x)		(((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000)
    136  1.27    mjacob #define	NANOTIME_SUB		isp_microtime_sub
    137   1.1    mjacob 
    138  1.27    mjacob #define	MAXISPREQUEST(isp)	256
    139   1.8    mjacob 
    140  1.47    mjacob 
    141  1.73    mjacob #define	MEMORYBARRIER(isp, type, offset, size, c)		\
    142  1.47    mjacob switch (type) {							\
    143  1.47    mjacob case SYNC_REQUEST:						\
    144  1.47    mjacob {								\
    145  1.47    mjacob 	off_t off = (off_t) offset * QENTRY_LEN;		\
    146  1.47    mjacob 	bus_dmamap_sync(isp->isp_dmatag, isp->isp_rqdmap,	\
    147  1.47    mjacob 	    off, size, BUS_DMASYNC_PREWRITE);			\
    148  1.47    mjacob 	break;							\
    149  1.47    mjacob }								\
    150  1.47    mjacob case SYNC_RESULT:						\
    151  1.47    mjacob {								\
    152  1.47    mjacob 	off_t off = (off_t) offset * QENTRY_LEN;		\
    153  1.47    mjacob 	bus_dmamap_sync(isp->isp_dmatag, isp->isp_rsdmap,	\
    154  1.47    mjacob 	    off, size, BUS_DMASYNC_POSTREAD);			\
    155  1.47    mjacob 	break;							\
    156  1.47    mjacob }								\
    157  1.47    mjacob case SYNC_SFORDEV:						\
    158  1.47    mjacob {								\
    159  1.49    mjacob 	off_t off = (off_t) offset;				\
    160  1.47    mjacob 	bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap,	\
    161  1.47    mjacob 	    off, size, BUS_DMASYNC_PREWRITE);			\
    162  1.47    mjacob 	break;							\
    163  1.47    mjacob }								\
    164  1.47    mjacob case SYNC_SFORCPU:						\
    165  1.47    mjacob {								\
    166  1.49    mjacob 	off_t off = (off_t) offset;				\
    167  1.47    mjacob 	bus_dmamap_sync(isp->isp_dmatag, isp->isp_scdmap,	\
    168  1.47    mjacob 	    off, size, BUS_DMASYNC_POSTREAD);			\
    169  1.47    mjacob 	break;							\
    170  1.47    mjacob }								\
    171  1.47    mjacob default:							\
    172  1.47    mjacob 	break;							\
    173  1.47    mjacob }
    174   1.3    mjacob 
    175  1.59    mjacob #define	MBOX_ACQUIRE		isp_mbox_acquire
    176  1.59    mjacob #define	MBOX_WAIT_COMPLETE	isp_mbox_wait_complete
    177  1.59    mjacob #define	MBOX_NOTIFY_COMPLETE	isp_mbox_notify_done
    178  1.59    mjacob #define	MBOX_RELEASE		isp_mbox_release
    179  1.26    mjacob 
    180  1.66    mjacob #define	FC_SCRATCH_ACQUIRE(isp, chan)	0
    181  1.66    mjacob #define	FC_SCRATCH_RELEASE(isp, chan)	do { } while (0)
    182  1.48    mjacob 
    183  1.27    mjacob #ifndef	SCSI_GOOD
    184  1.27    mjacob #define	SCSI_GOOD	0x0
    185  1.27    mjacob #endif
    186  1.27    mjacob #ifndef	SCSI_CHECK
    187  1.27    mjacob #define	SCSI_CHECK	0x2
    188  1.27    mjacob #endif
    189  1.27    mjacob #ifndef	SCSI_BUSY
    190  1.27    mjacob #define	SCSI_BUSY	0x8
    191  1.27    mjacob #endif
    192  1.27    mjacob #ifndef	SCSI_QFULL
    193  1.27    mjacob #define	SCSI_QFULL	0x28
    194  1.27    mjacob #endif
    195  1.26    mjacob 
    196  1.27    mjacob #define	XS_T			struct scsipi_xfer
    197  1.59    mjacob #define	XS_DMA_ADDR_T		bus_addr_t
    198  1.67    mjacob #define	XS_DMA_ADDR_T		bus_addr_t
    199  1.67    mjacob #define XS_GET_DMA64_SEG(a, b, c)		\
    200  1.67    mjacob {						\
    201  1.67    mjacob 	ispds64_t *d = a;			\
    202  1.67    mjacob 	bus_dma_segment_t *e = b;		\
    203  1.67    mjacob 	uint32_t f = c;				\
    204  1.67    mjacob 	e += f;					\
    205  1.67    mjacob         d->ds_base = DMA_LO32(e->ds_addr);	\
    206  1.67    mjacob         d->ds_basehi = DMA_HI32(e->ds_addr);	\
    207  1.67    mjacob         d->ds_count = e->ds_len;		\
    208  1.67    mjacob }
    209  1.67    mjacob #define XS_GET_DMA_SEG(a, b, c)			\
    210  1.67    mjacob {						\
    211  1.67    mjacob 	ispds_t *d = a;				\
    212  1.67    mjacob 	bus_dma_segment_t *e = b;		\
    213  1.67    mjacob 	uint32_t f = c;				\
    214  1.67    mjacob 	e += f;					\
    215  1.67    mjacob         d->ds_base = DMA_LO32(e->ds_addr);	\
    216  1.67    mjacob         d->ds_count = e->ds_len;		\
    217  1.67    mjacob }
    218  1.59    mjacob #define	XS_CHANNEL(xs)		\
    219  1.59    mjacob 	((int) (xs)->xs_periph->periph_channel->chan_channel)
    220  1.40    bouyer #define	XS_ISP(xs)		\
    221  1.68   tsutsui 	device_private((xs)->xs_periph->periph_channel->chan_adapter->adapt_dev)
    222  1.40    bouyer #define	XS_LUN(xs)		((int) (xs)->xs_periph->periph_lun)
    223  1.40    bouyer #define	XS_TGT(xs)		((int) (xs)->xs_periph->periph_target)
    224  1.59    mjacob #define	XS_CDBP(xs)		((uint8_t *) (xs)->cmd)
    225  1.27    mjacob #define	XS_CDBLEN(xs)		(xs)->cmdlen
    226   1.1    mjacob #define	XS_XFRLEN(xs)		(xs)->datalen
    227   1.1    mjacob #define	XS_TIME(xs)		(xs)->timeout
    228  1.67    mjacob #define	XS_GET_RESID(xs)	(xs)->resid
    229  1.67    mjacob #define	XS_SET_RESID(xs, r)	(xs)->resid = r
    230  1.27    mjacob #define	XS_STSP(xs)		(&(xs)->status)
    231   1.1    mjacob #define	XS_SNSP(xs)		(&(xs)->sense.scsi_sense)
    232  1.27    mjacob #define	XS_SNSLEN(xs)		(sizeof (xs)->sense)
    233  1.72    mjacob #define	XS_SNSKEY(xs)		SSD_SENSE_KEY((xs)->sense.scsi_sense.flags)
    234  1.72    mjacob #define	XS_SNSASC(xs)		((xs)->sense.scsi_sense.asc)
    235  1.72    mjacob #define	XS_SNSASCQ(xs)		((xs)->sense.scsi_sense.ascq)
    236  1.59    mjacob /* PORTING NOTES: check to see if there's a better way of checking for tagged */
    237  1.27    mjacob #define	XS_TAG_P(ccb)		(((xs)->xs_control & XS_CTL_POLL) != 0)
    238  1.59    mjacob /* PORTING NOTES: We elimited OTAG option for performance */
    239  1.27    mjacob #define	XS_TAG_TYPE(xs)	\
    240  1.59    mjacob 	(((xs)->xs_control & XS_CTL_URGENT) ? REQFLAG_HTAG : REQFLAG_STAG)
    241  1.27    mjacob 
    242  1.27    mjacob #define	XS_SETERR(xs, v)	(xs)->error = v
    243  1.27    mjacob 
    244  1.27    mjacob #	define	HBA_NOERROR		XS_NOERROR
    245  1.27    mjacob #	define	HBA_BOTCH		XS_DRIVER_STUFFUP
    246  1.27    mjacob #	define	HBA_CMDTIMEOUT		XS_TIMEOUT
    247  1.27    mjacob #	define	HBA_SELTIMEOUT		XS_SELTIMEOUT
    248  1.27    mjacob #	define	HBA_TGTBSY		XS_BUSY
    249  1.27    mjacob #	define	HBA_BUSRESET		XS_RESET
    250  1.27    mjacob #	define	HBA_ABORTED		XS_DRIVER_STUFFUP
    251  1.27    mjacob #	define	HBA_DATAOVR		XS_DRIVER_STUFFUP
    252  1.27    mjacob #	define	HBA_ARQFAIL		XS_DRIVER_STUFFUP
    253   1.1    mjacob 
    254  1.27    mjacob #define	XS_ERR(xs)		(xs)->error
    255  1.75     joerg #define	XS_NOERR(xs)		((xs)->error == XS_NOERROR)
    256  1.27    mjacob #define	XS_INITERR(xs)		(xs)->error = 0, XS_CMD_S_CLEAR(xs)
    257  1.27    mjacob 
    258  1.59    mjacob #define	XS_SAVE_SENSE(xs, ptr, len)				\
    259  1.59    mjacob 	if (xs->error == XS_NOERROR) {				\
    260  1.59    mjacob 		xs->error = XS_SENSE;				\
    261  1.59    mjacob 	}							\
    262  1.59    mjacob 	memcpy(&(xs)->sense, ptr, imin(XS_SNSLEN(xs), len))
    263  1.27    mjacob 
    264  1.72    mjacob #define	XS_SENSE_VALID(xs)		(xs)->error == XS_SENSE
    265  1.72    mjacob 
    266  1.64    mjacob #define	DEFAULT_FRAMESIZE(isp)		(isp)->isp_osinfo.framesize
    267  1.64    mjacob #define	DEFAULT_EXEC_THROTTLE(isp)	(isp)->isp_osinfo.exec_throttle
    268  1.64    mjacob #define	GET_DEFAULT_ROLE(isp, chan)	ISP_ROLE_INITIATOR
    269  1.64    mjacob #define	SET_DEFAULT_ROLE(isp, chan)	do { } while (0)
    270  1.64    mjacob #define	DEFAULT_IID(x, chan)		7
    271  1.64    mjacob #define	DEFAULT_LOOPID(x, chan)		108
    272  1.64    mjacob #define	DEFAULT_NODEWWN(isp, chan)	(isp)->isp_osinfo.wwn
    273  1.64    mjacob #define	DEFAULT_PORTWWN(isp, chan)	(isp)->isp_osinfo.wwn
    274  1.64    mjacob #define	ACTIVE_NODEWWN(isp, chan)				\
    275  1.70    mjacob 	((isp)->isp_osinfo.wwn? (isp)->isp_osinfo.wwn :	\
    276  1.70    mjacob 	(FCPARAM(isp, chan)->isp_wwnn_nvram?		\
    277  1.70    mjacob 	 FCPARAM(isp, chan)->isp_wwnn_nvram : 0x400000007F000008ull))
    278  1.64    mjacob #define	ACTIVE_PORTWWN(isp, chan)				\
    279  1.70    mjacob 	((isp)->isp_osinfo.wwn? (isp)->isp_osinfo.wwn :	\
    280  1.70    mjacob 	(FCPARAM(isp, chan)->isp_wwpn_nvram?		\
    281  1.70    mjacob 	 FCPARAM(isp, chan)->isp_wwpn_nvram : 0x400000007F000008ull))
    282  1.27    mjacob 
    283  1.32    mjacob #if	_BYTE_ORDER == _BIG_ENDIAN
    284  1.47    mjacob #ifdef	ISP_SBUS_SUPPORTED
    285  1.47    mjacob #define	ISP_IOXPUT_8(isp, s, d)		*(d) = s
    286  1.47    mjacob #define	ISP_IOXPUT_16(isp, s, d)				\
    287  1.47    mjacob 	*(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap16(s)
    288  1.47    mjacob #define	ISP_IOXPUT_32(isp, s, d)				\
    289  1.47    mjacob 	*(d) = (isp->isp_bustype == ISP_BT_SBUS)? s : bswap32(s)
    290  1.47    mjacob 
    291  1.59    mjacob #define	ISP_IOXGET_8(isp, s, d)		d = (*((uint8_t *)s))
    292  1.47    mjacob #define	ISP_IOXGET_16(isp, s, d)				\
    293  1.47    mjacob 	d = (isp->isp_bustype == ISP_BT_SBUS)?			\
    294  1.59    mjacob 	*((uint16_t *)s) : bswap16(*((uint16_t *)s))
    295  1.47    mjacob #define	ISP_IOXGET_32(isp, s, d)				\
    296  1.47    mjacob 	d = (isp->isp_bustype == ISP_BT_SBUS)?			\
    297  1.59    mjacob 	*((uint32_t *)s) : bswap32(*((uint32_t *)s))
    298  1.59    mjacob 
    299  1.59    mjacob #else	/* ISP_SBUS_SUPPORTED */
    300  1.47    mjacob #define	ISP_IOXPUT_8(isp, s, d)		*(d) = s
    301  1.47    mjacob #define	ISP_IOXPUT_16(isp, s, d)	*(d) = bswap16(s)
    302  1.47    mjacob #define	ISP_IOXPUT_32(isp, s, d)	*(d) = bswap32(s)
    303  1.59    mjacob #define	ISP_IOXGET_8(isp, s, d)		d = (*((uint8_t *)s))
    304  1.59    mjacob #define	ISP_IOXGET_16(isp, s, d)	d = bswap16(*((uint16_t *)s))
    305  1.59    mjacob #define	ISP_IOXGET_32(isp, s, d)	d = bswap32(*((uint32_t *)s))
    306  1.59    mjacob #endif	/* ISP_SBUS_SUPPORTED */
    307  1.32    mjacob #define	ISP_SWIZZLE_NVRAM_WORD(isp, rp)	*rp = bswap16(*rp)
    308  1.60    mjacob #define	ISP_SWIZZLE_NVRAM_LONG(isp, rp)	*rp = bswap32(*rp)
    309  1.59    mjacob 
    310  1.59    mjacob #define	ISP_IOZGET_8(isp, s, d)		d = (*((uint8_t *)s))
    311  1.59    mjacob #define	ISP_IOZGET_16(isp, s, d)	d = (*((uint16_t *)s))
    312  1.59    mjacob #define	ISP_IOZGET_32(isp, s, d)	d = (*((uint32_t *)s))
    313  1.59    mjacob #define	ISP_IOZPUT_8(isp, s, d)		*(d) = s
    314  1.59    mjacob #define	ISP_IOZPUT_16(isp, s, d)	*(d) = s
    315  1.59    mjacob #define	ISP_IOZPUT_32(isp, s, d)	*(d) = s
    316  1.59    mjacob 
    317   1.3    mjacob #else
    318  1.47    mjacob #define	ISP_IOXPUT_8(isp, s, d)		*(d) = s
    319  1.47    mjacob #define	ISP_IOXPUT_16(isp, s, d)	*(d) = s
    320  1.47    mjacob #define	ISP_IOXPUT_32(isp, s, d)	*(d) = s
    321  1.47    mjacob #define	ISP_IOXGET_8(isp, s, d)		d = *(s)
    322  1.47    mjacob #define	ISP_IOXGET_16(isp, s, d)	d = *(s)
    323  1.47    mjacob #define	ISP_IOXGET_32(isp, s, d)	d = *(s)
    324  1.27    mjacob #define	ISP_SWIZZLE_NVRAM_WORD(isp, rp)
    325  1.61    mjacob #define	ISP_SWIZZLE_NVRAM_LONG(isp, rp)
    326  1.59    mjacob 
    327  1.59    mjacob #define	ISP_IOZPUT_8(isp, s, d)		*(d) = s
    328  1.59    mjacob #define	ISP_IOZPUT_16(isp, s, d)	*(d) = bswap16(s)
    329  1.59    mjacob #define	ISP_IOZPUT_32(isp, s, d)	*(d) = bswap32(s)
    330  1.59    mjacob 
    331  1.59    mjacob #define	ISP_IOZGET_8(isp, s, d)		d = (*((uint8_t *)(s)))
    332  1.59    mjacob #define	ISP_IOZGET_16(isp, s, d)	d = bswap16(*((uint16_t *)(s)))
    333  1.59    mjacob #define	ISP_IOZGET_32(isp, s, d)	d = bswap32(*((uint32_t *)(s)))
    334  1.59    mjacob 
    335  1.27    mjacob #endif
    336  1.27    mjacob 
    337  1.60    mjacob #define	ISP_SWAP16(isp, x)		bswap16(x)
    338  1.60    mjacob #define	ISP_SWAP32(isp, x)		bswap32(x)
    339  1.60    mjacob 
    340  1.27    mjacob /*
    341  1.27    mjacob  * Includes of common header files
    342  1.27    mjacob  */
    343   1.1    mjacob 
    344  1.27    mjacob #include <dev/ic/ispreg.h>
    345  1.27    mjacob #include <dev/ic/ispvar.h>
    346  1.27    mjacob #include <dev/ic/ispmbox.h>
    347  1.27    mjacob 
    348  1.27    mjacob /*
    349  1.27    mjacob  * isp_osinfo definitions, extensions and shorthand.
    350  1.27    mjacob  */
    351  1.68   tsutsui #define	isp_unit	device_unit(isp_osinfo.dev)
    352  1.43    mjacob 
    353  1.27    mjacob 
    354  1.27    mjacob /*
    355  1.27    mjacob  * Driver prototypes..
    356  1.27    mjacob  */
    357  1.59    mjacob void isp_attach(ispsoftc_t *);
    358  1.59    mjacob void isp_uninit(ispsoftc_t *);
    359  1.27    mjacob 
    360  1.27    mjacob /*
    361  1.27    mjacob  * Driver wide data...
    362  1.27    mjacob  */
    363  1.27    mjacob 
    364  1.27    mjacob /*
    365  1.27    mjacob  * Locking macros...
    366  1.27    mjacob  */
    367  1.27    mjacob #define	ISP_LOCK		isp_lock
    368  1.27    mjacob #define	ISP_UNLOCK		isp_unlock
    369  1.29    mjacob #define	ISP_ILOCK(x)		isp_lock(x); isp->isp_osinfo.onintstack++
    370  1.29    mjacob #define	ISP_IUNLOCK(x)		isp->isp_osinfo.onintstack--; isp_unlock(x)
    371  1.27    mjacob 
    372  1.53     perry /*
    373  1.53     perry  * Platform private flags
    374  1.27    mjacob  */
    375   1.1    mjacob 
    376  1.26    mjacob #define	XS_PSTS_INWDOG		0x10000000
    377  1.26    mjacob #define	XS_PSTS_GRACE		0x20000000
    378  1.26    mjacob #define	XS_PSTS_ALL		0x30000000
    379  1.26    mjacob 
    380  1.26    mjacob #define	XS_CMD_S_WDOG(xs)	(xs)->xs_status |= XS_PSTS_INWDOG
    381  1.26    mjacob #define	XS_CMD_C_WDOG(xs)	(xs)->xs_status &= ~XS_PSTS_INWDOG
    382  1.26    mjacob #define	XS_CMD_WDOG_P(xs)	(((xs)->xs_status & XS_PSTS_INWDOG) != 0)
    383  1.26    mjacob 
    384  1.26    mjacob #define	XS_CMD_S_GRACE(xs)	(xs)->xs_status |= XS_PSTS_GRACE
    385  1.26    mjacob #define	XS_CMD_C_GRACE(xs)	(xs)->xs_status &= ~XS_PSTS_GRACE
    386  1.26    mjacob #define	XS_CMD_GRACE_P(xs)	(((xs)->xs_status & XS_PSTS_GRACE) != 0)
    387  1.26    mjacob 
    388  1.26    mjacob #define	XS_CMD_S_DONE(xs)	(xs)->xs_status |= XS_STS_DONE
    389  1.26    mjacob #define	XS_CMD_C_DONE(xs)	(xs)->xs_status &= ~XS_STS_DONE
    390  1.26    mjacob #define	XS_CMD_DONE_P(xs)	(((xs)->xs_status & XS_STS_DONE) != 0)
    391  1.26    mjacob 
    392  1.26    mjacob #define	XS_CMD_S_CLEAR(xs)	(xs)->xs_status &= ~XS_PSTS_ALL
    393  1.26    mjacob 
    394   1.1    mjacob /*
    395  1.59    mjacob  * Platform Library Functionw
    396   1.1    mjacob  */
    397  1.76  christos void isp_prt(ispsoftc_t *, int level, const char *, ...) __printflike(3, 4);
    398  1.76  christos void isp_xs_prt(ispsoftc_t *, XS_T *, int level, const char *, ...)
    399  1.76  christos     __printflike(4, 5);
    400  1.59    mjacob void isp_lock(ispsoftc_t *);
    401  1.59    mjacob void isp_unlock(ispsoftc_t *);
    402  1.59    mjacob uint64_t isp_microtime_sub(struct timeval *, struct timeval *);
    403  1.59    mjacob int isp_mbox_acquire(ispsoftc_t *);
    404  1.59    mjacob void isp_mbox_wait_complete(ispsoftc_t *, mbreg_t *);
    405  1.59    mjacob void isp_mbox_notify_done(ispsoftc_t *);
    406  1.59    mjacob void isp_mbox_release(ispsoftc_t *);
    407  1.27    mjacob 
    408  1.27    mjacob /*
    409  1.59    mjacob  * Common Library functions
    410  1.27    mjacob  */
    411  1.59    mjacob #include <dev/ic/isp_library.h>
    412  1.18    mjacob 
    413  1.19    mjacob #if	!defined(ISP_DISABLE_FW) && !defined(ISP_COMPILE_FW)
    414  1.19    mjacob #define	ISP_COMPILE_FW	1
    415  1.19    mjacob #endif
    416   1.1    mjacob #endif	/* _ISP_NETBSD_H */
    417