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 | #define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */
|
---|
119 | /* by xf86scanpci */
|
---|
120 | #if defined(sun) && defined(SVR4) && defined(sparc)
|
---|
121 | # define MAX_PCI_BUSES 4096 /* Max number of PCI buses */
|
---|
122 | #elif (defined(__alpha__) || defined(__ia64__)) && defined (linux)
|
---|
123 | # define MAX_PCI_DOMAINS 512
|
---|
124 | # define PCI_DOM_MASK 0x01fful
|
---|
125 | # define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */
|
---|
126 | #else
|
---|
127 | # define MAX_PCI_BUSES 256 /* Max number of PCI buses */
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | #define DEVID(vendor, device) \
|
---|
131 | ((CARD32)((PCI_##device << 16) | PCI_##vendor))
|
---|
132 |
|
---|
133 | #ifndef PCI_DOM_MASK
|
---|
134 | # define PCI_DOM_MASK 0x0ffu
|
---|
135 | #endif
|
---|
136 | #define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
|
---|
137 |
|
---|
138 | /*
|
---|
139 | * "b" contains an optional domain number.
|
---|
140 | */
|
---|
141 | #define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
|
---|
142 | (((d) & 0x00001fu) << 11) | \
|
---|
143 | (((f) & 0x000007u) << 8))
|
---|
144 |
|
---|
145 | #define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
|
---|
146 |
|
---|
147 | #define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
|
---|
148 | #define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
|
---|
149 | #define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
|
---|
150 | #define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
|
---|
151 |
|
---|
152 | #define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8)
|
---|
153 | #define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
|
---|
154 |
|
---|
155 | #define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
|
---|
156 | #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
|
---|
157 | #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * Debug Macros/Definitions
|
---|
161 | */
|
---|
162 | /* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
|
---|
163 |
|
---|
164 | #if defined(DEBUGPCI)
|
---|
165 |
|
---|
166 | # define PCITRACE(lvl,printfargs) \
|
---|
167 | if (lvl > xf86Verbose) { \
|
---|
168 | ErrorF printfargs; \
|
---|
169 | }
|
---|
170 |
|
---|
171 | #else /* !defined(DEBUGPCI) */
|
---|
172 |
|
---|
173 | # define PCITRACE(lvl,printfargs)
|
---|
174 |
|
---|
175 | #endif /* !defined(DEBUGPCI) */
|
---|
176 |
|
---|
177 | /*
|
---|
178 | * PCI Config mechanism definitions
|
---|
179 | */
|
---|
180 | #define PCI_EN 0x80000000
|
---|
181 |
|
---|
182 | #define PCI_CFGMECH1_ADDRESS_REG 0xCF8
|
---|
183 | #define PCI_CFGMECH1_DATA_REG 0xCFC
|
---|
184 |
|
---|
185 | #define PCI_CFGMECH1_MAXDEV 32
|
---|
186 |
|
---|
187 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
|
---|
188 | defined(__DragonFly__)
|
---|
189 | #define ARCH_PCI_INIT bsdPciInit
|
---|
190 | #endif
|
---|
191 |
|
---|
192 | #if defined(linux)
|
---|
193 | # define ARCH_PCI_INIT linuxPciInit
|
---|
194 | # if defined(__m32r__)
|
---|
195 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
196 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
197 | # endif
|
---|
198 | #endif /* defined(linux) */
|
---|
199 |
|
---|
200 |
|
---|
201 | #if !defined(ARCH_PCI_INIT)
|
---|
202 | /*
|
---|
203 | * Select architecture specific PCI init function
|
---|
204 | */
|
---|
205 | #if defined(__i386__) || defined(__i386) || defined(__amd64__) || defined(__amd64) || defined(__x86_64__)
|
---|
206 | # define ARCH_PCI_INIT ix86PciInit
|
---|
207 | #elif defined(__powerpc__) || defined(__powerpc64__)
|
---|
208 | # define ARCH_PCI_INIT ppcPciInit
|
---|
209 | #elif defined(__sparc__) || defined(sparc)
|
---|
210 | # define ARCH_PCI_INIT sparcPciInit
|
---|
211 | # define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
|
---|
212 | #endif
|
---|
213 | #endif /* !defined(ARCH_PCI_INIT) */
|
---|
214 |
|
---|
215 | #ifndef ARCH_PCI_INIT
|
---|
216 | #error No PCI support available for this architecture/OS combination
|
---|
217 | #endif
|
---|
218 |
|
---|
219 | extern void ARCH_PCI_INIT(void);
|
---|
220 |
|
---|
221 | #if defined(XF86SCANPCI_WRAPPER)
|
---|
222 | typedef enum {
|
---|
223 | SCANPCI_INIT,
|
---|
224 | SCANPCI_TERM
|
---|
225 | } scanpciWrapperOpt;
|
---|
226 | extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
|
---|
227 | #endif
|
---|
228 |
|
---|
229 | /*
|
---|
230 | * Table of functions used to access a specific PCI bus domain
|
---|
231 | * (e.g. a primary PCI bus and all of its secondaries)
|
---|
232 | */
|
---|
233 | typedef struct pci_bus_funcs {
|
---|
234 | ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
|
---|
235 | } pciBusFuncs_t, *pciBusFuncs_p;
|
---|
236 |
|
---|
237 | /*
|
---|
238 | * pciBusInfo_t - One structure per defined PCI bus
|
---|
239 | */
|
---|
240 | typedef struct pci_bus_info {
|
---|
241 | unsigned char configMech; /* PCI config type to use */
|
---|
242 | unsigned char numDevices; /* Range of valid devnums */
|
---|
243 | unsigned char secondary; /* Boolean: bus is a secondary */
|
---|
244 | int primary_bus; /* Parent bus */
|
---|
245 | pciBusFuncs_p funcs; /* PCI access functions */
|
---|
246 | void *pciBusPriv; /* Implementation private data */
|
---|
247 | struct pci_device *bridge; /* bridge that opens this bus */
|
---|
248 | } pciBusInfo_t;
|
---|
249 |
|
---|
250 | #define HOST_NO_BUS ((pciBusInfo_t *)(-1))
|
---|
251 |
|
---|
252 | /* configMech values */
|
---|
253 | #define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
|
---|
254 | #define PCI_CFG_MECH_1 1 /* Most machines */
|
---|
255 | #define PCI_CFG_MECH_2 2 /* Older PC's */
|
---|
256 | #define PCI_CFG_MECH_OTHER 3 /* Something else */
|
---|
257 |
|
---|
258 | /* Generic PCI service functions and helpers */
|
---|
259 | CARD32 pciCfgMech1Read(PCITAG tag, int offset);
|
---|
260 | void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
|
---|
261 | void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
|
---|
262 | CARD32 val);
|
---|
263 | ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
|
---|
264 |
|
---|
265 | extern int pciMaxBusNum;
|
---|
266 |
|
---|
267 | extern pciBusInfo_t *pciBusInfo[];
|
---|
268 |
|
---|
269 | #endif /* _PCI_H */
|
---|