If we don't have a NEWAVIINDEX chunk, but have an OpenDML index,
[mplayer/greg.git] / libdha / sysdep / pci_lynx.c
blobb698f63083330563531261f81fcc1bedf365c01c
1 /*
2 This file is based on:
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
5 */
7 #if defined(Lynx_22)
8 #ifndef GCCUSESGAS
9 #define GCCUSESGAS
10 #endif
12 /* let's mimick the Linux Alpha stuff for LynxOS so we don't have
13 * to change too much code
15 #include <smem.h>
17 static unsigned char *pciConfBase;
19 static __inline__ void enable_os_io(void)
21 pciConfBase = (unsigned char *) smem_create("PCI-CONF",
22 (char *)0x80800000, 64*1024, SM_READ|SM_WRITE);
23 if (pciConfBase == (void *) -1)
24 exit(1);
27 static __inline__ void disable_os_io(void)
29 smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH);
30 smem_remove("PCI-CONF");
31 pciConfBase = NULL;
34 #include <smem.h>
36 static unsigned char *pciConfBase;
38 static __inline__ unsigned long
39 static swapl(unsigned long val)
41 unsigned char *p = (unsigned char *)&val;
42 return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0));
46 #define BUS(tag) (((tag)>>16)&0xff)
47 #define DFN(tag) (((tag)>>8)&0xff)
49 #define PCIBIOS_DEVICE_NOT_FOUND 0x86
50 #define PCIBIOS_SUCCESSFUL 0x00
52 static int pciconfig_read(
53 unsigned char bus,
54 unsigned char dev,
55 unsigned char offset,
56 int len, /* unused, alway 4 */
57 unsigned long *val)
59 unsigned long _val;
60 unsigned long *ptr;
62 dev >>= 3;
63 if (bus || dev >= 16) {
64 *val = 0xFFFFFFFF;
65 return PCIBIOS_DEVICE_NOT_FOUND;
66 } else {
67 ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
68 _val = swapl(*ptr);
70 *val = _val;
71 return PCIBIOS_SUCCESSFUL;
74 static int pciconfig_write(
75 unsigned char bus,
76 unsigned char dev,
77 unsigned char offset,
78 int len, /* unused, alway 4 */
79 unsigned long val)
81 unsigned long _val;
82 unsigned long *ptr;
84 dev >>= 3;
85 _val = swapl(val);
86 if (bus || dev >= 16) {
87 return PCIBIOS_DEVICE_NOT_FOUND;
88 } else {
89 ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
90 *ptr = _val;
92 return PCIBIOS_SUCCESSFUL;