VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/x11include/XFree86-4.3/Xserver/Pci.h@ 97956

最後變更 在這個檔案從97956是 69098,由 vboxsync 提交於 7 年 前

Clean up XFree86 driver header files.
bugref:3810: X11 Guest Additions maintenance
Over the years we have cleaned up the layout in the tree of the X.Org
header files we use to build drivers. The XFree86 ones were still in their
original, rather sub-optimal layout. This change fixes that.

  • 屬性 svn:eol-style 設為 native
檔案大小: 13.8 KB
 
1/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.36 2002/12/23 15:37:26 tsi 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/*
74 * This file has the private Pci definitions. The public ones are imported
75 * from xf86Pci.h. Drivers should not use this file.
76 */
77#ifndef _PCI_H
78#define _PCI_H 1
79
80#include "Xarch.h"
81#include "Xfuncproto.h"
82#include "xf86Pci.h"
83#include "xf86PciInfo.h"
84
85/*
86 * Global Definitions
87 */
88#define MAX_PCI_DEVICES 64 /* Max number of devices accomodated */
89 /* by xf86scanpci */
90#if defined(sun) && defined(SVR4) && defined(sparc)
91# define MAX_PCI_BUSES 4096 /* Max number of PCI buses */
92#elif defined(__alpha__) && defined (linux)
93# define MAX_PCI_DOMAINS 512
94# define PCI_DOM_MASK 0x01fful
95# define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */
96#else
97# define MAX_PCI_BUSES 256 /* Max number of PCI buses */
98#endif
99
100#define PCI_NOT_FOUND 0xffffffff
101
102#define DEVID(vendor, device) \
103 ((CARD32)((PCI_CHIP_##device << 16) | PCI_VENDOR_##vendor))
104
105#ifndef PCI_DOM_MASK
106# define PCI_DOM_MASK 0x0ffu
107#endif
108#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
109
110/*
111 * "b" contains an optional domain number.
112 */
113#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
114 (((d) & 0x00001fu) << 11) | \
115 (((f) & 0x000007u) << 8))
116
117#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
118
119#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
120#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
121#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
122#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
123
124#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8)
125#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
126
127#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
128#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
129#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
130
131/*
132 * Macros for bus numbers found in P2P headers.
133 */
134#define PCI_PRIMARY_BUS_EXTRACT(x, tag) \
135 ((((x) & PCI_PRIMARY_BUS_MASK ) >> 0) | (PCI_DOM_FROM_TAG(tag) << 8))
136#define PCI_SECONDARY_BUS_EXTRACT(x, tag) \
137 ((((x) & PCI_SECONDARY_BUS_MASK ) >> 8) | (PCI_DOM_FROM_TAG(tag) << 8))
138#define PCI_SUBORDINATE_BUS_EXTRACT(x, tag) \
139 ((((x) & PCI_SUBORDINATE_BUS_MASK) >> 16) | (PCI_DOM_FROM_TAG(tag) << 8))
140
141#define PCI_PRIMARY_BUS_INSERT(x, y) \
142 (((x) & ~PCI_PRIMARY_BUS_MASK ) | (((y) & 0xffu) << 0))
143#define PCI_SECONDARY_BUS_INSERT(x, y) \
144 (((x) & ~PCI_SECONDARY_BUS_MASK ) | (((y) & 0xffu) << 8))
145#define PCI_SUBORDINATE_BUS_INSERT(x, y) \
146 (((x) & ~PCI_SUBORDINATE_BUS_MASK) | (((y) & 0xffu) << 16))
147
148/* Ditto for CardBus bridges */
149#define PCI_CB_PRIMARY_BUS_EXTRACT(x, tag) \
150 PCI_PRIMARY_BUS_EXTRACT(x, tag)
151#define PCI_CB_CARDBUS_BUS_EXTRACT(x, tag) \
152 PCI_SECONDARY_BUS_EXTRACT(x, tag)
153#define PCI_CB_SUBORDINATE_BUS_EXTRACT(x, tag) \
154 PCI_SUBORDINATE_BUS_EXTRACT(x, tag)
155
156#define PCI_CB_PRIMARY_BUS_INSERT(x, tag) \
157 PCI_PRIMARY_BUS_INSERT(x, tag)
158#define PCI_CB_CARDBUS_BUS_INSERT(x, tag) \
159 PCI_SECONDARY_BUS_INSERT(x, tag)
160#define PCI_CB_SUBORDINATE_BUS_INSERT(x, tag) \
161 PCI_SUBORDINATE_BUS_INSERT(x, tag)
162
163#if X_BYTE_ORDER == X_BIG_ENDIAN
164#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
165 ((val >> 8) & 0x0000ff00) | \
166 ((val << 8) & 0x00ff0000) | \
167 ((val << 24) & 0xff000000))
168#else
169#define PCI_CPU(val) (val)
170#endif
171
172/*
173 * Debug Macros/Definitions
174 */
175/* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
176
177#if defined(DEBUGPCI)
178
179# define PCITRACE(lvl,printfargs) \
180 if (lvl > xf86Verbose) { \
181 ErrorF printfargs; \
182 }
183
184#else /* !defined(DEBUGPCI) */
185
186# define PCITRACE(lvl,printfargs)
187
188#endif /* !defined(DEBUGPCI) */
189
190/*
191 * PCI Config mechanism definitions
192 */
193#define PCI_EN 0x80000000
194
195#define PCI_CFGMECH1_ADDRESS_REG 0xCF8
196#define PCI_CFGMECH1_DATA_REG 0xCFC
197
198#define PCI_CFGMECH1_MAXDEV 32
199
200/*
201 * Select architecture specific PCI init function
202 */
203#if defined(__alpha__)
204# if defined(linux)
205# define ARCH_PCI_INIT axpPciInit
206# define INCLUDE_XF86_MAP_PCI_MEM
207# elif defined(__FreeBSD__) || defined(__OpenBSD__)
208# define ARCH_PCI_INIT freebsdPciInit
209# define INCLUDE_XF86_MAP_PCI_MEM
210# define INCLUDE_XF86_NO_DOMAIN
211# elif defined(__NetBSD__)
212# define ARCH_PCI_INIT netbsdPciInit
213# define INCLUDE_XF86_MAP_PCI_MEM
214# define INCLUDE_XF86_NO_DOMAIN
215# endif
216#elif defined(__arm__)
217# if defined(linux)
218# define ARCH_PCI_INIT linuxPciInit
219# define INCLUDE_XF86_MAP_PCI_MEM
220# define INCLUDE_XF86_NO_DOMAIN
221# endif
222#elif defined(__hppa__)
223# if defined(linux)
224# define ARCH_PCI_INIT linuxPciInit
225# define INCLUDE_XF86_MAP_PCI_MEM
226# define INCLUDE_XF86_NO_DOMAIN
227# endif
228#elif defined(__ia64__)
229# if defined(linux)
230# define ARCH_PCI_INIT linuxPciInit
231# define INCLUDE_XF86_MAP_PCI_MEM
232# define INCLUDE_XF86_NO_DOMAIN
233# endif
234# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
235#elif defined(__i386__)
236# define ARCH_PCI_INIT ix86PciInit
237# define ARCH_PCI_HOST_BRIDGE ix86PciHostBridge
238# define INCLUDE_XF86_MAP_PCI_MEM
239# define INCLUDE_XF86_NO_DOMAIN
240# if defined(linux)
241# define ARCH_PCI_OS_INIT linuxPciInit
242# endif
243#elif defined(__mc68000__)
244# if defined(linux)
245# define ARCH_PCI_INIT linuxPciInit
246# define INCLUDE_XF86_MAP_PCI_MEM
247# define INCLUDE_XF86_NO_DOMAIN
248# endif
249#elif defined(__mips__)
250# if defined(linux)
251# define ARCH_PCI_INIT linuxPciInit
252# define INCLUDE_XF86_MAP_PCI_MEM
253# define INCLUDE_XF86_NO_DOMAIN
254# endif
255#elif defined(__powerpc__)
256# if defined(linux)
257# define ARCH_PCI_INIT linuxPciInit
258# define INCLUDE_XF86_MAP_PCI_MEM
259# define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */
260# elif defined(__OpenBSD__)
261# define ARCH_PCI_INIT freebsdPciInit
262# define INCLUDE_XF86_MAP_PCI_MEM
263# define INCLUDE_XF86_NO_DOMAIN
264# elif defined(__NetBSD__)
265# define ARCH_PCI_INIT netbsdPciInit
266# define INCLUDE_XF86_MAP_PCI_MEM
267# define INCLUDE_XF86_NO_DOMAIN
268# elif defined(PowerMAX_OS) /* This port is broken */
269# define ARCH_PCI_INIT ppcPciInit
270# else
271# define ARCH_PCI_INIT ppcPciInit
272# define INCLUDE_XF86_MAP_PCI_MEM
273# define INCLUDE_XF86_NO_DOMAIN
274# endif
275#elif defined(__s390__)
276# if defined(linux)
277# define ARCH_PCI_INIT linuxPciInit
278# define INCLUDE_XF86_MAP_PCI_MEM
279# define INCLUDE_XF86_NO_DOMAIN
280# endif
281#elif defined(__sh__)
282# if defined(linux)
283# define ARCH_PCI_INIT linuxPciInit
284# define INCLUDE_XF86_MAP_PCI_MEM
285# define INCLUDE_XF86_NO_DOMAIN
286# endif
287#elif defined(__sparc__)
288# if defined(linux)
289# define ARCH_PCI_INIT linuxPciInit
290# define INCLUDE_XF86_MAP_PCI_MEM
291# elif defined(sun)
292# define ARCH_PCI_INIT sparcPciInit
293# define INCLUDE_XF86_MAP_PCI_MEM
294# elif defined(__OpenBSD__) && defined(__sparc64__)
295# define ARCH_PCI_INIT freebsdPciInit
296# define INCLUDE_XF86_MAP_PCI_MEM
297# define INCLUDE_XF86_NO_DOMAIN
298# endif
299# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
300#elif defined(__x86_64__)
301# define ARCH_PCI_INIT ix86PciInit
302# define INCLUDE_XF86_MAP_PCI_MEM
303# define INCLUDE_XF86_NO_DOMAIN
304# if defined(linux)
305# define ARCH_PCI_OS_INIT linuxPciInit
306# endif
307#endif
308
309#ifndef ARCH_PCI_INIT
310#error No PCI support available for this architecture/OS combination
311#endif
312
313extern void ARCH_PCI_INIT(void);
314#if defined(ARCH_PCI_OS_INIT)
315extern void ARCH_PCI_OS_INIT(void);
316#endif
317
318#if defined(ARCH_PCI_HOST_BRIDGE)
319extern void ARCH_PCI_HOST_BRIDGE(pciConfigPtr pPCI);
320#endif
321
322#if defined(ARCH_PCI_PCI_BRIDGE)
323extern void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI);
324#endif
325
326#if defined(XF86SCANPCI_WRAPPER)
327typedef enum {
328 SCANPCI_INIT,
329 SCANPCI_TERM
330} scanpciWrapperOpt;
331extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
332#endif
333
334/*
335 * Table of functions used to access a specific PCI bus domain
336 * (e.g. a primary PCI bus and all of its secondaries)
337 */
338typedef struct pci_bus_funcs {
339 CARD32 (*pciReadLong)(PCITAG, int);
340 void (*pciWriteLong)(PCITAG, int, CARD32);
341 void (*pciSetBitsLong)(PCITAG, int, CARD32, CARD32);
342 ADDRESS (*pciAddrHostToBus)(PCITAG, PciAddrType, ADDRESS);
343 ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
344 /*
345 * The next three are optional. If NULL, the corresponding function is
346 * to be performed generically.
347 */
348 CARD16 (*pciControlBridge)(int, CARD16, CARD16);
349 void (*pciGetBridgeBusses)(int, int *, int *, int *);
350 /* Use pointer's to avoid #include recursion */
351 void (*pciGetBridgeResources)(int, pointer *, pointer *, pointer *);
352} pciBusFuncs_t, *pciBusFuncs_p;
353
354/*
355 * pciBusInfo_t - One structure per defined PCI bus
356 */
357typedef struct pci_bus_info {
358 unsigned char configMech; /* PCI config type to use */
359 unsigned char numDevices; /* Range of valid devnums */
360 unsigned char secondary; /* Boolean: bus is a secondary */
361 int primary_bus; /* Parent bus */
362#ifdef PowerMAX_OS
363 unsigned long ppc_io_base; /* PowerPC I/O spc membase */
364 unsigned long ppc_io_size; /* PowerPC I/O spc size */
365#endif
366 pciBusFuncs_p funcs; /* PCI access functions */
367 void *pciBusPriv; /* Implementation private data */
368 pciConfigPtr bridge; /* bridge that opens this bus */
369} pciBusInfo_t;
370
371#define HOST_NO_BUS ((pciBusInfo_t *)(-1))
372
373/* configMech values */
374#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
375#define PCI_CFG_MECH_1 1 /* Most machines */
376#define PCI_CFG_MECH_2 2 /* Older PC's */
377#define PCI_CFG_MECH_OTHER 3 /* Something else */
378
379/* Generic PCI service functions and helpers */
380PCITAG pciGenFindFirst(void);
381PCITAG pciGenFindNext(void);
382CARD32 pciCfgMech1Read(PCITAG tag, int offset);
383void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
384void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
385 CARD32 val);
386CARD32 pciByteSwap(CARD32);
387Bool pciMfDev(int, int);
388ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
389
390extern PCITAG (*pciFindFirstFP)(void);
391extern PCITAG (*pciFindNextFP)(void);
392
393extern CARD32 pciDevid;
394extern CARD32 pciDevidMask;
395
396extern int pciMaxBusNum;
397
398extern int pciBusNum;
399extern int pciDevNum;
400extern int pciFuncNum;
401extern PCITAG pciDeviceTag;
402
403extern pciBusInfo_t *pciBusInfo[];
404
405#endif /* _PCI_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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