1139749Simp/*******************************************************************************
2129794Stackerman
3129794StackermanCopyright (c) 2001-2004, Intel Corporation
4129794StackermanAll rights reserved.
5129794Stackerman
6129794StackermanRedistribution and use in source and binary forms, with or without
7129794Stackermanmodification, are permitted provided that the following conditions are met:
8129794Stackerman
9129794Stackerman 1. Redistributions of source code must retain the above copyright notice,
10129794Stackerman    this list of conditions and the following disclaimer.
11129794Stackerman
12129794Stackerman 2. Redistributions in binary form must reproduce the above copyright
13129794Stackerman    notice, this list of conditions and the following disclaimer in the
14129794Stackerman    documentation and/or other materials provided with the distribution.
15129794Stackerman
16129794Stackerman 3. Neither the name of the Intel Corporation nor the names of its
17129794Stackerman    contributors may be used to endorse or promote products derived from
18129794Stackerman    this software without specific prior written permission.
19129794Stackerman
20129794StackermanTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21129794StackermanAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22129794StackermanIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23129794StackermanARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24129794StackermanLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25129794StackermanCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26129794StackermanSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27129794StackermanINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28129794StackermanCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29129794StackermanARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30129794StackermanPOSSIBILITY OF SUCH DAMAGE.
31129794Stackerman
32129794Stackerman***************************************************************************/
33129794Stackerman
34129794Stackerman/*$FreeBSD$*/
35129794Stackerman
36129794Stackerman#ifndef _FREEBSD_OS_H_
37129794Stackerman#define _FREEBSD_OS_H_
38129794Stackerman
39129794Stackerman#include <sys/types.h>
40129794Stackerman#include <sys/param.h>
41129794Stackerman#include <sys/systm.h>
42129794Stackerman#include <sys/mbuf.h>
43129794Stackerman#include <sys/protosw.h>
44129794Stackerman#include <sys/socket.h>
45129794Stackerman#include <sys/malloc.h>
46129794Stackerman#include <sys/kernel.h>
47129794Stackerman#include <sys/bus.h>
48129794Stackerman#include <machine/bus.h>
49129794Stackerman#include <sys/rman.h>
50129794Stackerman#include <machine/resource.h>
51129794Stackerman#if __FreeBSD_version >= 502000
52129794Stackerman        #include <dev/pci/pcivar.h>
53129794Stackerman        #include <dev/pci/pcireg.h>
54129794Stackerman#else
55129794Stackerman        #include <pci/pcivar.h>
56129794Stackerman        #include <pci/pcireg.h>
57129794Stackerman#endif
58129794Stackerman
59129794Stackerman#define ASSERT(x) if(!(x)) panic("IXGB: x")
60129794Stackerman
61129794Stackerman/* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */
62129794Stackerman#define usec_delay(x) DELAY(x)
63129794Stackerman#define msec_delay(x) DELAY(1000*(x))
64129794Stackerman
65129794Stackerman#define DBG 0
66129794Stackerman#define MSGOUT(S, A, B)     printf(S "\n", A, B)
67129794Stackerman#define DEBUGFUNC(F)        DEBUGOUT(F);
68129794Stackerman#if DBG
69129794Stackerman	#define DEBUGOUT(S)         printf(S "\n")
70129794Stackerman	#define DEBUGOUT1(S,A)      printf(S "\n",A)
71129794Stackerman	#define DEBUGOUT2(S,A,B)    printf(S "\n",A,B)
72129794Stackerman	#define DEBUGOUT3(S,A,B,C)  printf(S "\n",A,B,C)
73129794Stackerman	#define DEBUGOUT7(S,A,B,C,D,E,F,G)  printf(S "\n",A,B,C,D,E,F,G)
74129794Stackerman#else
75129794Stackerman	#define DEBUGOUT(S)
76129794Stackerman	#define DEBUGOUT1(S,A)
77129794Stackerman	#define DEBUGOUT2(S,A,B)
78129794Stackerman	#define DEBUGOUT3(S,A,B,C)
79129794Stackerman	#define DEBUGOUT7(S,A,B,C,D,E,F,G)
80129794Stackerman#endif
81129794Stackerman
82129794Stackerman#define FALSE               0
83129794Stackerman#define TRUE                1
84129794Stackerman#define CMD_MEM_WRT_INVALIDATE          0x0010  /* BIT_4 */
85129794Stackerman#define PCI_COMMAND_REGISTER            PCIR_COMMAND
86129794Stackerman
87129794Stackerman#define le16_to_cpu
88129794Stackerman
89129794Stackermanstruct ixgb_osdep
90129794Stackerman{
91129794Stackerman	bus_space_tag_t    mem_bus_space_tag;
92129794Stackerman	bus_space_handle_t mem_bus_space_handle;
93129794Stackerman	struct device     *dev;
94129794Stackerman};
95129794Stackerman
96129794Stackerman#define IXGB_WRITE_FLUSH(a) IXGB_READ_REG(a, STATUS)
97129794Stackerman
98129794Stackerman#define IXGB_READ_REG(a, reg) (\
99129794Stackerman   bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
100129794Stackerman                     ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
101129794Stackerman                     IXGB_##reg))
102129794Stackerman
103129794Stackerman#define IXGB_WRITE_REG(a, reg, value) (\
104129794Stackerman   bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
105129794Stackerman                     ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
106129794Stackerman                     IXGB_##reg, value))
107129794Stackerman
108129794Stackerman
109129794Stackerman#define IXGB_READ_REG_ARRAY(a, reg, offset) (\
110129794Stackerman   bus_space_read_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
111129794Stackerman                     ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
112129794Stackerman                     (IXGB_##reg + ((offset) << 2))))
113129794Stackerman
114129794Stackerman#define IXGB_WRITE_REG_ARRAY(a, reg, offset, value) (\
115129794Stackerman      bus_space_write_4( ((struct ixgb_osdep *)(a)->back)->mem_bus_space_tag, \
116129794Stackerman                      ((struct ixgb_osdep *)(a)->back)->mem_bus_space_handle, \
117129794Stackerman                      (IXGB_##reg + ((offset) << 2)), value))
118129794Stackerman
119129794Stackerman#endif  /* _FREEBSD_OS_H_ */
120129794Stackerman
121