1/**************************************************************************
2
3Copyright (c) 2001-2005, Intel Corporation
4All rights reserved.
5
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10    this list of conditions and the following disclaimer.
11
12 2. Redistributions in binary form must reproduce the above copyright
13    notice, this list of conditions and the following disclaimer in the
14    documentation and/or other materials provided with the distribution.
15
16 3. Neither the name of the Intel Corporation nor the names of its
17    contributors may be used to endorse or promote products derived from
18    this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30POSSIBILITY OF SUCH DAMAGE.
31
32***************************************************************************/
33
34/* $OpenBSD: if_ixgb_osdep.h,v 1.4 2011/07/26 14:57:57 deraadt Exp $ */
35
36#ifndef _IXGB_OPENBSD_OS_H_
37#define _IXGB_OPENBSD_OS_H_
38
39#define ASSERT(x)	if(!(x)) panic("IXGB: x")
40
41#define usec_delay(x)	DELAY(x)
42#define msec_delay(x)	DELAY(1000*(x))
43
44#define DBG 0
45#define MSGOUT(S, A, B)	printf(S "\n", A, B)
46#define DEBUGFUNC(F)	DEBUGOUT(F);
47#if DBG
48	#define DEBUGOUT(S)			printf(S "\n")
49	#define DEBUGOUT1(S,A)			printf(S "\n",A)
50	#define DEBUGOUT2(S,A,B)		printf(S "\n",A,B)
51	#define DEBUGOUT3(S,A,B,C)		printf(S "\n",A,B,C)
52	#define DEBUGOUT7(S,A,B,C,D,E,F,G)	printf(S "\n",A,B,C,D,E,F,G)
53#else
54	#define DEBUGOUT(S)
55	#define DEBUGOUT1(S,A)
56	#define DEBUGOUT2(S,A,B)
57	#define DEBUGOUT3(S,A,B,C)
58	#define DEBUGOUT7(S,A,B,C,D,E,F,G)
59#endif
60
61#define CMD_MEM_WRT_INVALIDATE		0x0010	/* BIT_4 */
62
63#define le16_to_cpu		letoh16
64
65struct ixgb_osdep
66{
67	bus_space_tag_t		mem_bus_space_tag;
68	bus_space_handle_t	mem_bus_space_handle;
69	struct device		*dev;
70
71	struct pci_attach_args	ixgb_pa;
72
73	bus_size_t		ixgb_memsize;
74	bus_addr_t		ixgb_membase;
75};
76
77#define IXGB_WRITE_FLUSH(a)	IXGB_READ_REG(a, STATUS)
78
79#define IXGB_READ_REG(a, reg)						\
80   bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
81                     ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
82                     IXGB_##reg)
83
84#define IXGB_WRITE_REG(a, reg, value)					\
85   bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
86                     ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
87                     IXGB_##reg, value)
88
89#define IXGB_READ_REG_ARRAY(a, reg, offset)				\
90   bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
91                     ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
92                     (IXGB_##reg + ((offset) << 2)))
93
94#define IXGB_WRITE_REG_ARRAY(a, reg, offset, value)			\
95      bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
96                      ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
97                      (IXGB_##reg + ((offset) << 2)), value)
98
99#ifdef DEBUG
100#define IXGB_KASSERT(exp,msg)	do { if (!(exp)) panic msg; } while (0)
101#else
102#define IXGB_KASSERT(exp,msg)
103#endif
104
105#endif  /* _IXGB_OPENBSD_OS_H_ */
106