annotate libdha/sysdep/pci_lynx.c @ 16265:f0bd9bc9647b

gtk2 is supported, next step is pure gtk without X.
author reimar
date Thu, 18 Aug 2005 13:46:01 +0000
parents 2e3262002acb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4164
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
1 /*
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
2 This file is based on:
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
3 $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
4 Modified for readability by Nick Kurshev
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
5 */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
6
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
7 #if defined(Lynx_22)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
8 #ifndef GCCUSESGAS
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
9 #define GCCUSESGAS
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
10 #endif
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
11
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
12 /* let's mimick the Linux Alpha stuff for LynxOS so we don't have
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
13 * to change too much code
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
14 */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
15 #include <smem.h>
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
16
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
17 static unsigned char *pciConfBase;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
18
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
19 static __inline__ void enable_os_io(void)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
20 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
21 pciConfBase = (unsigned char *) smem_create("PCI-CONF",
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
22 (char *)0x80800000, 64*1024, SM_READ|SM_WRITE);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
23 if (pciConfBase == (void *) -1)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
24 exit(1);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
25 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
26
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
27 static __inline__ void disable_os_io(void)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
28 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
29 smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
30 smem_remove("PCI-CONF");
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
31 pciConfBase = NULL;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
32 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
33
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
34 #include <smem.h>
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
35
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
36 static unsigned char *pciConfBase;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
37
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
38 static __inline__ unsigned long
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
39 static swapl(unsigned long val)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
40 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
41 unsigned char *p = (unsigned char *)&val;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
42 return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0));
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
43 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
44
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
45
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
46 #define BUS(tag) (((tag)>>16)&0xff)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
47 #define DFN(tag) (((tag)>>8)&0xff)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
48
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
49 #define PCIBIOS_DEVICE_NOT_FOUND 0x86
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
50 #define PCIBIOS_SUCCESSFUL 0x00
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
51
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
52 static int pciconfig_read(
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
53 unsigned char bus,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
54 unsigned char dev,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
55 unsigned char offset,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
56 int len, /* unused, alway 4 */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
57 unsigned long *val)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
58 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
59 unsigned long _val;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
60 unsigned long *ptr;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
61
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
62 dev >>= 3;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
63 if (bus || dev >= 16) {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
64 *val = 0xFFFFFFFF;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
65 return PCIBIOS_DEVICE_NOT_FOUND;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
66 } else {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
67 ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
68 _val = swapl(*ptr);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
69 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
70 *val = _val;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
71 return PCIBIOS_SUCCESSFUL;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
72 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
73
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
74 static int pciconfig_write(
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
75 unsigned char bus,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
76 unsigned char dev,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
77 unsigned char offset,
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
78 int len, /* unused, alway 4 */
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
79 unsigned long val)
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
80 {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
81 unsigned long _val;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
82 unsigned long *ptr;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
83
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
84 dev >>= 3;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
85 _val = swapl(val);
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
86 if (bus || dev >= 16) {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
87 return PCIBIOS_DEVICE_NOT_FOUND;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
88 } else {
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
89 ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset));
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
90 *ptr = _val;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
91 }
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
92 return PCIBIOS_SUCCESSFUL;
2e3262002acb Improved readability and new stuffs
nick
parents:
diff changeset
93 }