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
|
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.3 2002/10/03 02:04:19 tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting documentation, and
* that the names of the copyright holders not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. The copyright holders make no representations
* about the suitability of this software for any purpose. It is provided "as
* is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
*/
#ifdef i386
#define _NEED_SYSI86
#endif
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
char *apertureDevName = NULL;
Bool
xf86LinearVidMem(void)
{
int mmapFd;
if (apertureDevName)
return TRUE;
apertureDevName = "/dev/xsvc";
if ((mmapFd = open(apertureDevName, O_RDWR)) < 0)
{
apertureDevName = "/dev/fbs/aperture";
if((mmapFd = open(apertureDevName, O_RDWR)) < 0)
{
xf86MsgVerb(X_WARNING, 0,
"xf86LinearVidMem: failed to open %s (%s)\n",
apertureDevName, strerror(errno));
xf86MsgVerb(X_WARNING, 0,
"xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc"
" device driver required\n");
xf86MsgVerb(X_WARNING, 0,
"xf86LinearVidMem: linear memory access disabled\n");
apertureDevName = NULL;
return FALSE;
}
}
close(mmapFd);
return TRUE;
}
pointer
xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
{
pointer base;
int fd;
char vtname[20];
/*
* Solaris 2.1 x86 SVR4 (10/27/93)
* The server must treat the virtual terminal device file as the
* standard SVR4 /dev/pmem.
*
* Using the /dev/vtXX device as /dev/pmem only works for the
* A0000-FFFFF region - If we wish you mmap the linear aperture
* it requires a device driver.
*
* So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and
* try to use the /dev/fbs/aperture or /dev/xsvc driver if the server
* tries to mmap anything > FFFFF. Its very very unlikely that the
* server will try to mmap anything below FFFFF that can't be handled
* by /dev/vtXX.
*
* DWH - 2/23/94
* DWH - 1/31/99 (Gee has it really been 5 years?)
*
* Solaris 2.8 7/26/99
* Use /dev/xsvc for everything
*
* DWH - 7/26/99 - Solaris8/dev/xsvc changes
*
* TSI - 2001.09 - SPARC changes
*/
#if defined(i386) && !defined(__SOL8__)
if(Base < 0xFFFFF)
sprintf(vtname, "/dev/vt%02d", xf86Info.vtno);
else
#endif
{
if (!xf86LinearVidMem())
FatalError("xf86MapVidMem: no aperture device\n");
strcpy(vtname, apertureDevName);
}
fd = open(vtname, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
if (fd < 0)
FatalError("xf86MapVidMem: failed to open %s (%s)\n",
vtname, strerror(errno));
base = mmap(NULL, Size,
(Flags & VIDMEM_READONLY) ?
PROT_READ : (PROT_READ | PROT_WRITE),
MAP_SHARED, fd, (off_t)Base);
close(fd);
if (base == MAP_FAILED)
FatalError("xf86MapVidMem: mmap failure: %s\n",
strerror(errno));
return(base);
}
/* ARGSUSED */
void
xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
munmap(Base, Size);
}
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
#ifdef i386
static Bool ExtendedEnabled = FALSE;
#endif
void
xf86EnableIO(void)
{
#ifdef i386
if (ExtendedEnabled)
return;
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n");
ExtendedEnabled = TRUE;
#endif /* i386 */
}
void
xf86DisableIO(void)
{
#ifdef i386
if(!ExtendedEnabled)
return;
sysi86(SI86V86, V86SC_IOPL, 0);
ExtendedEnabled = FALSE;
#endif /* i386 */
}
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
Bool xf86DisableInterrupts(void)
{
#ifdef i386
if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
return FALSE;
#ifdef __GNUC__
__asm__ __volatile__("cli");
#else
asm("cli");
#endif /* __GNUC__ */
if (!ExtendedEnabled)
sysi86(SI86V86, V86SC_IOPL, 0);
#endif /* i386 */
return TRUE;
}
void xf86EnableInterrupts(void)
{
#ifdef i386
if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
return;
#ifdef __GNUC__
__asm__ __volatile__("sti");
#else
asm("sti");
#endif /* __GNUC__ */
if (!ExtendedEnabled)
sysi86(SI86V86, V86SC_IOPL, 0);
#endif /* i386 */
}
void
xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
unsigned long Size)
{
}
Bool
xf86CheckMTRR(int ScreenNum)
{
return FALSE;
}
|