3 $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
4 Modified for readability by Nick Kurshev
7 * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
9 * Permission to use, copy, modify, distribute, and sell this software and its
10 * documentation for any purpose is hereby granted without fee, provided that
11 * the above copyright notice appear in all copies and that both that
12 * copyright notice and this permission notice appear in supporting
13 * documentation, and that the names of the above listed copyright holder(s)
14 * not be used in advertising or publicity pertaining to distribution of
15 * the software without specific, written prior permission. The above listed
16 * copyright holder(s) make(s) no representations about the suitability of this
17 * software for any purpose. It is provided "as is" without express or
20 * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
21 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22 * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
23 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
24 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
25 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
26 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34 /* let's mimick the Linux Alpha stuff for LynxOS so we don't have
35 * to change too much code
39 static unsigned char *pciConfBase
;
41 static __inline__
void enable_os_io(void)
43 pciConfBase
= (unsigned char *) smem_create("PCI-CONF",
44 (char *)0x80800000, 64*1024, SM_READ
|SM_WRITE
);
45 if (pciConfBase
== (void *) -1)
49 static __inline__
void disable_os_io(void)
51 smem_create(NULL
, (char *) pciConfBase
, 0, SM_DETACH
);
52 smem_remove("PCI-CONF");
58 static unsigned char *pciConfBase
;
60 static __inline__
unsigned long
61 static swapl(unsigned long val
)
63 unsigned char *p
= (unsigned char *)&val
;
64 return (p
[3] << 24) | (p
[2] << 16) | (p
[1] << 8) | (p
[0] << 0);
68 #define BUS(tag) (((tag)>>16)&0xff)
69 #define DFN(tag) (((tag)>>8)&0xff)
71 #define PCIBIOS_DEVICE_NOT_FOUND 0x86
72 #define PCIBIOS_SUCCESSFUL 0x00
74 static int pciconfig_read(
78 int len
, /* unused, alway 4 */
85 if (bus
|| dev
>= 16) {
87 return PCIBIOS_DEVICE_NOT_FOUND
;
89 ptr
= (unsigned long *)(pciConfBase
+ ((1<<dev
) | offset
));
93 return PCIBIOS_SUCCESSFUL
;
96 static int pciconfig_write(
100 int len
, /* unused, alway 4 */
108 if (bus
|| dev
>= 16) {
109 return PCIBIOS_DEVICE_NOT_FOUND
;
111 ptr
= (unsigned long *)(pciConfBase
+ ((1<<dev
) | offset
));
114 return PCIBIOS_SUCCESSFUL
;