Mercurial > mplayer.hg
annotate vidix/sysdep/pci_lynx.c @ 30417:892f4b4e1d5f
license header cosmetics
author | diego |
---|---|
date | Sat, 30 Jan 2010 13:46:26 +0000 |
parents | 0f1b5b68af32 |
children | 958431e2cde0 |
rev | line source |
---|---|
4164 | 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 */ | |
25132
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
6 /* |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
7 * Copyright 1995 by Robin Cutshaw <robin@XFree86.Org> |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
8 * |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
9 * Permission to use, copy, modify, distribute, and sell this software and its |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
10 * documentation for any purpose is hereby granted without fee, provided that |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
11 * the above copyright notice appear in all copies and that both that |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
12 * copyright notice and this permission notice appear in supporting |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
13 * documentation, and that the names of the above listed copyright holder(s) |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
14 * not be used in advertising or publicity pertaining to distribution of |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
15 * the software without specific, written prior permission. The above listed |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
16 * copyright holder(s) make(s) no representations about the suitability of this |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
17 * software for any purpose. It is provided "as is" without express or |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
18 * implied warranty. |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
19 * |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
20 * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
21 * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
22 * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
23 * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
24 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
25 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
26 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
9c4ad35fabc5
Restore copyright/license notices that were stripped off.
diego
parents:
22900
diff
changeset
|
27 */ |
4164 | 28 |
29 #if defined(Lynx_22) | |
30 #ifndef GCCUSESGAS | |
31 #define GCCUSESGAS | |
32 #endif | |
33 | |
34 /* let's mimick the Linux Alpha stuff for LynxOS so we don't have | |
35 * to change too much code | |
36 */ | |
37 #include <smem.h> | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
38 |
4164 | 39 static unsigned char *pciConfBase; |
40 | |
41 static __inline__ void enable_os_io(void) | |
42 { | |
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); | |
47 } | |
48 | |
49 static __inline__ void disable_os_io(void) | |
50 { | |
51 smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH); | |
52 smem_remove("PCI-CONF"); | |
53 pciConfBase = NULL; | |
54 } | |
55 | |
56 #include <smem.h> | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
57 |
4164 | 58 static unsigned char *pciConfBase; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
59 |
4164 | 60 static __inline__ unsigned long |
61 static swapl(unsigned long val) | |
62 { | |
63 unsigned char *p = (unsigned char *)&val; | |
26753
502f04b67653
cosmetics: Remove useless parentheses from return statements.
diego
parents:
25132
diff
changeset
|
64 return (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0); |
4164 | 65 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
66 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
67 |
4164 | 68 #define BUS(tag) (((tag)>>16)&0xff) |
69 #define DFN(tag) (((tag)>>8)&0xff) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
70 |
4164 | 71 #define PCIBIOS_DEVICE_NOT_FOUND 0x86 |
72 #define PCIBIOS_SUCCESSFUL 0x00 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
73 |
4164 | 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) | |
80 { | |
81 unsigned long _val; | |
82 unsigned long *ptr; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
83 |
4164 | 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); | |
91 } | |
92 *val = _val; | |
93 return PCIBIOS_SUCCESSFUL; | |
94 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
95 |
4164 | 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) | |
102 { | |
103 unsigned long _val; | |
104 unsigned long *ptr; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26753
diff
changeset
|
105 |
4164 | 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; | |
113 } | |
114 return PCIBIOS_SUCCESSFUL; | |
115 } |