1 /**************************************************************************
3 Copyright (c) 2001-2002 Intel Corporation
6 Redistribution and use in source and binary forms of the Software, with or
7 without modification, are permitted provided that the following conditions
10 1. Redistributions of source code of the Software may retain the above
11 copyright notice, this list of conditions and the following disclaimer.
13 2. Redistributions in binary form of the Software may reproduce the above
14 copyright notice, this list of conditions and the following disclaimer
15 in the documentation and/or other materials provided with the
18 3. Neither the name of the Intel Corporation nor the names of its
19 contributors shall be used to endorse or promote products derived from
20 this Software without specific prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 ***************************************************************************/
38 #ifndef _FREEBSD_OS_H_
39 #define _FREEBSD_OS_H_
41 #include <sys/types.h>
42 #include <sys/param.h>
43 #include <sys/systm.h>
45 #include <sys/protosw.h>
46 #include <sys/socket.h>
47 #include <sys/malloc.h>
48 #include <sys/kernel.h>
50 #include <machine/bus.h>
52 #include <machine/resource.h>
55 #include <machine/clock.h>
56 #include <pci/pcivar.h>
57 #include <pci/pcireg.h>
60 #define ASSERT(x) if(!(x)) panic("EM: x")
62 /* The happy-fun DELAY macro is defined in /usr/src/sys/i386/include/clock.h */
63 #define usec_delay(x) DELAY(x)
64 #define msec_delay(x) DELAY(1000*(x))
66 #define MSGOUT(S, A, B) printf(S "\n", A, B)
67 #define DEBUGFUNC(F) DEBUGOUT(F);
69 #define DEBUGOUT(S) printf(S "\n")
70 #define DEBUGOUT1(S,A) printf(S "\n",A)
71 #define DEBUGOUT2(S,A,B) printf(S "\n",A,B)
72 #define DEBUGOUT3(S,A,B,C) printf(S "\n",A,B,C)
73 #define DEBUGOUT7(S,A,B,C,D,E,F,G) printf(S "\n",A,B,C,D,E,F,G)
76 #define DEBUGOUT1(S,A)
77 #define DEBUGOUT2(S,A,B)
78 #define DEBUGOUT3(S,A,B,C)
79 #define DEBUGOUT7(S,A,B,C,D,E,F,G)
84 #define CMD_MEM_WRT_INVALIDATE 0x0010 /* BIT_4 */
85 #define PCI_COMMAND_REGISTER PCIR_COMMAND
89 bus_space_tag_t bus_space_tag;
90 bus_space_handle_t bus_space_handle;
94 #define E1000_READ_REG(a, reg) (\
95 ((a)->mac_type >= em_82543) ? \
96 bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
97 ((struct em_osdep *)(a)->back)->bus_space_handle, \
99 bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
100 ((struct em_osdep *)(a)->back)->bus_space_handle, \
104 #define E1000_WRITE_REG(a, reg, value) (\
105 ((a)->mac_type >= em_82543) ? \
106 bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
107 ((struct em_osdep *)(a)->back)->bus_space_handle, \
108 E1000_##reg, value): \
109 bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
110 ((struct em_osdep *)(a)->back)->bus_space_handle, \
111 E1000_82542_##reg, value))
114 #define E1000_READ_REG_ARRAY(a, reg, offset) (\
115 ((a)->mac_type >= em_82543) ? \
116 bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
117 ((struct em_osdep *)(a)->back)->bus_space_handle, \
118 (E1000_##reg + ((offset) << 2))): \
119 bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
120 ((struct em_osdep *)(a)->back)->bus_space_handle, \
121 (E1000_82542_##reg + ((offset) << 2))))
124 #define E1000_WRITE_REG_ARRAY(a, reg, offset, value) (\
125 ((a)->mac_type >= em_82543) ? \
126 bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
127 ((struct em_osdep *)(a)->back)->bus_space_handle, \
128 (E1000_##reg + ((offset) << 2)), value): \
129 bus_space_write_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
130 ((struct em_osdep *)(a)->back)->bus_space_handle, \
131 (E1000_82542_##reg + ((offset) << 2)), value))
134 #endif /* _FREEBSD_OS_H_ */