rtsp_rtp.c: Add missing avstring include for av_strlcpy
[mplayer.git] / vidix / sysdep / pci_lynx.c
blobd24676ad1f1a7501e40c8d9be079498b26bb9739
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 */
6 /*
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
18 * implied warranty.
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.
29 #if defined(Lynx_22)
30 #ifndef GCCUSESGAS
31 #define GCCUSESGAS
32 #endif
34 /* let's mimick the Linux Alpha stuff for LynxOS so we don't have
35 * to change too much code
37 #include <smem.h>
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)
46 exit(1);
49 static __inline__ void disable_os_io(void)
51 smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH);
52 smem_remove("PCI-CONF");
53 pciConfBase = NULL;
56 #include <smem.h>
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(
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 if (bus || dev >= 16) {
86 *val = 0xFFFFFFFF;
87 return PCIBIOS_DEVICE_NOT_FOUND;
88 } else {
89 ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
90 _val = swapl(*ptr);
92 *val = _val;
93 return PCIBIOS_SUCCESSFUL;
96 static int pciconfig_write(
97 unsigned char bus,
98 unsigned char dev,
99 unsigned char offset,
100 int len, /* unused, alway 4 */
101 unsigned long val)
103 unsigned long _val;
104 unsigned long *ptr;
106 dev >>= 3;
107 _val = swapl(val);
108 if (bus || dev >= 16) {
109 return PCIBIOS_DEVICE_NOT_FOUND;
110 } else {
111 ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
112 *ptr = _val;
114 return PCIBIOS_SUCCESSFUL;