149ef7e0Garrett D'Amore/*
249ef7e0Garrett D'Amore * Copyright (c) 2008-2016 Solarflare Communications Inc.
349ef7e0Garrett D'Amore * All rights reserved.
449ef7e0Garrett D'Amore *
549ef7e0Garrett D'Amore * Redistribution and use in source and binary forms, with or without
649ef7e0Garrett D'Amore * modification, are permitted provided that the following conditions are met:
749ef7e0Garrett D'Amore *
849ef7e0Garrett D'Amore * 1. Redistributions of source code must retain the above copyright notice,
949ef7e0Garrett D'Amore *    this list of conditions and the following disclaimer.
1049ef7e0Garrett D'Amore * 2. Redistributions in binary form must reproduce the above copyright notice,
1149ef7e0Garrett D'Amore *    this list of conditions and the following disclaimer in the documentation
1249ef7e0Garrett D'Amore *    and/or other materials provided with the distribution.
1349ef7e0Garrett D'Amore *
1449ef7e0Garrett D'Amore * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1549ef7e0Garrett D'Amore * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1649ef7e0Garrett D'Amore * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1749ef7e0Garrett D'Amore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
1849ef7e0Garrett D'Amore * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1949ef7e0Garrett D'Amore * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2049ef7e0Garrett D'Amore * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2149ef7e0Garrett D'Amore * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2249ef7e0Garrett D'Amore * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2349ef7e0Garrett D'Amore * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2449ef7e0Garrett D'Amore * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2549ef7e0Garrett D'Amore *
2649ef7e0Garrett D'Amore * The views and conclusions contained in the software and documentation are
2749ef7e0Garrett D'Amore * those of the authors and should not be interpreted as representing official
2849ef7e0Garrett D'Amore * policies, either expressed or implied, of the FreeBSD Project.
2949ef7e0Garrett D'Amore */
3049ef7e0Garrett D'Amore
3149ef7e0Garrett D'Amore#ifndef	_SYS_EFSYS_H
3249ef7e0Garrett D'Amore#define	_SYS_EFSYS_H
3349ef7e0Garrett D'Amore
3449ef7e0Garrett D'Amore#ifdef	__cplusplus
3549ef7e0Garrett D'Amoreextern "C" {
3649ef7e0Garrett D'Amore#endif
3749ef7e0Garrett D'Amore
3849ef7e0Garrett D'Amore#include <sys/types.h>
3949ef7e0Garrett D'Amore#include <sys/sysmacros.h>
4049ef7e0Garrett D'Amore#include <sys/ddi.h>
4149ef7e0Garrett D'Amore#include <sys/sunddi.h>
4249ef7e0Garrett D'Amore#include <sys/cpuvar.h>
4349ef7e0Garrett D'Amore#include <sys/disp.h>
4449ef7e0Garrett D'Amore#include <sys/sdt.h>
4549ef7e0Garrett D'Amore#include <sys/kstat.h>
4649ef7e0Garrett D'Amore#include <sys/crc32.h>
4749ef7e0Garrett D'Amore#include <sys/note.h>
4849ef7e0Garrett D'Amore#include <sys/byteorder.h>
4949ef7e0Garrett D'Amore
5049ef7e0Garrett D'Amore#define	EFSYS_HAS_UINT64 1
5149ef7e0Garrett D'Amore#define	EFSYS_USE_UINT64 0
5249ef7e0Garrett D'Amore#define	EFSYS_HAS_SSE2_M128 0
5349ef7e0Garrett D'Amore#ifdef	_BIG_ENDIAN
5449ef7e0Garrett D'Amore#define	EFSYS_IS_BIG_ENDIAN 1
5549ef7e0Garrett D'Amore#endif
5649ef7e0Garrett D'Amore#ifdef	_LITTLE_ENDIAN
5749ef7e0Garrett D'Amore#define	EFSYS_IS_LITTLE_ENDIAN 1
5849ef7e0Garrett D'Amore#endif
5949ef7e0Garrett D'Amore#include "efx_types.h"
6049ef7e0Garrett D'Amore
6149ef7e0Garrett D'Amore/* Modifiers used for Windows builds */
6249ef7e0Garrett D'Amore#define	__in
6349ef7e0Garrett D'Amore#define	__in_opt
6449ef7e0Garrett D'Amore#define	__in_ecount(_n)
6549ef7e0Garrett D'Amore#define	__in_ecount_opt(_n)
6649ef7e0Garrett D'Amore#define	__in_bcount(_n)
6749ef7e0Garrett D'Amore#define	__in_bcount_opt(_n)
6849ef7e0Garrett D'Amore
6949ef7e0Garrett D'Amore#define	__out
7049ef7e0Garrett D'Amore#define	__out_opt
7149ef7e0Garrett D'Amore#define	__out_ecount(_n)
7249ef7e0Garrett D'Amore#define	__out_ecount_opt(_n)
7349ef7e0Garrett D'Amore#define	__out_bcount(_n)
7449ef7e0Garrett D'Amore#define	__out_bcount_opt(_n)
7549ef7e0Garrett D'Amore#define	__out_bcount_part(_n, _l)
7649ef7e0Garrett D'Amore#define	__out_bcount_part_opt(_n, _l)
7749ef7e0Garrett D'Amore
7849ef7e0Garrett D'Amore#define	__deref_out
7949ef7e0Garrett D'Amore
8049ef7e0Garrett D'Amore#define	__inout
8149ef7e0Garrett D'Amore#define	__inout_opt
8249ef7e0Garrett D'Amore#define	__inout_ecount(_n)
8349ef7e0Garrett D'Amore#define	__inout_ecount_opt(_n)
8449ef7e0Garrett D'Amore#define	__inout_bcount(_n)
8549ef7e0Garrett D'Amore#define	__inout_bcount_opt(_n)
8649ef7e0Garrett D'Amore#define	__inout_bcount_full_opt(_n)
8749ef7e0Garrett D'Amore
8849ef7e0Garrett D'Amore#define	__deref_out_bcount_opt(n)
8949ef7e0Garrett D'Amore
9049ef7e0Garrett D'Amore#define	__checkReturn
9149ef7e0Garrett D'Amore#define	__success(_x)
9249ef7e0Garrett D'Amore
9349ef7e0Garrett D'Amore#define	__drv_when(_p, _c)
9449ef7e0Garrett D'Amore
9549ef7e0Garrett D'Amore/* Code inclusion options */
9649ef7e0Garrett D'Amore
9749ef7e0Garrett D'Amore
9849ef7e0Garrett D'Amore#define	EFSYS_OPT_NAMES 1
9949ef7e0Garrett D'Amore
10049ef7e0Garrett D'Amore#define	EFSYS_OPT_SIENA 1
10149ef7e0Garrett D'Amore#define	EFSYS_OPT_HUNTINGTON 1
10249ef7e0Garrett D'Amore#define	EFSYS_OPT_MEDFORD 0
10349ef7e0Garrett D'Amore#if DEBUG
10449ef7e0Garrett D'Amore#define	EFSYS_OPT_CHECK_REG 1
10549ef7e0Garrett D'Amore#else
10649ef7e0Garrett D'Amore#define	EFSYS_OPT_CHECK_REG 0
10749ef7e0Garrett D'Amore#endif
10849ef7e0Garrett D'Amore
10949ef7e0Garrett D'Amore#define	EFSYS_OPT_MCDI 1
11049ef7e0Garrett D'Amore#define	EFSYS_OPT_MCDI_LOGGING 0
11149ef7e0Garrett D'Amore#define	EFSYS_OPT_MCDI_PROXY_AUTH 0
11249ef7e0Garrett D'Amore
11349ef7e0Garrett D'Amore#define	EFSYS_OPT_MAC_STATS 1
11449ef7e0Garrett D'Amore
11549ef7e0Garrett D'Amore#define	EFSYS_OPT_LOOPBACK 1
11649ef7e0Garrett D'Amore
11749ef7e0Garrett D'Amore#define	EFSYS_OPT_MON_MCDI 1
11849ef7e0Garrett D'Amore#define	EFSYS_OPT_MON_STATS 1
11949ef7e0Garrett D'Amore
12049ef7e0Garrett D'Amore#define	EFSYS_OPT_PHY_STATS 1
12149ef7e0Garrett D'Amore#define	EFSYS_OPT_BIST 1
12249ef7e0Garrett D'Amore#define	EFSYS_OPT_PHY_LED_CONTROL 1
12349ef7e0Garrett D'Amore
12449ef7e0Garrett D'Amore#define	EFSYS_OPT_VPD 1
12549ef7e0Garrett D'Amore#define	EFSYS_OPT_NVRAM 1
12649ef7e0Garrett D'Amore#define	EFSYS_OPT_BOOTCFG 1
12749ef7e0Garrett D'Amore
12849ef7e0Garrett D'Amore#define	EFSYS_OPT_DIAG 0
12949ef7e0Garrett D'Amore#define	EFSYS_OPT_WOL 1
13049ef7e0Garrett D'Amore#define	EFSYS_OPT_RX_SCALE 1
13149ef7e0Garrett D'Amore#define	EFSYS_OPT_QSTATS 1
13249ef7e0Garrett D'Amore
13349ef7e0Garrett D'Amore#define	EFSYS_OPT_EV_PREFETCH 0
13449ef7e0Garrett D'Amore
13549ef7e0Garrett D'Amore#define	EFSYS_OPT_DECODE_INTR_FATAL 1
13649ef7e0Garrett D'Amore
13749ef7e0Garrett D'Amore#define	EFSYS_OPT_FILTER 1
13849ef7e0Garrett D'Amore
13949ef7e0Garrett D'Amore#define	EFSYS_OPT_LICENSING 0
14049ef7e0Garrett D'Amore
14149ef7e0Garrett D'Amore/* ID */
14249ef7e0Garrett D'Amore
14349ef7e0Garrett D'Amoretypedef struct __efsys_identifier_s	efsys_identifier_t;
14449ef7e0Garrett D'Amore
14549ef7e0Garrett D'Amore/* DMA */
14649ef7e0Garrett D'Amore
14749ef7e0Garrett D'Amoretypedef uint64_t		efsys_dma_addr_t;
14849ef7e0Garrett D'Amore
14949ef7e0Garrett D'Amoretypedef struct efsys_mem_s {
15049ef7e0Garrett D'Amore	ddi_dma_handle_t	esm_dma_handle; /* DMA memory allocate/bind */
15149ef7e0Garrett D'Amore	ddi_acc_handle_t	esm_acc_handle;	/* DMA memory read/write */
15249ef7e0Garrett D'Amore	caddr_t			esm_base;
15349ef7e0Garrett D'Amore	efsys_dma_addr_t	esm_addr;
15449ef7e0Garrett D'Amore	size_t			esm_size;
15549ef7e0Garrett D'Amore	size_t			esm_used;
15649ef7e0Garrett D'Amore} efsys_mem_t;
15749ef7e0Garrett D'Amore
15849ef7e0Garrett D'Amore
15949ef7e0Garrett D'Amore#define	EFSYS_MEM_ZERO(_esmp, _size)					\
16049ef7e0Garrett D'Amore	(void) bzero((_esmp)->esm_base, (_size))
16149ef7e0Garrett D'Amore
16249ef7e0Garrett D'Amore#define	EFSYS_MEM_READD(_esmp, _offset, _edp)				\
16349ef7e0Garrett D'Amore	do {								\
16449ef7e0Garrett D'Amore		uint32_t *addr;						\
16549ef7e0Garrett D'Amore									\
16649ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
16749ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_dword_t)));	\
16849ef7e0Garrett D'Amore									\
16949ef7e0Garrett D'Amore		addr = (void *)((_esmp)->esm_base + (_offset));		\
17049ef7e0Garrett D'Amore									\
17149ef7e0Garrett D'Amore		(_edp)->ed_u32[0] = ddi_get32((_esmp)->esm_acc_handle,	\
17249ef7e0Garrett D'Amore		    addr);						\
17349ef7e0Garrett D'Amore									\
17449ef7e0Garrett D'Amore		DTRACE_PROBE2(mem_readd, unsigned int, (_offset),	\
17549ef7e0Garrett D'Amore		    uint32_t, (_edp)->ed_u32[0]);			\
17649ef7e0Garrett D'Amore									\
17749ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
17849ef7e0Garrett D'Amore	} while (B_FALSE)
17949ef7e0Garrett D'Amore
18049ef7e0Garrett D'Amore#define	EFSYS_MEM_READQ(_esmp, _offset, _eqp)				\
18149ef7e0Garrett D'Amore	do {								\
18249ef7e0Garrett D'Amore		uint32_t *addr;						\
18349ef7e0Garrett D'Amore									\
18449ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
18549ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)));	\
18649ef7e0Garrett D'Amore									\
18749ef7e0Garrett D'Amore		addr = (void *)((_esmp)->esm_base + (_offset));		\
18849ef7e0Garrett D'Amore									\
18949ef7e0Garrett D'Amore		(_eqp)->eq_u32[0] = ddi_get32((_esmp)->esm_acc_handle,	\
19049ef7e0Garrett D'Amore		    addr++);						\
19149ef7e0Garrett D'Amore		(_eqp)->eq_u32[1] = ddi_get32((_esmp)->esm_acc_handle,	\
19249ef7e0Garrett D'Amore		    addr);						\
19349ef7e0Garrett D'Amore									\
19449ef7e0Garrett D'Amore		DTRACE_PROBE3(mem_readq, unsigned int, (_offset),	\
19549ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[1],			\
19649ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[0]);			\
19749ef7e0Garrett D'Amore									\
19849ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
19949ef7e0Garrett D'Amore	} while (B_FALSE)
20049ef7e0Garrett D'Amore
20149ef7e0Garrett D'Amore#define	EFSYS_MEM_READO(_esmp, _offset, _eop)				\
20249ef7e0Garrett D'Amore	do {								\
20349ef7e0Garrett D'Amore		uint32_t *addr;						\
20449ef7e0Garrett D'Amore									\
20549ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
20649ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_oword_t)));	\
20749ef7e0Garrett D'Amore									\
20849ef7e0Garrett D'Amore		addr = (void *)((_esmp)->esm_base + (_offset));		\
20949ef7e0Garrett D'Amore									\
21049ef7e0Garrett D'Amore		(_eop)->eo_u32[0] = ddi_get32((_esmp)->esm_acc_handle,	\
21149ef7e0Garrett D'Amore		    addr++);						\
21249ef7e0Garrett D'Amore		(_eop)->eo_u32[1] = ddi_get32((_esmp)->esm_acc_handle,	\
21349ef7e0Garrett D'Amore		    addr++);						\
21449ef7e0Garrett D'Amore		(_eop)->eo_u32[2] = ddi_get32((_esmp)->esm_acc_handle,	\
21549ef7e0Garrett D'Amore		    addr++);						\
21649ef7e0Garrett D'Amore		(_eop)->eo_u32[3] = ddi_get32((_esmp)->esm_acc_handle,	\
21749ef7e0Garrett D'Amore		    addr);						\
21849ef7e0Garrett D'Amore									\
21949ef7e0Garrett D'Amore		DTRACE_PROBE5(mem_reado, unsigned int, (_offset),	\
22049ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[3],			\
22149ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[2],			\
22249ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[1],			\
22349ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[0]);			\
22449ef7e0Garrett D'Amore									\
22549ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
22649ef7e0Garrett D'Amore	} while (B_FALSE)
22749ef7e0Garrett D'Amore
22849ef7e0Garrett D'Amore#define	EFSYS_MEM_WRITED(_esmp, _offset, _edp)				\
22949ef7e0Garrett D'Amore	do {								\
23049ef7e0Garrett D'Amore		uint32_t *addr;						\
23149ef7e0Garrett D'Amore									\
23249ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
23349ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_dword_t)));	\
23449ef7e0Garrett D'Amore									\
23549ef7e0Garrett D'Amore		DTRACE_PROBE2(mem_writed, unsigned int, (_offset),	\
23649ef7e0Garrett D'Amore		    uint32_t, (_edp)->ed_u32[0]);			\
23749ef7e0Garrett D'Amore									\
23849ef7e0Garrett D'Amore		addr = (void *)((_esmp)->esm_base + (_offset));		\
23949ef7e0Garrett D'Amore									\
24049ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr,		\
24149ef7e0Garrett D'Amore		    (_edp)->ed_u32[0]);					\
24249ef7e0Garrett D'Amore									\
24349ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
24449ef7e0Garrett D'Amore	} while (B_FALSE)
24549ef7e0Garrett D'Amore
24649ef7e0Garrett D'Amore#define	EFSYS_MEM_WRITEQ(_esmp, _offset, _eqp)				\
24749ef7e0Garrett D'Amore	do {								\
24849ef7e0Garrett D'Amore		uint32_t *addr;						\
24949ef7e0Garrett D'Amore									\
25049ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
25149ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)));	\
25249ef7e0Garrett D'Amore									\
25349ef7e0Garrett D'Amore		DTRACE_PROBE3(mem_writeq, unsigned int, (_offset),	\
25449ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[1],			\
25549ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[0]);			\
25649ef7e0Garrett D'Amore									\
25749ef7e0Garrett D'Amore		addr = (void *)((_esmp)->esm_base + (_offset));		\
25849ef7e0Garrett D'Amore									\
25949ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr++,		\
26049ef7e0Garrett D'Amore		    (_eqp)->eq_u32[0]);					\
26149ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr,		\
26249ef7e0Garrett D'Amore		    (_eqp)->eq_u32[1]);					\
26349ef7e0Garrett D'Amore									\
26449ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
26549ef7e0Garrett D'Amore	} while (B_FALSE)
26649ef7e0Garrett D'Amore
26749ef7e0Garrett D'Amore#define	EFSYS_MEM_WRITEO(_esmp, _offset, _eop)				\
26849ef7e0Garrett D'Amore	do {								\
26949ef7e0Garrett D'Amore		uint32_t *addr;						\
27049ef7e0Garrett D'Amore									\
27149ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
27249ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_oword_t)));	\
27349ef7e0Garrett D'Amore									\
27449ef7e0Garrett D'Amore		DTRACE_PROBE5(mem_writeo, unsigned int, (_offset),	\
27549ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[3],			\
27649ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[2],			\
27749ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[1],			\
27849ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[0]);			\
27949ef7e0Garrett D'Amore									\
28049ef7e0Garrett D'Amore		addr = (void *)((_esmp)->esm_base + (_offset));		\
28149ef7e0Garrett D'Amore									\
28249ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr++,		\
28349ef7e0Garrett D'Amore		    (_eop)->eo_u32[0]);					\
28449ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr++,		\
28549ef7e0Garrett D'Amore		    (_eop)->eo_u32[1]);					\
28649ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr++,		\
28749ef7e0Garrett D'Amore		    (_eop)->eo_u32[2]);					\
28849ef7e0Garrett D'Amore		ddi_put32((_esmp)->esm_acc_handle, addr,		\
28949ef7e0Garrett D'Amore		    (_eop)->eo_u32[3]);					\
29049ef7e0Garrett D'Amore									\
29149ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
29249ef7e0Garrett D'Amore	} while (B_FALSE)
29349ef7e0Garrett D'Amore
29449ef7e0Garrett D'Amore#define	EFSYS_MEM_ADDR(_esmp)						\
29549ef7e0Garrett D'Amore	((_esmp)->esm_addr)
29649ef7e0Garrett D'Amore
29749ef7e0Garrett D'Amore#define	EFSYS_MEM_IS_NULL(_esmp)					\
29849ef7e0Garrett D'Amore	((_esmp)->esm_base == NULL)
29949ef7e0Garrett D'Amore
30049ef7e0Garrett D'Amore/* BAR */
30149ef7e0Garrett D'Amore
30249ef7e0Garrett D'Amoretypedef struct efsys_bar_s {
30349ef7e0Garrett D'Amore	kmutex_t		esb_lock;
30449ef7e0Garrett D'Amore	ddi_acc_handle_t	esb_handle;
30549ef7e0Garrett D'Amore	caddr_t			esb_base;
30649ef7e0Garrett D'Amore} efsys_bar_t;
30749ef7e0Garrett D'Amore
30849ef7e0Garrett D'Amore#define	EFSYS_BAR_READD(_esbp, _offset, _edp, _lock)			\
30949ef7e0Garrett D'Amore	do {								\
31049ef7e0Garrett D'Amore		uint32_t *addr;						\
31149ef7e0Garrett D'Amore									\
31249ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
31349ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_dword_t)));	\
31449ef7e0Garrett D'Amore									\
31549ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
31649ef7e0Garrett D'Amore		if (_lock)						\
31749ef7e0Garrett D'Amore			mutex_enter(&((_esbp)->esb_lock));		\
31849ef7e0Garrett D'Amore									\
31949ef7e0Garrett D'Amore		addr = (void *)((_esbp)->esb_base + (_offset));		\
32049ef7e0Garrett D'Amore									\
32149ef7e0Garrett D'Amore		(_edp)->ed_u32[0] = ddi_get32((_esbp)->esb_handle,	\
32249ef7e0Garrett D'Amore		    addr);						\
32349ef7e0Garrett D'Amore									\
32449ef7e0Garrett D'Amore		DTRACE_PROBE2(bar_readd, unsigned int, (_offset),	\
32549ef7e0Garrett D'Amore		    uint32_t, (_edp)->ed_u32[0]);			\
32649ef7e0Garrett D'Amore									\
32749ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
32849ef7e0Garrett D'Amore		if (_lock)						\
32949ef7e0Garrett D'Amore			mutex_exit(&((_esbp)->esb_lock));		\
33049ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
33149ef7e0Garrett D'Amore	} while (B_FALSE)
33249ef7e0Garrett D'Amore
33349ef7e0Garrett D'Amore#define	EFSYS_BAR_READQ(_esbp, _offset, _eqp)				\
33449ef7e0Garrett D'Amore	do {								\
33549ef7e0Garrett D'Amore		uint32_t *addr;						\
33649ef7e0Garrett D'Amore									\
33749ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
33849ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)));	\
33949ef7e0Garrett D'Amore									\
34049ef7e0Garrett D'Amore		mutex_enter(&((_esbp)->esb_lock));			\
34149ef7e0Garrett D'Amore									\
34249ef7e0Garrett D'Amore		addr = (void *)((_esbp)->esb_base + (_offset));		\
34349ef7e0Garrett D'Amore									\
34449ef7e0Garrett D'Amore		(_eqp)->eq_u32[0] = ddi_get32((_esbp)->esb_handle,	\
34549ef7e0Garrett D'Amore		    addr++);						\
34649ef7e0Garrett D'Amore		(_eqp)->eq_u32[1] = ddi_get32((_esbp)->esb_handle,	\
34749ef7e0Garrett D'Amore		    addr);						\
34849ef7e0Garrett D'Amore									\
34949ef7e0Garrett D'Amore		DTRACE_PROBE3(bar_readq, unsigned int, (_offset),	\
35049ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[1],			\
35149ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[0]);			\
35249ef7e0Garrett D'Amore									\
35349ef7e0Garrett D'Amore		mutex_exit(&((_esbp)->esb_lock));			\
35449ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
35549ef7e0Garrett D'Amore	} while (B_FALSE)
35649ef7e0Garrett D'Amore
35749ef7e0Garrett D'Amore#define	EFSYS_BAR_READO(_esbp, _offset, _eop, _lock)			\
35849ef7e0Garrett D'Amore	do {								\
35949ef7e0Garrett D'Amore		uint32_t *addr;						\
36049ef7e0Garrett D'Amore									\
36149ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
36249ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_oword_t)));	\
36349ef7e0Garrett D'Amore									\
36449ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
36549ef7e0Garrett D'Amore		if (_lock)						\
36649ef7e0Garrett D'Amore			mutex_enter(&((_esbp)->esb_lock));		\
36749ef7e0Garrett D'Amore									\
36849ef7e0Garrett D'Amore		addr = (void *)((_esbp)->esb_base + (_offset));		\
36949ef7e0Garrett D'Amore									\
37049ef7e0Garrett D'Amore		(_eop)->eo_u32[0] = ddi_get32((_esbp)->esb_handle,	\
37149ef7e0Garrett D'Amore		    addr++);						\
37249ef7e0Garrett D'Amore		(_eop)->eo_u32[1] = ddi_get32((_esbp)->esb_handle,	\
37349ef7e0Garrett D'Amore		    addr++);						\
37449ef7e0Garrett D'Amore		(_eop)->eo_u32[2] = ddi_get32((_esbp)->esb_handle,	\
37549ef7e0Garrett D'Amore		    addr++);						\
37649ef7e0Garrett D'Amore		(_eop)->eo_u32[3] = ddi_get32((_esbp)->esb_handle,	\
37749ef7e0Garrett D'Amore		    addr);						\
37849ef7e0Garrett D'Amore									\
37949ef7e0Garrett D'Amore		DTRACE_PROBE5(bar_reado, unsigned int, (_offset),	\
38049ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[3],			\
38149ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[2],			\
38249ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[1],			\
38349ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[0]);			\
38449ef7e0Garrett D'Amore									\
38549ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
38649ef7e0Garrett D'Amore		if (_lock)						\
38749ef7e0Garrett D'Amore			mutex_exit(&((_esbp)->esb_lock));		\
38849ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
38949ef7e0Garrett D'Amore	} while (B_FALSE)
39049ef7e0Garrett D'Amore
39149ef7e0Garrett D'Amore#define	EFSYS_BAR_WRITED(_esbp, _offset, _edp, _lock)			\
39249ef7e0Garrett D'Amore	do {								\
39349ef7e0Garrett D'Amore		uint32_t *addr;						\
39449ef7e0Garrett D'Amore									\
39549ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
39649ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_dword_t)));	\
39749ef7e0Garrett D'Amore									\
39849ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
39949ef7e0Garrett D'Amore		if (_lock)						\
40049ef7e0Garrett D'Amore			mutex_enter(&((_esbp)->esb_lock));		\
40149ef7e0Garrett D'Amore									\
40249ef7e0Garrett D'Amore		DTRACE_PROBE2(bar_writed, unsigned int, (_offset),	\
40349ef7e0Garrett D'Amore		    uint32_t, (_edp)->ed_u32[0]);			\
40449ef7e0Garrett D'Amore									\
40549ef7e0Garrett D'Amore		addr = (void *)((_esbp)->esb_base + (_offset));		\
40649ef7e0Garrett D'Amore									\
40749ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr,			\
40849ef7e0Garrett D'Amore		    (_edp)->ed_u32[0]);					\
40949ef7e0Garrett D'Amore									\
41049ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
41149ef7e0Garrett D'Amore		if (_lock)						\
41249ef7e0Garrett D'Amore			mutex_exit(&((_esbp)->esb_lock));		\
41349ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
41449ef7e0Garrett D'Amore	} while (B_FALSE)
41549ef7e0Garrett D'Amore
41649ef7e0Garrett D'Amore#define	EFSYS_BAR_WRITEQ(_esbp, _offset, _eqp)				\
41749ef7e0Garrett D'Amore	do {								\
41849ef7e0Garrett D'Amore		uint32_t *addr;						\
41949ef7e0Garrett D'Amore									\
42049ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
42149ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)));	\
42249ef7e0Garrett D'Amore									\
42349ef7e0Garrett D'Amore		mutex_enter(&((_esbp)->esb_lock));			\
42449ef7e0Garrett D'Amore									\
42549ef7e0Garrett D'Amore		DTRACE_PROBE3(bar_writeq, unsigned int, (_offset),	\
42649ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[1],			\
42749ef7e0Garrett D'Amore		    uint32_t, (_eqp)->eq_u32[0]);			\
42849ef7e0Garrett D'Amore									\
42949ef7e0Garrett D'Amore		addr = (void *)((_esbp)->esb_base + (_offset));		\
43049ef7e0Garrett D'Amore									\
43149ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr++,			\
43249ef7e0Garrett D'Amore		    (_eqp)->eq_u32[0]);					\
43349ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr,			\
43449ef7e0Garrett D'Amore		    (_eqp)->eq_u32[1]);					\
43549ef7e0Garrett D'Amore									\
43649ef7e0Garrett D'Amore		mutex_exit(&((_esbp)->esb_lock));			\
43749ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
43849ef7e0Garrett D'Amore	} while (B_FALSE)
43949ef7e0Garrett D'Amore
44049ef7e0Garrett D'Amore/*
44149ef7e0Garrett D'Amore * Guarantees 64bit aligned 64bit writes to write combined BAR mapping
44249ef7e0Garrett D'Amore * (required by PIO hardware)
44349ef7e0Garrett D'Amore */
44449ef7e0Garrett D'Amore#define	EFSYS_BAR_WC_WRITEQ(_esbp, _offset, _eqp)			\
44549ef7e0Garrett D'Amore	do {								\
44649ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
44749ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_qword_t)));	\
44849ef7e0Garrett D'Amore									\
44949ef7e0Garrett D'Amore		(void) (_esbp);						\
45049ef7e0Garrett D'Amore									\
45149ef7e0Garrett D'Amore		/* FIXME: Perform a 64-bit write */			\
45249ef7e0Garrett D'Amore		EFSYS_ASSERT(0);					\
45349ef7e0Garrett D'Amore									\
45449ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
45549ef7e0Garrett D'Amore	} while (B_FALSE)
45649ef7e0Garrett D'Amore
45749ef7e0Garrett D'Amore#define	EFSYS_BAR_WRITEO(_esbp, _offset, _eop, _lock)			\
45849ef7e0Garrett D'Amore	do {								\
45949ef7e0Garrett D'Amore		uint32_t *addr;						\
46049ef7e0Garrett D'Amore									\
46149ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
46249ef7e0Garrett D'Amore		ASSERT(IS_P2ALIGNED(_offset, sizeof (efx_oword_t)));	\
46349ef7e0Garrett D'Amore									\
46449ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
46549ef7e0Garrett D'Amore		if (_lock)						\
46649ef7e0Garrett D'Amore			mutex_enter(&((_esbp)->esb_lock));		\
46749ef7e0Garrett D'Amore									\
46849ef7e0Garrett D'Amore		DTRACE_PROBE5(bar_writeo, unsigned int, (_offset),	\
46949ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[3],			\
47049ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[2],			\
47149ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[1],			\
47249ef7e0Garrett D'Amore		    uint32_t, (_eop)->eo_u32[0]);			\
47349ef7e0Garrett D'Amore									\
47449ef7e0Garrett D'Amore		addr = (void *)((_esbp)->esb_base + (_offset));		\
47549ef7e0Garrett D'Amore									\
47649ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr++,			\
47749ef7e0Garrett D'Amore		    (_eop)->eo_u32[0]);					\
47849ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr++,			\
47949ef7e0Garrett D'Amore		    (_eop)->eo_u32[1]);					\
48049ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr++,			\
48149ef7e0Garrett D'Amore		    (_eop)->eo_u32[2]);					\
48249ef7e0Garrett D'Amore		ddi_put32((_esbp)->esb_handle, addr,			\
48349ef7e0Garrett D'Amore		    (_eop)->eo_u32[3]);					\
48449ef7e0Garrett D'Amore									\
48549ef7e0Garrett D'Amore		_NOTE(CONSTANTCONDITION)				\
48649ef7e0Garrett D'Amore		if (_lock)						\
48749ef7e0Garrett D'Amore			mutex_exit(&((_esbp)->esb_lock));		\
48849ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
48949ef7e0Garrett D'Amore	} while (B_FALSE)
49049ef7e0Garrett D'Amore
49149ef7e0Garrett D'Amore/* Use the standard octo-word write for doorbell writes */
49249ef7e0Garrett D'Amore#define	EFSYS_BAR_DOORBELL_WRITEO(_esbp, _offset, _eop)			\
49349ef7e0Garrett D'Amore	do {								\
49449ef7e0Garrett D'Amore		EFSYS_BAR_WRITEO((_esbp), (_offset), (_eop), B_FALSE);	\
49549ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
49649ef7e0Garrett D'Amore	} while (B_FALSE)
49749ef7e0Garrett D'Amore
49849ef7e0Garrett D'Amore/* SPIN */
49949ef7e0Garrett D'Amore
50049ef7e0Garrett D'Amore#define	EFSYS_SPIN(_us)							\
50149ef7e0Garrett D'Amore	drv_usecwait(_us)
50249ef7e0Garrett D'Amore
50349ef7e0Garrett D'Amore/* TODO: Perhaps this should use delay(9F)? */
50449ef7e0Garrett D'Amore#define	EFSYS_SLEEP	EFSYS_SPIN
50549ef7e0Garrett D'Amore
50649ef7e0Garrett D'Amore/* BARRIERS */
50749ef7e0Garrett D'Amore
50849ef7e0Garrett D'Amore/* Strict ordering guaranteed by devacc.devacc_attr_dataorder */
50949ef7e0Garrett D'Amore#define	EFSYS_MEM_READ_BARRIER()	membar_consumer()
51049ef7e0Garrett D'Amore/* TODO: Is ddi_put32() properly barriered? */
51149ef7e0Garrett D'Amore#define	EFSYS_PIO_WRITE_BARRIER()
51249ef7e0Garrett D'Amore
51349ef7e0Garrett D'Amore/* DMA SYNC */
51449ef7e0Garrett D'Amore/*
51549ef7e0Garrett D'Amore * It could be cheaper to sync entire map than calculate offset and
51649ef7e0Garrett D'Amore * size. If so, below macros should be updated to ignore these arguments
51749ef7e0Garrett D'Amore * and sync entire map.
51849ef7e0Garrett D'Amore */
51949ef7e0Garrett D'Amore#define	EFSYS_DMA_SYNC_FOR_KERNEL(_esmp, _offset, _size)		\
52049ef7e0Garrett D'Amore	(void) ddi_dma_sync((_esmp)->esm_dma_handle,			\
52149ef7e0Garrett D'Amore	    (_offset), (_size), DDI_DMA_SYNC_FORKERNEL)
52249ef7e0Garrett D'Amore
52349ef7e0Garrett D'Amore#define	EFSYS_DMA_SYNC_FOR_DEVICE(_esmp, _offset, _size)		\
52449ef7e0Garrett D'Amore	(void) ddi_dma_sync((_esmp)->esm_dma_handle,			\
52549ef7e0Garrett D'Amore	    (_offset), (_size), DDI_DMA_SYNC_FORDEV)
52649ef7e0Garrett D'Amore
52749ef7e0Garrett D'Amore/* TIMESTAMP */
52849ef7e0Garrett D'Amore
52949ef7e0Garrett D'Amoretypedef	clock_t	efsys_timestamp_t;
53049ef7e0Garrett D'Amore
53149ef7e0Garrett D'Amore/* TODO: Arguably this could use gethrtime */
53249ef7e0Garrett D'Amore#define	EFSYS_TIMESTAMP(_usp)						\
53349ef7e0Garrett D'Amore	do {								\
53449ef7e0Garrett D'Amore		*(_usp) = drv_hztousec(ddi_get_lbolt());		\
53549ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
53649ef7e0Garrett D'Amore	} while (B_FALSE)
53749ef7e0Garrett D'Amore
53849ef7e0Garrett D'Amore/* KMEM */
53949ef7e0Garrett D'Amore
54049ef7e0Garrett D'Amore#define	EFSYS_KMEM_ALLOC(_esip, _size, _p)				\
54149ef7e0Garrett D'Amore	do {								\
54249ef7e0Garrett D'Amore		(_esip) = (_esip);					\
54349ef7e0Garrett D'Amore		(_p) = kmem_zalloc((_size), KM_NOSLEEP);		\
54449ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
54549ef7e0Garrett D'Amore	} while (B_FALSE)
54649ef7e0Garrett D'Amore
54749ef7e0Garrett D'Amore#define	EFSYS_KMEM_FREE(_esip, _size, _p)				\
54849ef7e0Garrett D'Amore	do {								\
54949ef7e0Garrett D'Amore		(_esip) = (_esip);					\
55049ef7e0Garrett D'Amore		kmem_free((_p), (_size));				\
55149ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
55249ef7e0Garrett D'Amore	} while (B_FALSE)
55349ef7e0Garrett D'Amore
55449ef7e0Garrett D'Amore/* LOCK */
55549ef7e0Garrett D'Amore
55649ef7e0Garrett D'Amoretypedef kmutex_t	efsys_lock_t;
55749ef7e0Garrett D'Amore
55849ef7e0Garrett D'Amore#define	EFSYS_LOCK_MAGIC	0x000010c4
55949ef7e0Garrett D'Amore
56049ef7e0Garrett D'Amore#define	EFSYS_LOCK(_lockp, _state)					\
56149ef7e0Garrett D'Amore	do {								\
56249ef7e0Garrett D'Amore		mutex_enter(_lockp);					\
56349ef7e0Garrett D'Amore		(_state) = EFSYS_LOCK_MAGIC;				\
56449ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
56549ef7e0Garrett D'Amore	} while (B_FALSE)
56649ef7e0Garrett D'Amore
56749ef7e0Garrett D'Amore#define	EFSYS_UNLOCK(_lockp, _state)					\
56849ef7e0Garrett D'Amore	do {								\
56949ef7e0Garrett D'Amore		if ((_state) != EFSYS_LOCK_MAGIC)			\
57049ef7e0Garrett D'Amore			ASSERT(B_FALSE);				\
57149ef7e0Garrett D'Amore		mutex_exit(_lockp);					\
57249ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
57349ef7e0Garrett D'Amore	} while (B_FALSE)
57449ef7e0Garrett D'Amore
57549ef7e0Garrett D'Amore/* STAT */
57649ef7e0Garrett D'Amore
57749ef7e0Garrett D'Amoretypedef kstat_named_t		efsys_stat_t;
57849ef7e0Garrett D'Amore
57949ef7e0Garrett D'Amore#define	EFSYS_STAT_INCR(_knp, _delta) 					\
58049ef7e0Garrett D'Amore	do {								\
58149ef7e0Garrett D'Amore		((_knp)->value.ui64) += (_delta);			\
58249ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
58349ef7e0Garrett D'Amore	} while (B_FALSE)
58449ef7e0Garrett D'Amore
58549ef7e0Garrett D'Amore#define	EFSYS_STAT_DECR(_knp, _delta) 					\
58649ef7e0Garrett D'Amore	do {								\
58749ef7e0Garrett D'Amore		((_knp)->value.ui64) -= (_delta);			\
58849ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
58949ef7e0Garrett D'Amore	} while (B_FALSE)
59049ef7e0Garrett D'Amore
59149ef7e0Garrett D'Amore#define	EFSYS_STAT_SET(_knp, _val)					\
59249ef7e0Garrett D'Amore	do {								\
59349ef7e0Garrett D'Amore		((_knp)->value.ui64) = (_val);				\
59449ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
59549ef7e0Garrett D'Amore	} while (B_FALSE)
59649ef7e0Garrett D'Amore
59749ef7e0Garrett D'Amore#define	EFSYS_STAT_SET_QWORD(_knp, _valp)				\
59849ef7e0Garrett D'Amore	do {								\
59949ef7e0Garrett D'Amore		((_knp)->value.ui64) = LE_64((_valp)->eq_u64[0]);	\
60049ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
60149ef7e0Garrett D'Amore	} while (B_FALSE)
60249ef7e0Garrett D'Amore
60349ef7e0Garrett D'Amore#define	EFSYS_STAT_SET_DWORD(_knp, _valp)				\
60449ef7e0Garrett D'Amore	do {								\
60549ef7e0Garrett D'Amore		((_knp)->value.ui64) = LE_32((_valp)->ed_u32[0]);	\
60649ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
60749ef7e0Garrett D'Amore	} while (B_FALSE)
60849ef7e0Garrett D'Amore
60949ef7e0Garrett D'Amore#define	EFSYS_STAT_INCR_QWORD(_knp, _valp)				\
61049ef7e0Garrett D'Amore	do {								\
61149ef7e0Garrett D'Amore		((_knp)->value.ui64) += LE_64((_valp)->eq_u64[0]);	\
61249ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
61349ef7e0Garrett D'Amore	} while (B_FALSE)
61449ef7e0Garrett D'Amore
61549ef7e0Garrett D'Amore#define	EFSYS_STAT_SUBR_QWORD(_knp, _valp)				\
61649ef7e0Garrett D'Amore	do {								\
61749ef7e0Garrett D'Amore		((_knp)->value.ui64) -= LE_64((_valp)->eq_u64[0]);	\
61849ef7e0Garrett D'Amore	_NOTE(CONSTANTCONDITION)					\
61949ef7e0Garrett D'Amore	} while (B_FALSE)
62049ef7e0Garrett D'Amore
62149ef7e0Garrett D'Amore/* ERR */
62249ef7e0Garrett D'Amore
62349ef7e0Garrett D'Amoreextern void	sfxge_err(efsys_identifier_t *, unsigned int,
62449ef7e0Garrett D'Amore		    uint32_t, uint32_t);
62549ef7e0Garrett D'Amore
62649ef7e0Garrett D'Amore#if EFSYS_OPT_DECODE_INTR_FATAL
62749ef7e0Garrett D'Amore#define	EFSYS_ERR(_esip, _code, _dword0, _dword1)			\
62849ef7e0Garrett D'Amore	sfxge_err((_esip), (_code), (_dword0), (_dword1))
62949ef7e0Garrett D'Amore#endif
63049ef7e0Garrett D'Amore
63149ef7e0Garrett D'Amore/* PROBE */
63249ef7e0Garrett D'Amore
63349ef7e0Garrett D'Amore#define	EFSYS_PROBE(_name)						\
63449ef7e0Garrett D'Amore	DTRACE_PROBE(_name)
63549ef7e0Garrett D'Amore
63649ef7e0Garrett D'Amore#define	EFSYS_PROBE1(_name, _type1, _arg1)				\
63749ef7e0Garrett D'Amore	DTRACE_PROBE1(_name, _type1, _arg1)
63849ef7e0Garrett D'Amore
63949ef7e0Garrett D'Amore#define	EFSYS_PROBE2(_name, _type1, _arg1, _type2, _arg2)		\
64049ef7e0Garrett D'Amore	DTRACE_PROBE2(_name, _type1, _arg1, _type2, _arg2)
64149ef7e0Garrett D'Amore
64249ef7e0Garrett D'Amore#define	EFSYS_PROBE3(_name, _type1, _arg1, _type2, _arg2,		\
64349ef7e0Garrett D'Amore	    _type3, _arg3)						\
64449ef7e0Garrett D'Amore	DTRACE_PROBE3(_name, _type1, _arg1, _type2, _arg2,		\
64549ef7e0Garrett D'Amore	    _type3, _arg3)
64649ef7e0Garrett D'Amore
64749ef7e0Garrett D'Amore#define	EFSYS_PROBE4(_name, _type1, _arg1, _type2, _arg2,		\
64849ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4)				\
64949ef7e0Garrett D'Amore	DTRACE_PROBE4(_name, _type1, _arg1, _type2, _arg2,		\
65049ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4)
65149ef7e0Garrett D'Amore
65249ef7e0Garrett D'Amore#define	EFSYS_PROBE5(_name, _type1, _arg1, _type2, _arg2,		\
65349ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4, _type5, _arg5)		\
65449ef7e0Garrett D'Amore	DTRACE_PROBE5(_name, _type1, _arg1, _type2, _arg2,		\
65549ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4, _type5, _arg5)
65649ef7e0Garrett D'Amore
65749ef7e0Garrett D'Amore#define	EFSYS_PROBE6(_name, _type1, _arg1, _type2, _arg2,		\
65849ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4, _type5, _arg5,		\
65949ef7e0Garrett D'Amore	    _type6, _arg6)						\
66049ef7e0Garrett D'Amore	DTRACE_PROBE6(_name, _type1, _arg1, _type2, _arg2,		\
66149ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4, _type5, _arg5,		\
66249ef7e0Garrett D'Amore	    _type6, _arg6)
66349ef7e0Garrett D'Amore
66449ef7e0Garrett D'Amore#define	EFSYS_PROBE7(_name, _type1, _arg1, _type2, _arg2,		\
66549ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4, _type5, _arg5,		\
66649ef7e0Garrett D'Amore	    _type6, _arg6, _type7, _arg7)				\
66749ef7e0Garrett D'Amore	DTRACE_PROBE7(_name, _type1, _arg1, _type2, _arg2,		\
66849ef7e0Garrett D'Amore	    _type3, _arg3, _type4, _arg4, _type5, _arg5,		\
66949ef7e0Garrett D'Amore	    _type6, _arg6, _type7, _arg7)
67049ef7e0Garrett D'Amore
67149ef7e0Garrett D'Amore/* ASSERT */
67249ef7e0Garrett D'Amore
67349ef7e0Garrett D'Amore#define	EFSYS_ASSERT(_exp)		ASSERT(_exp)
67449ef7e0Garrett D'Amore#define	EFSYS_ASSERT3U(_x, _op, _y)	ASSERT3U(_x, _op, _y)
67549ef7e0Garrett D'Amore#define	EFSYS_ASSERT3S(_x, _op, _y)	ASSERT3S(_x, _op, _y)
67649ef7e0Garrett D'Amore#define	EFSYS_ASSERT3P(_x, _op, _y)	ASSERT3P(_x, _op, _y)
67749ef7e0Garrett D'Amore
67849ef7e0Garrett D'Amore/* ROTATE */
67949ef7e0Garrett D'Amore
68049ef7e0Garrett D'Amore#define	EFSYS_HAS_ROTL_DWORD 0
68149ef7e0Garrett D'Amore
68249ef7e0Garrett D'Amore#ifdef	__cplusplus
68349ef7e0Garrett D'Amore}
68449ef7e0Garrett D'Amore#endif
68549ef7e0Garrett D'Amore
68649ef7e0Garrett D'Amore#endif	/* _SYS_EFSYS_H */
687