]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/em/if_em_osdep.h
This commit was generated by cvs2svn to compensate for changes in r98008,
[FreeBSD/FreeBSD.git] / sys / dev / em / if_em_osdep.h
1 /**************************************************************************
2
3 Copyright (c) 2001-2002 Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms of the Software, with or
7 without modification, are permitted provided that the following conditions
8 are met:
9
10  1. Redistributions of source code of the Software may retain the above
11     copyright notice, this list of conditions and the following disclaimer.
12
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
16     distribution.
17
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.
21
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
32 SUCH DAMAGE.
33
34 ***************************************************************************/
35
36 /*$FreeBSD$*/
37
38 #ifndef _FREEBSD_OS_H_
39 #define _FREEBSD_OS_H_
40
41 #include <sys/types.h>
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/mbuf.h>
45 #include <sys/protosw.h>
46 #include <sys/socket.h>
47 #include <sys/malloc.h>
48 #include <sys/kernel.h>
49 #include <sys/bus.h>
50 #include <machine/bus.h>
51 #include <sys/rman.h>
52 #include <machine/resource.h>
53 #include <vm/vm.h>
54 #include <vm/pmap.h>
55 #include <machine/clock.h>
56 #include <pci/pcivar.h>
57 #include <pci/pcireg.h>
58
59
60 #define ASSERT(x) if(!(x)) panic("EM: x")
61
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))
65
66 #define MSGOUT(S, A, B)     printf(S "\n", A, B)
67 #define DEBUGFUNC(F)        DEBUGOUT(F);
68 #if DBG
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)
74 #else
75         #define DEBUGOUT(S)
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)
80 #endif
81
82 #define FALSE               0
83 #define TRUE                1
84 #define CMD_MEM_WRT_INVALIDATE          0x0010  /* BIT_4 */
85 #define PCI_COMMAND_REGISTER            PCIR_COMMAND
86
87 struct em_osdep
88 {
89         bus_space_tag_t bus_space_tag;
90         bus_space_handle_t bus_space_handle;
91         struct device   *dev;
92 };
93
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, \
98                      E1000_##reg): \
99    bus_space_read_4( ((struct em_osdep *)(a)->back)->bus_space_tag, \
100                       ((struct em_osdep *)(a)->back)->bus_space_handle, \
101                        E1000_82542_##reg))
102
103
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))
112
113
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))))
122
123
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))
132
133
134 #endif  /* _FREEBSD_OS_H_ */
135