1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
/*
* Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the XFree86 Project shall
* not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization from the
* XFree86 Project.
*/
/*
* This file contains the glue needed to support various IA-64 chipsets.
*/
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <linux/pci.h>
#include "compiler.h"
#include "460gxPCI.h"
#include "e8870PCI.h"
#include "zx1PCI.h"
#include "altixPCI.h"
#include "Pci.h"
#include "ia64Pci.h"
/*
* We use special in/out routines here since Altix platforms require the
* use of the sysfs legacy_io interface. The legacy_io file maps to the I/O
* space of a given PCI domain; reads and writes are used to do port I/O.
* The file descriptor for the file is stored in the upper bits of the
* value passed in by the caller, and is created and populated by
* xf86MapLegacyIO.
*
* If the legacy_io interface doesn't exist, we fall back to the glibc in/out
* routines, which are prefixed by an underscore (e.g. _outb).
*/
static int ia64_port_to_fd(unsigned long port)
{
return (port >> 24) & 0xffffffff;
}
_X_EXPORT void outb(unsigned long port, unsigned char val)
{
int fd = ia64_port_to_fd(port);
if (!fd) {
_outb(val, port & 0xffff);
goto out;
}
if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
ErrorF("I/O lseek failed\n");
goto out;
}
if (write(fd, &val, 1) != 1) {
ErrorF("I/O write failed\n");
goto out;
}
out:
return;
}
_X_EXPORT void outw(unsigned long port, unsigned short val)
{
int fd = ia64_port_to_fd(port);
if (!fd) {
_outw(val, port & 0xffff);
goto out;
}
if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
ErrorF("I/O lseek failed\n");
goto out;
}
if (write(fd, &val, 2) != 2) {
ErrorF("I/O write failed\n");
goto out;
}
out:
return;
}
_X_EXPORT void outl(unsigned long port, unsigned int val)
{
int fd = ia64_port_to_fd(port);
if (!fd) {
_outl(val, port & 0xffff);
goto out;
}
if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
ErrorF("I/O lseek failed\n");
goto out;
}
if (write(fd, &val, 4) != 4) {
ErrorF("I/O write failed\n");
goto out;
}
out:
return;
}
_X_EXPORT unsigned int inb(unsigned long port)
{
int fd = ia64_port_to_fd(port);
unsigned char val;
if (!fd)
return _inb(port & 0xffff);
if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
ErrorF("I/O lseek failed\n");
val = -1;
goto out;
}
if (read(fd, &val, 1) != 1) {
ErrorF("I/O read failed\n");
val = -1;
goto out;
}
out:
return val;
}
_X_EXPORT unsigned int inw(unsigned long port)
{
int fd = ia64_port_to_fd(port);
unsigned short val;
if (!fd)
return _inw(port & 0xffff);
if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
ErrorF("I/O lseek failed\n");
val = -1;
goto out;
}
if (read(fd, &val, 2) != 2) {
ErrorF("I/O read failed\n");
val = -1;
goto out;
}
out:
return val;
}
_X_EXPORT unsigned int inl(unsigned long port)
{
int fd = ia64_port_to_fd(port);
unsigned int val;
if (!fd)
return _inl(port & 0xffff);
if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
ErrorF("I/O lseek failed\n");
val = -1;
goto out;
}
if (read(fd, &val, 4) != 4) {
ErrorF("I/O read failed\n");
val = -1;
goto out;
}
out:
return val;
}
void
ia64ScanPCIWrapper(scanpciWrapperOpt flags)
{
static IA64Chipset chipset = NONE_CHIPSET;
if (flags == SCANPCI_INIT) {
/* PCI configuration space probes should be done first */
if (xorgProbe460GX(flags)) {
chipset = I460GX_CHIPSET;
xf86PreScan460GX();
return;
} else if (xorgProbeE8870(flags)) {
chipset = E8870_CHIPSET;
xf86PreScanE8870();
return;
}
#ifdef OS_PROBE_PCI_CHIPSET
chipset = OS_PROBE_PCI_CHIPSET(flags);
switch (chipset) {
case ZX1_CHIPSET:
xf86PreScanZX1();
return;
case ALTIX_CHIPSET:
xf86PreScanAltix();
return;
default:
return;
}
#endif
} else /* if (flags == SCANPCI_TERM) */ {
switch (chipset) {
case I460GX_CHIPSET:
xf86PostScan460GX();
return;
case E8870_CHIPSET:
xf86PostScanE8870();
return;
case ZX1_CHIPSET:
xf86PostScanZX1();
return;
case ALTIX_CHIPSET:
xf86PostScanAltix();
return;
default:
return;
}
}
}
|