VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/xorg-server-1.4.2/Pci.h@ 78293

Last change on this file since 78293 was 43272, checked in by vboxsync, 12 years ago

Additions/x11: more original X server headers.

  • Property svn:eol-style set to native
File size: 15.6 KB
Line 
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 * Macros for bus numbers found in P2P headers.
161 */
162#define PCI_PRIMARY_BUS_EXTRACT(x, tag) \
163 ((((x) & PCI_PRIMARY_BUS_MASK ) >> 0) | (PCI_DOM_FROM_TAG(tag) << 8))
164#define PCI_SECONDARY_BUS_EXTRACT(x, tag) \
165 ((((x) & PCI_SECONDARY_BUS_MASK ) >> 8) | (PCI_DOM_FROM_TAG(tag) << 8))
166#define PCI_SUBORDINATE_BUS_EXTRACT(x, tag) \
167 ((((x) & PCI_SUBORDINATE_BUS_MASK) >> 16) | (PCI_DOM_FROM_TAG(tag) << 8))
168
169#define PCI_PRIMARY_BUS_INSERT(x, y) \
170 (((x) & ~PCI_PRIMARY_BUS_MASK ) | (((y) & 0xffu) << 0))
171#define PCI_SECONDARY_BUS_INSERT(x, y) \
172 (((x) & ~PCI_SECONDARY_BUS_MASK ) | (((y) & 0xffu) << 8))
173#define PCI_SUBORDINATE_BUS_INSERT(x, y) \
174 (((x) & ~PCI_SUBORDINATE_BUS_MASK) | (((y) & 0xffu) << 16))
175
176/* Ditto for CardBus bridges */
177#define PCI_CB_PRIMARY_BUS_EXTRACT(x, tag) \
178 PCI_PRIMARY_BUS_EXTRACT(x, tag)
179#define PCI_CB_CARDBUS_BUS_EXTRACT(x, tag) \
180 PCI_SECONDARY_BUS_EXTRACT(x, tag)
181#define PCI_CB_SUBORDINATE_BUS_EXTRACT(x, tag) \
182 PCI_SUBORDINATE_BUS_EXTRACT(x, tag)
183
184#define PCI_CB_PRIMARY_BUS_INSERT(x, tag) \
185 PCI_PRIMARY_BUS_INSERT(x, tag)
186#define PCI_CB_CARDBUS_BUS_INSERT(x, tag) \
187 PCI_SECONDARY_BUS_INSERT(x, tag)
188#define PCI_CB_SUBORDINATE_BUS_INSERT(x, tag) \
189 PCI_SUBORDINATE_BUS_INSERT(x, tag)
190
191#if X_BYTE_ORDER == X_BIG_ENDIAN
192#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
193 ((val >> 8) & 0x0000ff00) | \
194 ((val << 8) & 0x00ff0000) | \
195 ((val << 24) & 0xff000000))
196#define PCI_CPU16(val) (((val >> 8) & 0x000000ff) | \
197 ((val << 8) & 0x0000ff00))
198#else
199#define PCI_CPU(val) (val)
200#define PCI_CPU16(val) (val)
201#endif
202
203/*
204 * Debug Macros/Definitions
205 */
206/* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
207
208#if defined(DEBUGPCI)
209
210# define PCITRACE(lvl,printfargs) \
211 if (lvl > xf86Verbose) { \
212 ErrorF printfargs; \
213 }
214
215#else /* !defined(DEBUGPCI) */
216
217# define PCITRACE(lvl,printfargs)
218
219#endif /* !defined(DEBUGPCI) */
220
221/*
222 * PCI Config mechanism definitions
223 */
224#define PCI_EN 0x80000000
225
226#define PCI_CFGMECH1_ADDRESS_REG 0xCF8
227#define PCI_CFGMECH1_DATA_REG 0xCFC
228
229#define PCI_CFGMECH1_MAXDEV 32
230
231/*
232 * Select architecture specific PCI init function
233 */
234#if defined(__alpha__)
235# if defined(linux)
236# define ARCH_PCI_INIT axpPciInit
237# define INCLUDE_XF86_MAP_PCI_MEM
238# elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
239# define ARCH_PCI_INIT freebsdPciInit
240# define INCLUDE_XF86_MAP_PCI_MEM
241# define INCLUDE_XF86_NO_DOMAIN
242# elif defined(__NetBSD__)
243# define ARCH_PCI_INIT netbsdPciInit
244# define INCLUDE_XF86_MAP_PCI_MEM
245# define INCLUDE_XF86_NO_DOMAIN
246# endif
247#elif defined(__arm__)
248# if defined(linux)
249# define ARCH_PCI_INIT linuxPciInit
250# define INCLUDE_XF86_MAP_PCI_MEM
251# define INCLUDE_XF86_NO_DOMAIN
252# endif
253#elif defined(__hppa__)
254# if defined(linux)
255# define ARCH_PCI_INIT linuxPciInit
256# define INCLUDE_XF86_MAP_PCI_MEM
257# define INCLUDE_XF86_NO_DOMAIN
258# endif
259#elif defined(__ia64__)
260# if defined(linux)
261# define ARCH_PCI_INIT ia64linuxPciInit
262# define INCLUDE_XF86_MAP_PCI_MEM
263# elif defined(FreeBSD)
264# define ARCH_PCI_INIT freebsdPciInit
265# define INCLUDE_XF86_MAP_PCI_MEM
266# define INCLUDE_XF86_NO_DOMAIN
267# endif
268# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
269#elif defined(__i386__) || defined(i386)
270# define ARCH_PCI_INIT ix86PciInit
271# define INCLUDE_XF86_MAP_PCI_MEM
272# define INCLUDE_XF86_NO_DOMAIN
273# if defined(linux)
274# define ARCH_PCI_OS_INIT linuxPciInit
275# endif
276#elif defined(__mc68000__)
277# if defined(linux)
278# define ARCH_PCI_INIT linuxPciInit
279# define INCLUDE_XF86_MAP_PCI_MEM
280# define INCLUDE_XF86_NO_DOMAIN
281# endif
282#elif defined(__mips__)
283# if defined(linux)
284# define ARCH_PCI_INIT linuxPciInit
285# define INCLUDE_XF86_MAP_PCI_MEM
286# define INCLUDE_XF86_NO_DOMAIN
287# endif
288#elif defined(__powerpc__) || defined(__powerpc64__)
289# if defined(linux)
290# define ARCH_PCI_INIT linuxPciInit
291# define INCLUDE_XF86_MAP_PCI_MEM
292# define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */
293# elif defined(__FreeBSD__) || defined(__OpenBSD__)
294# define ARCH_PCI_INIT freebsdPciInit
295# define INCLUDE_XF86_MAP_PCI_MEM
296# define INCLUDE_XF86_NO_DOMAIN
297# elif defined(__NetBSD__)
298# define ARCH_PCI_INIT netbsdPciInit
299# define INCLUDE_XF86_MAP_PCI_MEM
300# define INCLUDE_XF86_NO_DOMAIN
301# else
302# define ARCH_PCI_INIT ppcPciInit
303# define INCLUDE_XF86_MAP_PCI_MEM
304# define INCLUDE_XF86_NO_DOMAIN
305# endif
306#elif defined(__s390__)
307# if defined(linux)
308# define ARCH_PCI_INIT linuxPciInit
309# define INCLUDE_XF86_MAP_PCI_MEM
310# define INCLUDE_XF86_NO_DOMAIN
311# endif
312#elif defined(__sh__)
313# if defined(linux)
314# define ARCH_PCI_INIT linuxPciInit
315# define INCLUDE_XF86_MAP_PCI_MEM
316# define INCLUDE_XF86_NO_DOMAIN
317# endif
318#elif defined(__sparc__) || defined(sparc)
319# if defined(linux)
320# define ARCH_PCI_INIT linuxPciInit
321# define INCLUDE_XF86_MAP_PCI_MEM
322# elif defined(sun)
323# define ARCH_PCI_INIT sparcPciInit
324# define INCLUDE_XF86_MAP_PCI_MEM
325# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
326# define ARCH_PCI_INIT freebsdPciInit
327# define INCLUDE_XF86_MAP_PCI_MEM
328# define INCLUDE_XF86_NO_DOMAIN
329# endif
330# if !defined(__FreeBSD__) && !defined(linux)
331# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
332# endif
333#elif defined(__amd64__) || defined(__amd64)
334# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
335# define ARCH_PCI_INIT freebsdPciInit
336# else
337# define ARCH_PCI_INIT ix86PciInit
338# endif
339# define INCLUDE_XF86_MAP_PCI_MEM
340# define INCLUDE_XF86_NO_DOMAIN
341# if defined(linux)
342# define ARCH_PCI_OS_INIT linuxPciInit
343# endif
344#endif
345
346#ifndef ARCH_PCI_INIT
347#error No PCI support available for this architecture/OS combination
348#endif
349
350extern void ARCH_PCI_INIT(void);
351#if defined(ARCH_PCI_OS_INIT)
352extern void ARCH_PCI_OS_INIT(void);
353#endif
354
355#if defined(ARCH_PCI_PCI_BRIDGE)
356extern void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI);
357#endif
358
359#if defined(XF86SCANPCI_WRAPPER)
360typedef enum {
361 SCANPCI_INIT,
362 SCANPCI_TERM
363} scanpciWrapperOpt;
364extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
365#endif
366
367/*
368 * Table of functions used to access a specific PCI bus domain
369 * (e.g. a primary PCI bus and all of its secondaries)
370 */
371typedef struct pci_bus_funcs {
372 CARD32 (*pciReadLong)(PCITAG, int);
373 void (*pciWriteLong)(PCITAG, int, CARD32);
374 void (*pciSetBitsLong)(PCITAG, int, CARD32, CARD32);
375 ADDRESS (*pciAddrHostToBus)(PCITAG, PciAddrType, ADDRESS);
376 ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
377 /*
378 * The next three are optional. If NULL, the corresponding function is
379 * to be performed generically.
380 */
381 CARD16 (*pciControlBridge)(int, CARD16, CARD16);
382 void (*pciGetBridgeBuses)(int, int *, int *, int *);
383 /* Use pointer's to avoid #include recursion */
384 void (*pciGetBridgeResources)(int, pointer *, pointer *, pointer *);
385
386 /* These are optional and will be implemented using read long
387 * if not present. */
388 CARD8 (*pciReadByte)(PCITAG, int);
389 void (*pciWriteByte)(PCITAG, int, CARD8);
390 CARD16 (*pciReadWord)(PCITAG, int);
391 void (*pciWriteWord)(PCITAG, int, CARD16);
392
393} pciBusFuncs_t, *pciBusFuncs_p;
394
395/*
396 * pciBusInfo_t - One structure per defined PCI bus
397 */
398typedef struct pci_bus_info {
399 unsigned char configMech; /* PCI config type to use */
400 unsigned char numDevices; /* Range of valid devnums */
401 unsigned char secondary; /* Boolean: bus is a secondary */
402 int primary_bus; /* Parent bus */
403 pciBusFuncs_p funcs; /* PCI access functions */
404 void *pciBusPriv; /* Implementation private data */
405 pciConfigPtr bridge; /* bridge that opens this bus */
406} pciBusInfo_t;
407
408#define HOST_NO_BUS ((pciBusInfo_t *)(-1))
409
410/* configMech values */
411#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
412#define PCI_CFG_MECH_1 1 /* Most machines */
413#define PCI_CFG_MECH_2 2 /* Older PC's */
414#define PCI_CFG_MECH_OTHER 3 /* Something else */
415
416/* Generic PCI service functions and helpers */
417PCITAG pciGenFindFirst(void);
418PCITAG pciGenFindNext(void);
419CARD32 pciCfgMech1Read(PCITAG tag, int offset);
420void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
421void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
422 CARD32 val);
423CARD32 pciByteSwap(CARD32);
424Bool pciMfDev(int, int);
425ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
426
427extern void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len));
428extern PCITAG (*pciFindFirstFP)(void);
429extern PCITAG (*pciFindNextFP)(void);
430
431extern CARD32 pciDevid;
432extern CARD32 pciDevidMask;
433
434extern int pciMaxBusNum;
435
436extern int pciBusNum;
437extern int pciDevNum;
438extern int pciFuncNum;
439extern PCITAG pciDeviceTag;
440
441extern int xf86MaxPciDevs;
442
443extern pciBusInfo_t *pciBusInfo[];
444
445#endif /* _PCI_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette