1 | /*
|
---|
2 | * Copyright 1998 by Concurrent Computer Corporation
|
---|
3 | *
|
---|
4 | * Permission to use, copy, modify, distribute, and sell this software
|
---|
5 | * and its documentation for any purpose is hereby granted without fee,
|
---|
6 | * provided that the above copyright notice appear in all copies and that
|
---|
7 | * both that copyright notice and this permission notice appear in
|
---|
8 | * supporting documentation, and that the name of Concurrent Computer
|
---|
9 | * Corporation not be used in advertising or publicity pertaining to
|
---|
10 | * distribution of the software without specific, written prior
|
---|
11 | * permission. Concurrent Computer Corporation makes no representations
|
---|
12 | * about the suitability of this software for any purpose. It is
|
---|
13 | * provided "as is" without express or implied warranty.
|
---|
14 | *
|
---|
15 | * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
|
---|
16 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
17 | * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
|
---|
18 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
19 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
20 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
21 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
22 | * SOFTWARE.
|
---|
23 | *
|
---|
24 | * Copyright 1998 by Metro Link Incorporated
|
---|
25 | *
|
---|
26 | * Permission to use, copy, modify, distribute, and sell this software
|
---|
27 | * and its documentation for any purpose is hereby granted without fee,
|
---|
28 | * provided that the above copyright notice appear in all copies and that
|
---|
29 | * both that copyright notice and this permission notice appear in
|
---|
30 | * supporting documentation, and that the name of Metro Link
|
---|
31 | * Incorporated not be used in advertising or publicity pertaining to
|
---|
32 | * distribution of the software without specific, written prior
|
---|
33 | * permission. Metro Link Incorporated makes no representations
|
---|
34 | * about the suitability of this software for any purpose. It is
|
---|
35 | * provided "as is" without express or implied warranty.
|
---|
36 | *
|
---|
37 | * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
|
---|
38 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
39 | * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
|
---|
40 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
41 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
42 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
43 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
44 | * SOFTWARE.
|
---|
45 | *
|
---|
46 | * This file is derived in part from the original xf86_PCI.h that included
|
---|
47 | * following copyright message:
|
---|
48 | *
|
---|
49 | * Copyright 1995 by Robin Cutshaw <[email protected]>
|
---|
50 | *
|
---|
51 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
52 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
53 | * the above copyright notice appear in all copies and that both that
|
---|
54 | * copyright notice and this permission notice appear in supporting
|
---|
55 | * documentation, and that the names of the above listed copyright holder(s)
|
---|
56 | * not be used in advertising or publicity pertaining to distribution of
|
---|
57 | * the software without specific, written prior permission. The above listed
|
---|
58 | * copyright holder(s) make(s) no representations about the suitability of this
|
---|
59 | * software for any purpose. It is provided "as is" without express or
|
---|
60 | * implied warranty.
|
---|
61 | *
|
---|
62 | * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
|
---|
63 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
64 | * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
|
---|
65 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
66 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
---|
67 | * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
68 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
69 | *
|
---|
70 | */
|
---|
71 | /*
|
---|
72 | * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
|
---|
73 | *
|
---|
74 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
75 | * copy of this software and associated documentation files (the "Software"),
|
---|
76 | * to deal in the Software without restriction, including without limitation
|
---|
77 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
78 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
79 | * Software is furnished to do so, subject to the following conditions:
|
---|
80 | *
|
---|
81 | * The above copyright notice and this permission notice shall be included in
|
---|
82 | * all copies or substantial portions of the Software.
|
---|
83 | *
|
---|
84 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
85 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
86 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
87 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
88 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
89 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
90 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
91 | *
|
---|
92 | * Except as contained in this notice, the name of the copyright holder(s)
|
---|
93 | * and author(s) shall not be used in advertising or otherwise to promote
|
---|
94 | * the sale, use or other dealings in this Software without prior written
|
---|
95 | * authorization from the copyright holder(s) and author(s).
|
---|
96 | */
|
---|
97 |
|
---|
98 |
|
---|
99 | /*
|
---|
100 | * This file has the private Pci definitions. The public ones are imported
|
---|
101 | * from xf86Pci.h. Drivers should not use this file.
|
---|
102 | */
|
---|
103 | #ifdef HAVE_XORG_CONFIG_H
|
---|
104 | #include <xorg-config.h>
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | #ifndef _PCI_H
|
---|
108 | #define _PCI_H 1
|
---|
109 |
|
---|
110 | #include <X11/Xarch.h>
|
---|
111 | #include <X11/Xfuncproto.h>
|
---|
112 | #include "xf86Pci.h"
|
---|
113 | #include "xf86PciInfo.h"
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * Global Definitions
|
---|
117 | */
|
---|
118 | #if (defined(__alpha__) || defined(__ia64__)) && defined (linux)
|
---|
119 | #define PCI_DOM_MASK 0x01fful
|
---|
120 | #else
|
---|
121 | #define PCI_DOM_MASK 0x0ffu
|
---|
122 | #endif
|
---|
123 |
|
---|
124 | #define DEVID(vendor, device) \
|
---|
125 | ((CARD32)((PCI_##device << 16) | PCI_##vendor))
|
---|
126 |
|
---|
127 | #ifndef PCI_DOM_MASK
|
---|
128 | # define PCI_DOM_MASK 0x0ffu
|
---|
129 | #endif
|
---|
130 | #define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
|
---|
131 |
|
---|
132 | /*
|
---|
133 | * "b" contains an optional domain number.
|
---|
134 | */
|
---|
135 | #define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
|
---|
136 | (((d) & 0x00001fu) << 11) | \
|
---|
137 | (((f) & 0x000007u) << 8))
|
---|
138 |
|
---|
139 | #define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
|
---|
140 |
|
---|
141 | #define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
|
---|
142 | #define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
|
---|
143 | #define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
|
---|
144 | #define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
|
---|
145 |
|
---|
146 | #define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8)
|
---|
147 | #define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
|
---|
148 |
|
---|
149 | #define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
|
---|
150 | #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
|
---|
151 | #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
|
---|
152 |
|
---|
153 | /*
|
---|
154 | * Debug Macros/Definitions
|
---|
155 | */
|
---|
156 | /* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
|
---|
157 |
|
---|
158 | #if defined(DEBUGPCI)
|
---|
159 |
|
---|
160 | # define PCITRACE(lvl,printfargs) \
|
---|
161 | if (lvl > xf86Verbose) { \
|
---|
162 | ErrorF printfargs; \
|
---|
163 | }
|
---|
164 |
|
---|
165 | #else /* !defined(DEBUGPCI) */
|
---|
166 |
|
---|
167 | # define PCITRACE(lvl,printfargs)
|
---|
168 |
|
---|
169 | #endif /* !defined(DEBUGPCI) */
|
---|
170 |
|
---|
171 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
|
---|
172 | defined(__DragonFly__) || defined(__sun)
|
---|
173 | #define ARCH_PCI_INIT bsdPciInit
|
---|
174 | #endif
|
---|
175 |
|
---|
176 | #if defined(linux)
|
---|
177 | #define ARCH_PCI_INIT linuxPciInit
|
---|
178 | #endif /* defined(linux) */
|
---|
179 |
|
---|
180 | #ifndef ARCH_PCI_INIT
|
---|
181 | #error No PCI support available for this architecture/OS combination
|
---|
182 | #endif
|
---|
183 |
|
---|
184 | extern void ARCH_PCI_INIT(void);
|
---|
185 |
|
---|
186 | /*
|
---|
187 | * Table of functions used to access a specific PCI bus domain
|
---|
188 | * (e.g. a primary PCI bus and all of its secondaries)
|
---|
189 | */
|
---|
190 | typedef struct pci_bus_funcs {
|
---|
191 | ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
|
---|
192 | } pciBusFuncs_t, *pciBusFuncs_p;
|
---|
193 |
|
---|
194 | /* Generic PCI service functions and helpers */
|
---|
195 | ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
|
---|
196 |
|
---|
197 | extern pciBusFuncs_t *pciBusFuncs;
|
---|
198 |
|
---|
199 | #endif /* _PCI_H */
|
---|