VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/7.0/xorg/Pci.h@ 18709

Last change on this file since 18709 was 17236, checked in by vboxsync, 16 years ago

Additions/x11/x11include: blast! Reverted r43555 and r43556

  • Property svn:eol-style set to native
File size: 15.7 KB
Line 
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# elif defined(PowerMAX_OS) /* This port is broken */
303# define ARCH_PCI_INIT ppcPciInit
304# else
305# define ARCH_PCI_INIT ppcPciInit
306# define INCLUDE_XF86_MAP_PCI_MEM
307# define INCLUDE_XF86_NO_DOMAIN
308# endif
309#elif defined(__s390__)
310# if defined(linux)
311# define ARCH_PCI_INIT linuxPciInit
312# define INCLUDE_XF86_MAP_PCI_MEM
313# define INCLUDE_XF86_NO_DOMAIN
314# endif
315#elif defined(__sh__)
316# if defined(linux)
317# define ARCH_PCI_INIT linuxPciInit
318# define INCLUDE_XF86_MAP_PCI_MEM
319# define INCLUDE_XF86_NO_DOMAIN
320# endif
321#elif defined(__sparc__) || defined(sparc)
322# if defined(linux)
323# define ARCH_PCI_INIT linuxPciInit
324# define INCLUDE_XF86_MAP_PCI_MEM
325# elif defined(sun)
326# define ARCH_PCI_INIT sparcPciInit
327# define INCLUDE_XF86_MAP_PCI_MEM
328# elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__)
329# define ARCH_PCI_INIT freebsdPciInit
330# define INCLUDE_XF86_MAP_PCI_MEM
331# define INCLUDE_XF86_NO_DOMAIN
332# endif
333# if !defined(__FreeBSD__)
334# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
335# endif
336#elif defined(__amd64__) || defined(__amd64)
337# if defined(__FreeBSD__)
338# define ARCH_PCI_INIT freebsdPciInit
339# else
340# define ARCH_PCI_INIT ix86PciInit
341# endif
342# define INCLUDE_XF86_MAP_PCI_MEM
343# define INCLUDE_XF86_NO_DOMAIN
344# if defined(linux)
345# define ARCH_PCI_OS_INIT linuxPciInit
346# endif
347#endif
348
349#ifndef ARCH_PCI_INIT
350#error No PCI support available for this architecture/OS combination
351#endif
352
353extern void ARCH_PCI_INIT(void);
354#if defined(ARCH_PCI_OS_INIT)
355extern void ARCH_PCI_OS_INIT(void);
356#endif
357
358#if defined(ARCH_PCI_PCI_BRIDGE)
359extern void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI);
360#endif
361
362#if defined(XF86SCANPCI_WRAPPER)
363typedef enum {
364 SCANPCI_INIT,
365 SCANPCI_TERM
366} scanpciWrapperOpt;
367extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
368#endif
369
370/*
371 * Table of functions used to access a specific PCI bus domain
372 * (e.g. a primary PCI bus and all of its secondaries)
373 */
374typedef struct pci_bus_funcs {
375 CARD32 (*pciReadLong)(PCITAG, int);
376 void (*pciWriteLong)(PCITAG, int, CARD32);
377 void (*pciSetBitsLong)(PCITAG, int, CARD32, CARD32);
378 ADDRESS (*pciAddrHostToBus)(PCITAG, PciAddrType, ADDRESS);
379 ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
380 /*
381 * The next three are optional. If NULL, the corresponding function is
382 * to be performed generically.
383 */
384 CARD16 (*pciControlBridge)(int, CARD16, CARD16);
385 void (*pciGetBridgeBuses)(int, int *, int *, int *);
386 /* Use pointer's to avoid #include recursion */
387 void (*pciGetBridgeResources)(int, pointer *, pointer *, pointer *);
388
389 /* These are optional and will be implemented using read long
390 * if not present. */
391 CARD8 (*pciReadByte)(PCITAG, int);
392 void (*pciWriteByte)(PCITAG, int, CARD8);
393 CARD16 (*pciReadWord)(PCITAG, int);
394 void (*pciWriteWord)(PCITAG, int, CARD16);
395
396} pciBusFuncs_t, *pciBusFuncs_p;
397
398/*
399 * pciBusInfo_t - One structure per defined PCI bus
400 */
401typedef struct pci_bus_info {
402 unsigned char configMech; /* PCI config type to use */
403 unsigned char numDevices; /* Range of valid devnums */
404 unsigned char secondary; /* Boolean: bus is a secondary */
405 int primary_bus; /* Parent bus */
406#ifdef PowerMAX_OS
407 unsigned long ppc_io_base; /* PowerPC I/O spc membase */
408 unsigned long ppc_io_size; /* PowerPC I/O spc size */
409#endif
410 pciBusFuncs_p funcs; /* PCI access functions */
411 void *pciBusPriv; /* Implementation private data */
412 pciConfigPtr bridge; /* bridge that opens this bus */
413} pciBusInfo_t;
414
415#define HOST_NO_BUS ((pciBusInfo_t *)(-1))
416
417/* configMech values */
418#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
419#define PCI_CFG_MECH_1 1 /* Most machines */
420#define PCI_CFG_MECH_2 2 /* Older PC's */
421#define PCI_CFG_MECH_OTHER 3 /* Something else */
422
423/* Generic PCI service functions and helpers */
424PCITAG pciGenFindFirst(void);
425PCITAG pciGenFindNext(void);
426CARD32 pciCfgMech1Read(PCITAG tag, int offset);
427void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
428void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
429 CARD32 val);
430CARD32 pciByteSwap(CARD32);
431Bool pciMfDev(int, int);
432ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
433
434extern PCITAG (*pciFindFirstFP)(void);
435extern PCITAG (*pciFindNextFP)(void);
436
437extern CARD32 pciDevid;
438extern CARD32 pciDevidMask;
439
440extern int pciMaxBusNum;
441
442extern int pciBusNum;
443extern int pciDevNum;
444extern int pciFuncNum;
445extern PCITAG pciDeviceTag;
446
447extern pciBusInfo_t *pciBusInfo[];
448
449#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