xref: /OK3568_Linux_fs/external/xserver/hw/xfree86/os-support/bus/Pci.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright 1998 by Concurrent Computer Corporation
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission to use, copy, modify, distribute, and sell this software
5*4882a593Smuzhiyun  * and its documentation for any purpose is hereby granted without fee,
6*4882a593Smuzhiyun  * provided that the above copyright notice appear in all copies and that
7*4882a593Smuzhiyun  * both that copyright notice and this permission notice appear in
8*4882a593Smuzhiyun  * supporting documentation, and that the name of Concurrent Computer
9*4882a593Smuzhiyun  * Corporation not be used in advertising or publicity pertaining to
10*4882a593Smuzhiyun  * distribution of the software without specific, written prior
11*4882a593Smuzhiyun  * permission.  Concurrent Computer Corporation makes no representations
12*4882a593Smuzhiyun  * about the suitability of this software for any purpose.  It is
13*4882a593Smuzhiyun  * provided "as is" without express or implied warranty.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
16*4882a593Smuzhiyun  * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17*4882a593Smuzhiyun  * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
18*4882a593Smuzhiyun  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
19*4882a593Smuzhiyun  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20*4882a593Smuzhiyun  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
21*4882a593Smuzhiyun  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
22*4882a593Smuzhiyun  * SOFTWARE.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * Copyright 1998 by Metro Link Incorporated
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  * Permission to use, copy, modify, distribute, and sell this software
27*4882a593Smuzhiyun  * and its documentation for any purpose is hereby granted without fee,
28*4882a593Smuzhiyun  * provided that the above copyright notice appear in all copies and that
29*4882a593Smuzhiyun  * both that copyright notice and this permission notice appear in
30*4882a593Smuzhiyun  * supporting documentation, and that the name of Metro Link
31*4882a593Smuzhiyun  * Incorporated not be used in advertising or publicity pertaining to
32*4882a593Smuzhiyun  * distribution of the software without specific, written prior
33*4882a593Smuzhiyun  * permission.  Metro Link Incorporated makes no representations
34*4882a593Smuzhiyun  * about the suitability of this software for any purpose.  It is
35*4882a593Smuzhiyun  * provided "as is" without express or implied warranty.
36*4882a593Smuzhiyun  *
37*4882a593Smuzhiyun  * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
38*4882a593Smuzhiyun  * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
39*4882a593Smuzhiyun  * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
40*4882a593Smuzhiyun  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
41*4882a593Smuzhiyun  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42*4882a593Smuzhiyun  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43*4882a593Smuzhiyun  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44*4882a593Smuzhiyun  * SOFTWARE.
45*4882a593Smuzhiyun  *
46*4882a593Smuzhiyun  * This file is derived in part from the original xf86_PCI.h that included
47*4882a593Smuzhiyun  * following copyright message:
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
50*4882a593Smuzhiyun  *
51*4882a593Smuzhiyun  * Permission to use, copy, modify, distribute, and sell this software and its
52*4882a593Smuzhiyun  * documentation for any purpose is hereby granted without fee, provided that
53*4882a593Smuzhiyun  * the above copyright notice appear in all copies and that both that
54*4882a593Smuzhiyun  * copyright notice and this permission notice appear in supporting
55*4882a593Smuzhiyun  * documentation, and that the names of the above listed copyright holder(s)
56*4882a593Smuzhiyun  * not be used in advertising or publicity pertaining to distribution of
57*4882a593Smuzhiyun  * the software without specific, written prior permission.  The above listed
58*4882a593Smuzhiyun  * copyright holder(s) make(s) no representations about the suitability of this
59*4882a593Smuzhiyun  * software for any purpose.  It is provided "as is" without express or
60*4882a593Smuzhiyun  * implied warranty.
61*4882a593Smuzhiyun  *
62*4882a593Smuzhiyun  * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
63*4882a593Smuzhiyun  * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
64*4882a593Smuzhiyun  * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
65*4882a593Smuzhiyun  * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
66*4882a593Smuzhiyun  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
67*4882a593Smuzhiyun  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
68*4882a593Smuzhiyun  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
69*4882a593Smuzhiyun  *
70*4882a593Smuzhiyun  */
71*4882a593Smuzhiyun /*
72*4882a593Smuzhiyun  * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
73*4882a593Smuzhiyun  *
74*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
75*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
76*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
77*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
78*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
79*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
80*4882a593Smuzhiyun  *
81*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included in
82*4882a593Smuzhiyun  * all copies or substantial portions of the Software.
83*4882a593Smuzhiyun  *
84*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
85*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
86*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
87*4882a593Smuzhiyun  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
88*4882a593Smuzhiyun  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
89*4882a593Smuzhiyun  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
90*4882a593Smuzhiyun  * OTHER DEALINGS IN THE SOFTWARE.
91*4882a593Smuzhiyun  *
92*4882a593Smuzhiyun  * Except as contained in this notice, the name of the copyright holder(s)
93*4882a593Smuzhiyun  * and author(s) shall not be used in advertising or otherwise to promote
94*4882a593Smuzhiyun  * the sale, use or other dealings in this Software without prior written
95*4882a593Smuzhiyun  * authorization from the copyright holder(s) and author(s).
96*4882a593Smuzhiyun  */
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /*
99*4882a593Smuzhiyun  * This file has the private Pci definitions.  The public ones are imported
100*4882a593Smuzhiyun  * from xf86Pci.h.  Drivers should not use this file.
101*4882a593Smuzhiyun  */
102*4882a593Smuzhiyun #ifdef HAVE_XORG_CONFIG_H
103*4882a593Smuzhiyun #include <xorg-config.h>
104*4882a593Smuzhiyun #endif
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun #ifndef _PCI_H
107*4882a593Smuzhiyun #define _PCI_H 1
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun #include "xf86Pci.h"
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun /*
112*4882a593Smuzhiyun  * Global Definitions
113*4882a593Smuzhiyun  */
114*4882a593Smuzhiyun #if (defined(__alpha__) || defined(__ia64__)) && defined (__linux__)
115*4882a593Smuzhiyun #define PCI_DOM_MASK	0x01fful
116*4882a593Smuzhiyun #else
117*4882a593Smuzhiyun #define PCI_DOM_MASK 0x0ffu
118*4882a593Smuzhiyun #endif
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun #ifndef PCI_DOM_MASK
121*4882a593Smuzhiyun #define PCI_DOM_MASK 0x0ffu
122*4882a593Smuzhiyun #endif
123*4882a593Smuzhiyun #define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
124*4882a593Smuzhiyun 
125*4882a593Smuzhiyun /*
126*4882a593Smuzhiyun  * "b" contains an optional domain number.
127*4882a593Smuzhiyun  */
128*4882a593Smuzhiyun #define PCI_MAKE_TAG(b,d,f)  ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
129*4882a593Smuzhiyun 			      (((d) & 0x00001fu) << 11) | \
130*4882a593Smuzhiyun 			      (((f) & 0x000007u) << 8))
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun #define PCI_MAKE_BUS(d,b)    ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun #define PCI_DOM_FROM_BUS(bus)  (((bus) >> 8) & (PCI_DOM_MASK))
135*4882a593Smuzhiyun #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
136*4882a593Smuzhiyun #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun #if defined(__linux__)
139*4882a593Smuzhiyun #define osPciInit(x) do {} while (0)
140*4882a593Smuzhiyun #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
141*4882a593Smuzhiyun 	defined(__OpenBSD__) || defined(__NetBSD__) || \
142*4882a593Smuzhiyun 	defined(__DragonFly__) || defined(__sun) || defined(__GNU__)
143*4882a593Smuzhiyun extern void osPciInit(void);
144*4882a593Smuzhiyun #else
145*4882a593Smuzhiyun #error No PCI support available for this architecture/OS combination
146*4882a593Smuzhiyun #endif
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun #endif                          /* _PCI_H */
149