1 | /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.45 2004/02/02 03:55:31 dawes Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright 1998 by Concurrent Computer Corporation
|
---|
4 | *
|
---|
5 | * Permission to use, copy, modify, distribute, and sell this software
|
---|
6 | * and its documentation for any purpose is hereby granted without fee,
|
---|
7 | * provided that the above copyright notice appear in all copies and that
|
---|
8 | * both that copyright notice and this permission notice appear in
|
---|
9 | * supporting documentation, and that the name of Concurrent Computer
|
---|
10 | * Corporation not be used in advertising or publicity pertaining to
|
---|
11 | * distribution of the software without specific, written prior
|
---|
12 | * permission. Concurrent Computer Corporation makes no representations
|
---|
13 | * about the suitability of this software for any purpose. It is
|
---|
14 | * provided "as is" without express or implied warranty.
|
---|
15 | *
|
---|
16 | * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
|
---|
17 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
18 | * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
|
---|
19 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
20 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
21 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
22 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
23 | * SOFTWARE.
|
---|
24 | *
|
---|
25 | * Copyright 1998 by Metro Link Incorporated
|
---|
26 | *
|
---|
27 | * Permission to use, copy, modify, distribute, and sell this software
|
---|
28 | * and its documentation for any purpose is hereby granted without fee,
|
---|
29 | * provided that the above copyright notice appear in all copies and that
|
---|
30 | * both that copyright notice and this permission notice appear in
|
---|
31 | * supporting documentation, and that the name of Metro Link
|
---|
32 | * Incorporated not be used in advertising or publicity pertaining to
|
---|
33 | * distribution of the software without specific, written prior
|
---|
34 | * permission. Metro Link Incorporated makes no representations
|
---|
35 | * about the suitability of this software for any purpose. It is
|
---|
36 | * provided "as is" without express or implied warranty.
|
---|
37 | *
|
---|
38 | * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
|
---|
39 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
40 | * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
|
---|
41 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
42 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
---|
43 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
---|
44 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
---|
45 | * SOFTWARE.
|
---|
46 | *
|
---|
47 | * This file is derived in part from the original xf86_PCI.h that included
|
---|
48 | * following copyright message:
|
---|
49 | *
|
---|
50 | * Copyright 1995 by Robin Cutshaw <[email protected]>
|
---|
51 | *
|
---|
52 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
53 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
54 | * the above copyright notice appear in all copies and that both that
|
---|
55 | * copyright notice and this permission notice appear in supporting
|
---|
56 | * documentation, and that the names of the above listed copyright holder(s)
|
---|
57 | * not be used in advertising or publicity pertaining to distribution of
|
---|
58 | * the software without specific, written prior permission. The above listed
|
---|
59 | * copyright holder(s) make(s) no representations about the suitability of this
|
---|
60 | * software for any purpose. It is provided "as is" without express or
|
---|
61 | * implied warranty.
|
---|
62 | *
|
---|
63 | * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
|
---|
64 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
65 | * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
|
---|
66 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
67 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
---|
68 | * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
69 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
70 | *
|
---|
71 | */
|
---|
72 | /*
|
---|
73 | * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
|
---|
74 | *
|
---|
75 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
76 | * copy of this software and associated documentation files (the "Software"),
|
---|
77 | * to deal in the Software without restriction, including without limitation
|
---|
78 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
79 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
80 | * Software is furnished to do so, subject to the following conditions:
|
---|
81 | *
|
---|
82 | * The above copyright notice and this permission notice shall be included in
|
---|
83 | * all copies or substantial portions of the Software.
|
---|
84 | *
|
---|
85 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
86 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
87 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
88 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
89 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
90 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
91 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
92 | *
|
---|
93 | * Except as contained in this notice, the name of the copyright holder(s)
|
---|
94 | * and author(s) shall not be used in advertising or otherwise to promote
|
---|
95 | * the sale, use or other dealings in this Software without prior written
|
---|
96 | * authorization from the copyright holder(s) and author(s).
|
---|
97 | */
|
---|
98 |
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * This file has the private Pci definitions. The public ones are imported
|
---|
102 | * from xf86Pci.h. Drivers should not use this file.
|
---|
103 | */
|
---|
104 | #ifdef HAVE_XORG_CONFIG_H
|
---|
105 | #include <xorg-config.h>
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | #ifndef _PCI_H
|
---|
109 | #define _PCI_H 1
|
---|
110 |
|
---|
111 | #include <X11/Xarch.h>
|
---|
112 | #include <X11/Xfuncproto.h>
|
---|
113 | #include "xf86Pci.h"
|
---|
114 | #include "xf86PciInfo.h"
|
---|
115 |
|
---|
116 | /*
|
---|
117 | * Global Definitions
|
---|
118 | */
|
---|
119 | #define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */
|
---|
120 | /* by xf86scanpci */
|
---|
121 | #if defined(sun) && defined(SVR4) && defined(sparc)
|
---|
122 | # define MAX_PCI_BUSES 4096 /* Max number of PCI buses */
|
---|
123 | #elif defined(__alpha__) && defined (linux)
|
---|
124 | # define MAX_PCI_DOMAINS 512
|
---|
125 | # define PCI_DOM_MASK 0x01fful
|
---|
126 | # define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */
|
---|
127 | #else
|
---|
128 | # define MAX_PCI_BUSES 256 /* Max number of PCI buses */
|
---|
129 | #endif
|
---|
130 |
|
---|
131 | #define DEVID(vendor, device) \
|
---|
132 | ((CARD32)((PCI_##device << 16) | PCI_##vendor))
|
---|
133 |
|
---|
134 | #ifndef PCI_DOM_MASK
|
---|
135 | # define PCI_DOM_MASK 0x0ffu
|
---|
136 | #endif
|
---|
137 | #define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
|
---|
138 |
|
---|
139 | /*
|
---|
140 | * "b" contains an optional domain number.
|
---|
141 | */
|
---|
142 | #define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
|
---|
143 | (((d) & 0x00001fu) << 11) | \
|
---|
144 | (((f) & 0x000007u) << 8))
|
---|
145 |
|
---|
146 | #define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
|
---|
147 |
|
---|
148 | #define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
|
---|
149 | #define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
|
---|
150 | #define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
|
---|
151 | #define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
|
---|
152 |
|
---|
153 | #define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8)
|
---|
154 | #define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
|
---|
155 |
|
---|
156 | #define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
|
---|
157 | #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
|
---|
158 | #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
|
---|
159 |
|
---|
160 | /*
|
---|
161 | * Macros for bus numbers found in P2P headers.
|
---|
162 | */
|
---|
163 | #define PCI_PRIMARY_BUS_EXTRACT(x, tag) \
|
---|
164 | ((((x) & PCI_PRIMARY_BUS_MASK ) >> 0) | (PCI_DOM_FROM_TAG(tag) << 8))
|
---|
165 | #define PCI_SECONDARY_BUS_EXTRACT(x, tag) \
|
---|
166 | ((((x) & PCI_SECONDARY_BUS_MASK ) >> 8) | (PCI_DOM_FROM_TAG(tag) << 8))
|
---|
167 | #define PCI_SUBORDINATE_BUS_EXTRACT(x, tag) \
|
---|
168 | ((((x) & PCI_SUBORDINATE_BUS_MASK) >> 16) | (PCI_DOM_FROM_TAG(tag) << 8))
|
---|
169 |
|
---|
170 | #define PCI_PRIMARY_BUS_INSERT(x, y) \
|
---|
171 | (((x) & ~PCI_PRIMARY_BUS_MASK ) | (((y) & 0xffu) << 0))
|
---|
172 | #define PCI_SECONDARY_BUS_INSERT(x, y) \
|
---|
173 | (((x) & ~PCI_SECONDARY_BUS_MASK ) | (((y) & 0xffu) << 8))
|
---|
174 | #define PCI_SUBORDINATE_BUS_INSERT(x, y) \
|
---|
175 | (((x) & ~PCI_SUBORDINATE_BUS_MASK) | (((y) & 0xffu) << 16))
|
---|
176 |
|
---|
177 | /* Ditto for CardBus bridges */
|
---|
178 | #define PCI_CB_PRIMARY_BUS_EXTRACT(x, tag) \
|
---|
179 | PCI_PRIMARY_BUS_EXTRACT(x, tag)
|
---|
180 | #define PCI_CB_CARDBUS_BUS_EXTRACT(x, tag) \
|
---|
181 | PCI_SECONDARY_BUS_EXTRACT(x, tag)
|
---|
182 | #define PCI_CB_SUBORDINATE_BUS_EXTRACT(x, tag) \
|
---|
183 | PCI_SUBORDINATE_BUS_EXTRACT(x, tag)
|
---|
184 |
|
---|
185 | #define PCI_CB_PRIMARY_BUS_INSERT(x, tag) \
|
---|
186 | PCI_PRIMARY_BUS_INSERT(x, tag)
|
---|
187 | #define PCI_CB_CARDBUS_BUS_INSERT(x, tag) \
|
---|
188 | PCI_SECONDARY_BUS_INSERT(x, tag)
|
---|
189 | #define PCI_CB_SUBORDINATE_BUS_INSERT(x, tag) \
|
---|
190 | PCI_SUBORDINATE_BUS_INSERT(x, tag)
|
---|
191 |
|
---|
192 | #if X_BYTE_ORDER == X_BIG_ENDIAN
|
---|
193 | #define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
|
---|
194 | ((val >> 8) & 0x0000ff00) | \
|
---|
195 | ((val << 8) & 0x00ff0000) | \
|
---|
196 | ((val << 24) & 0xff000000))
|
---|
197 | #define PCI_CPU16(val) (((val >> 8) & 0x000000ff) | \
|
---|
198 | ((val << 8) & 0x0000ff00))
|
---|
199 | #else
|
---|
200 | #define PCI_CPU(val) (val)
|
---|
201 | #define PCI_CPU16(val) (val)
|
---|
202 | #endif
|
---|
203 |
|
---|
204 | /*
|
---|
205 | * Debug Macros/Definitions
|
---|
206 | */
|
---|
207 | /* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
|
---|
208 |
|
---|
209 | #if defined(DEBUGPCI)
|
---|
210 |
|
---|
211 | # define PCITRACE(lvl,printfargs) \
|
---|
212 | if (lvl > xf86Verbose) { \
|
---|
213 | ErrorF printfargs; \
|
---|
214 | }
|
---|
215 |
|
---|
216 | #else /* !defined(DEBUGPCI) */
|
---|
217 |
|
---|
218 | # define PCITRACE(lvl,printfargs)
|
---|
219 |
|
---|
220 | #endif /* !defined(DEBUGPCI) */
|
---|
221 |
|
---|
222 | /*
|
---|
223 | * PCI Config mechanism definitions
|
---|
224 | */
|
---|
225 | #define PCI_EN 0x80000000
|
---|
226 |
|
---|
227 | #define PCI_CFGMECH1_ADDRESS_REG 0xCF8
|
---|
228 | #define PCI_CFGMECH1_DATA_REG 0xCFC
|
---|
229 |
|
---|
230 | #define PCI_CFGMECH1_MAXDEV 32
|
---|
231 |
|
---|
232 | /*
|
---|
233 | * Select architecture specific PCI init function
|
---|
234 | */
|
---|
235 | #if defined(__alpha__)
|
---|
236 | # if defined(linux)
|
---|
237 | # define ARCH_PCI_INIT axpPciInit
|
---|
238 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
239 | # elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
---|
240 | # define ARCH_PCI_INIT freebsdPciInit
|
---|
241 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
242 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
243 | # elif defined(__NetBSD__)
|
---|
244 | # define ARCH_PCI_INIT netbsdPciInit
|
---|
245 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
246 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
247 | # endif
|
---|
248 | #elif defined(__arm__)
|
---|
249 | # if defined(linux)
|
---|
250 | # define ARCH_PCI_INIT linuxPciInit
|
---|
251 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
252 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
253 | # endif
|
---|
254 | #elif defined(__hppa__)
|
---|
255 | # if defined(linux)
|
---|
256 | # define ARCH_PCI_INIT linuxPciInit
|
---|
257 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
258 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
259 | # endif
|
---|
260 | #elif defined(__ia64__)
|
---|
261 | # if defined(linux)
|
---|
262 | # define ARCH_PCI_INIT linuxPciInit
|
---|
263 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
264 | # elif defined(FreeBSD)
|
---|
265 | # define ARCH_PCI_INIT freebsdPciInit
|
---|
266 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
267 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
268 | # endif
|
---|
269 | # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
|
---|
270 | #elif defined(__i386__) || defined(i386)
|
---|
271 | # define ARCH_PCI_INIT ix86PciInit
|
---|
272 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
273 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
274 | # if defined(linux)
|
---|
275 | # define ARCH_PCI_OS_INIT linuxPciInit
|
---|
276 | # endif
|
---|
277 | #elif defined(__mc68000__)
|
---|
278 | # if defined(linux)
|
---|
279 | # define ARCH_PCI_INIT linuxPciInit
|
---|
280 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
281 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
282 | # endif
|
---|
283 | #elif defined(__mips__)
|
---|
284 | # if defined(linux)
|
---|
285 | # define ARCH_PCI_INIT linuxPciInit
|
---|
286 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
287 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
288 | # endif
|
---|
289 | #elif defined(__powerpc__) || defined(__powerpc64__)
|
---|
290 | # if defined(linux)
|
---|
291 | # define ARCH_PCI_INIT linuxPciInit
|
---|
292 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
293 | # define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */
|
---|
294 | # elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
---|
295 | # define ARCH_PCI_INIT freebsdPciInit
|
---|
296 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
297 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
298 | # elif defined(__NetBSD__)
|
---|
299 | # define ARCH_PCI_INIT netbsdPciInit
|
---|
300 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
301 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
302 | # else
|
---|
303 | # define ARCH_PCI_INIT ppcPciInit
|
---|
304 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
305 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
306 | # endif
|
---|
307 | #elif defined(__s390__)
|
---|
308 | # if defined(linux)
|
---|
309 | # define ARCH_PCI_INIT linuxPciInit
|
---|
310 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
311 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
312 | # endif
|
---|
313 | #elif defined(__sh__)
|
---|
314 | # if defined(linux)
|
---|
315 | # define ARCH_PCI_INIT linuxPciInit
|
---|
316 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
317 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
318 | # endif
|
---|
319 | #elif defined(__sparc__) || defined(sparc)
|
---|
320 | # if defined(linux)
|
---|
321 | # define ARCH_PCI_INIT linuxPciInit
|
---|
322 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
323 | # elif defined(sun)
|
---|
324 | # define ARCH_PCI_INIT sparcPciInit
|
---|
325 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
326 | # elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
|
---|
327 | # define ARCH_PCI_INIT freebsdPciInit
|
---|
328 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
329 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
330 | # endif
|
---|
331 | # if !defined(__FreeBSD__)
|
---|
332 | # define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
|
---|
333 | # endif
|
---|
334 | #elif defined(__amd64__) || defined(__amd64)
|
---|
335 | # if defined(__FreeBSD__)
|
---|
336 | # define ARCH_PCI_INIT freebsdPciInit
|
---|
337 | # else
|
---|
338 | # define ARCH_PCI_INIT ix86PciInit
|
---|
339 | # endif
|
---|
340 | # define INCLUDE_XF86_MAP_PCI_MEM
|
---|
341 | # define INCLUDE_XF86_NO_DOMAIN
|
---|
342 | # if defined(linux)
|
---|
343 | # define ARCH_PCI_OS_INIT linuxPciInit
|
---|
344 | # endif
|
---|
345 | #endif
|
---|
346 |
|
---|
347 | #ifndef ARCH_PCI_INIT
|
---|
348 | #error No PCI support available for this architecture/OS combination
|
---|
349 | #endif
|
---|
350 |
|
---|
351 | extern void ARCH_PCI_INIT(void);
|
---|
352 | #if defined(ARCH_PCI_OS_INIT)
|
---|
353 | extern void ARCH_PCI_OS_INIT(void);
|
---|
354 | #endif
|
---|
355 |
|
---|
356 | #if defined(ARCH_PCI_PCI_BRIDGE)
|
---|
357 | extern void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI);
|
---|
358 | #endif
|
---|
359 |
|
---|
360 | #if defined(XF86SCANPCI_WRAPPER)
|
---|
361 | typedef enum {
|
---|
362 | SCANPCI_INIT,
|
---|
363 | SCANPCI_TERM
|
---|
364 | } scanpciWrapperOpt;
|
---|
365 | extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
|
---|
366 | #endif
|
---|
367 |
|
---|
368 | /*
|
---|
369 | * Table of functions used to access a specific PCI bus domain
|
---|
370 | * (e.g. a primary PCI bus and all of its secondaries)
|
---|
371 | */
|
---|
372 | typedef struct pci_bus_funcs {
|
---|
373 | CARD32 (*pciReadLong)(PCITAG, int);
|
---|
374 | void (*pciWriteLong)(PCITAG, int, CARD32);
|
---|
375 | void (*pciSetBitsLong)(PCITAG, int, CARD32, CARD32);
|
---|
376 | ADDRESS (*pciAddrHostToBus)(PCITAG, PciAddrType, ADDRESS);
|
---|
377 | ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
|
---|
378 | /*
|
---|
379 | * The next three are optional. If NULL, the corresponding function is
|
---|
380 | * to be performed generically.
|
---|
381 | */
|
---|
382 | CARD16 (*pciControlBridge)(int, CARD16, CARD16);
|
---|
383 | void (*pciGetBridgeBuses)(int, int *, int *, int *);
|
---|
384 | /* Use pointer's to avoid #include recursion */
|
---|
385 | void (*pciGetBridgeResources)(int, pointer *, pointer *, pointer *);
|
---|
386 |
|
---|
387 | /* These are optional and will be implemented using read long
|
---|
388 | * if not present. */
|
---|
389 | CARD8 (*pciReadByte)(PCITAG, int);
|
---|
390 | void (*pciWriteByte)(PCITAG, int, CARD8);
|
---|
391 | CARD16 (*pciReadWord)(PCITAG, int);
|
---|
392 | void (*pciWriteWord)(PCITAG, int, CARD16);
|
---|
393 |
|
---|
394 | } pciBusFuncs_t, *pciBusFuncs_p;
|
---|
395 |
|
---|
396 | /*
|
---|
397 | * pciBusInfo_t - One structure per defined PCI bus
|
---|
398 | */
|
---|
399 | typedef struct pci_bus_info {
|
---|
400 | unsigned char configMech; /* PCI config type to use */
|
---|
401 | unsigned char numDevices; /* Range of valid devnums */
|
---|
402 | unsigned char secondary; /* Boolean: bus is a secondary */
|
---|
403 | int primary_bus; /* Parent bus */
|
---|
404 | pciBusFuncs_p funcs; /* PCI access functions */
|
---|
405 | void *pciBusPriv; /* Implementation private data */
|
---|
406 | pciConfigPtr bridge; /* bridge that opens this bus */
|
---|
407 | } pciBusInfo_t;
|
---|
408 |
|
---|
409 | #define HOST_NO_BUS ((pciBusInfo_t *)(-1))
|
---|
410 |
|
---|
411 | /* configMech values */
|
---|
412 | #define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
|
---|
413 | #define PCI_CFG_MECH_1 1 /* Most machines */
|
---|
414 | #define PCI_CFG_MECH_2 2 /* Older PC's */
|
---|
415 | #define PCI_CFG_MECH_OTHER 3 /* Something else */
|
---|
416 |
|
---|
417 | /* Generic PCI service functions and helpers */
|
---|
418 | PCITAG pciGenFindFirst(void);
|
---|
419 | PCITAG pciGenFindNext(void);
|
---|
420 | CARD32 pciCfgMech1Read(PCITAG tag, int offset);
|
---|
421 | void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
|
---|
422 | void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
|
---|
423 | CARD32 val);
|
---|
424 | CARD32 pciByteSwap(CARD32);
|
---|
425 | Bool pciMfDev(int, int);
|
---|
426 | ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
|
---|
427 |
|
---|
428 | extern void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len));
|
---|
429 | extern PCITAG (*pciFindFirstFP)(void);
|
---|
430 | extern PCITAG (*pciFindNextFP)(void);
|
---|
431 |
|
---|
432 | extern CARD32 pciDevid;
|
---|
433 | extern CARD32 pciDevidMask;
|
---|
434 |
|
---|
435 | extern int pciMaxBusNum;
|
---|
436 |
|
---|
437 | extern int pciBusNum;
|
---|
438 | extern int pciDevNum;
|
---|
439 | extern int pciFuncNum;
|
---|
440 | extern PCITAG pciDeviceTag;
|
---|
441 |
|
---|
442 | extern pciBusInfo_t *pciBusInfo[];
|
---|
443 |
|
---|
444 | #endif /* _PCI_H */
|
---|