1 | /*
|
---|
2 | * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
|
---|
3 | * Copyright 1992 by David Dawes <[email protected]>
|
---|
4 | * Copyright 1992 by Jim Tsillas <[email protected]>
|
---|
5 | * Copyright 1992 by Rich Murphey <[email protected]>
|
---|
6 | * Copyright 1992 by Robert Baron <[email protected]>
|
---|
7 | * Copyright 1992 by Orest Zborowski <[email protected]>
|
---|
8 | * Copyright 1993 by Vrije Universiteit, The Netherlands
|
---|
9 | * Copyright 1993 by David Wexelblat <[email protected]>
|
---|
10 | * Copyright 1994, 1996 by Holger Veit <[email protected]>
|
---|
11 | * Copyright 1997 by Takis Psarogiannakopoulos <[email protected]>
|
---|
12 | * Copyright 1994-2003 by The XFree86 Project, Inc
|
---|
13 | *
|
---|
14 | * Permission to use, copy, modify, distribute, and sell this software and its
|
---|
15 | * documentation for any purpose is hereby granted without fee, provided that
|
---|
16 | * the above copyright notice appear in all copies and that both that
|
---|
17 | * copyright notice and this permission notice appear in supporting
|
---|
18 | * documentation, and that the names of the above listed copyright holders
|
---|
19 | * not be used in advertising or publicity pertaining to distribution of
|
---|
20 | * the software without specific, written prior permission. The above listed
|
---|
21 | * copyright holders make no representations about the suitability of this
|
---|
22 | * software for any purpose. It is provided "as is" without express or
|
---|
23 | * implied warranty.
|
---|
24 | *
|
---|
25 | * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
|
---|
26 | * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
27 | * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE
|
---|
28 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
---|
29 | * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
---|
30 | * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
---|
31 | * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
---|
32 | *
|
---|
33 | */
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * The ARM32 code here carries the following copyright:
|
---|
37 | *
|
---|
38 | * Copyright 1997
|
---|
39 | * Digital Equipment Corporation. All rights reserved.
|
---|
40 | * This software is furnished under license and may be used and copied only in
|
---|
41 | * accordance with the following terms and conditions. Subject to these
|
---|
42 | * conditions, you may download, copy, install, use, modify and distribute
|
---|
43 | * this software in source and/or binary form. No title or ownership is
|
---|
44 | * transferred hereby.
|
---|
45 | *
|
---|
46 | * 1) Any source code used, modified or distributed must reproduce and retain
|
---|
47 | * this copyright notice and list of conditions as they appear in the
|
---|
48 | * source file.
|
---|
49 | *
|
---|
50 | * 2) No right is granted to use any trade name, trademark, or logo of Digital
|
---|
51 | * Equipment Corporation. Neither the "Digital Equipment Corporation"
|
---|
52 | * name nor any trademark or logo of Digital Equipment Corporation may be
|
---|
53 | * used to endorse or promote products derived from this software without
|
---|
54 | * the prior written permission of Digital Equipment Corporation.
|
---|
55 | *
|
---|
56 | * 3) This software is provided "AS-IS" and any express or implied warranties,
|
---|
57 | * including but not limited to, any implied warranties of merchantability,
|
---|
58 | * fitness for a particular purpose, or non-infringement are disclaimed.
|
---|
59 | * In no event shall DIGITAL be liable for any damages whatsoever, and in
|
---|
60 | * particular, DIGITAL shall not be liable for special, indirect,
|
---|
61 | * consequential, or incidental damages or damages for lost profits, loss
|
---|
62 | * of revenue or loss of use, whether such damages arise in contract,
|
---|
63 | * negligence, tort, under statute, in equity, at law or otherwise, even
|
---|
64 | * if advised of the possibility of such damage.
|
---|
65 | *
|
---|
66 | */
|
---|
67 |
|
---|
68 | /*
|
---|
69 | * This is private, and should not be included by any drivers. Drivers
|
---|
70 | * may include xf86_OSproc.h to get prototypes for public interfaces.
|
---|
71 | */
|
---|
72 |
|
---|
73 | #ifndef _XF86_OSLIB_H
|
---|
74 | #define _XF86_OSLIB_H
|
---|
75 |
|
---|
76 | #include <X11/Xos.h>
|
---|
77 | #include <X11/Xfuncproto.h>
|
---|
78 |
|
---|
79 | #include <stdio.h>
|
---|
80 | #include <ctype.h>
|
---|
81 | #include <stddef.h>
|
---|
82 |
|
---|
83 | /**************************************************************************/
|
---|
84 | /* SYSV386 (SVR3, SVR4), including Solaris */
|
---|
85 | /**************************************************************************/
|
---|
86 | #if (defined(SYSV) || defined(SVR4)) && \
|
---|
87 | (defined(sun) || defined(__i386__))
|
---|
88 | # ifdef SCO325
|
---|
89 | # ifndef _SVID3
|
---|
90 | # define _SVID3
|
---|
91 | # endif
|
---|
92 | # ifndef _NO_STATIC
|
---|
93 | # define _NO_STATIC
|
---|
94 | # endif
|
---|
95 | # endif
|
---|
96 | # include <sys/ioctl.h>
|
---|
97 | # include <signal.h>
|
---|
98 | # include <termio.h>
|
---|
99 | # include <sys/stat.h>
|
---|
100 | # include <sys/types.h>
|
---|
101 | # if defined(__SCO__)
|
---|
102 | # include <sys/param.h>
|
---|
103 | # endif
|
---|
104 |
|
---|
105 |
|
---|
106 | # include <errno.h>
|
---|
107 |
|
---|
108 | # if defined(_NEED_SYSI86)
|
---|
109 | # if !(defined (sun) && defined (SVR4))
|
---|
110 | # include <sys/immu.h>
|
---|
111 | # include <sys/region.h>
|
---|
112 | # endif
|
---|
113 | # include <sys/proc.h>
|
---|
114 | # include <sys/tss.h>
|
---|
115 | # include <sys/sysi86.h>
|
---|
116 | # if defined(SVR4) && !defined(sun)
|
---|
117 | # include <sys/seg.h>
|
---|
118 | # endif /* SVR4 && !sun */
|
---|
119 | /* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */
|
---|
120 | # if !defined(V86SC_IOPL) /* Solaris 7 or later? */
|
---|
121 | # include <sys/v86.h> /* Nope */
|
---|
122 | # endif
|
---|
123 | # if defined(sun) && (defined (__i386__) || defined(__i386) || defined(__x86)) && defined (SVR4)
|
---|
124 | # include <sys/psw.h>
|
---|
125 | # endif
|
---|
126 | # endif /* _NEED_SYSI86 */
|
---|
127 |
|
---|
128 | # if defined(HAS_SVR3_MMAPDRV)
|
---|
129 | # include <sys/sysmacros.h>
|
---|
130 | # if !defined(_NEED_SYSI86)
|
---|
131 | # include <sys/immu.h>
|
---|
132 | # include <sys/region.h>
|
---|
133 | # endif
|
---|
134 | # include <sys/mmap.h> /* MMAP driver header */
|
---|
135 | # endif
|
---|
136 |
|
---|
137 | # if !defined(sun) || defined(HAVE_SYS_VT_H)
|
---|
138 | # define HAS_USL_VTS
|
---|
139 | # endif
|
---|
140 | # if !defined(sun)
|
---|
141 | # include <sys/emap.h>
|
---|
142 | # endif
|
---|
143 | # if defined(SCO325)
|
---|
144 | # include <sys/vtkd.h>
|
---|
145 | # include <sys/console.h>
|
---|
146 | # include <sys/scankbd.h>
|
---|
147 | # include <sys/vid.h>
|
---|
148 | # define LED_CAP CLKED
|
---|
149 | # define LED_NUM NLKED
|
---|
150 | # define LED_SCR SLKED
|
---|
151 | # elif defined(HAS_USL_VTS)
|
---|
152 | # if !defined(sun)
|
---|
153 | # include <sys/at_ansi.h>
|
---|
154 | # endif
|
---|
155 | # include <sys/kd.h>
|
---|
156 | # include <sys/vt.h>
|
---|
157 | # endif
|
---|
158 |
|
---|
159 | # if defined(sun)
|
---|
160 | # include <sys/fbio.h>
|
---|
161 | # include <sys/kbd.h>
|
---|
162 | # include <sys/kbio.h>
|
---|
163 |
|
---|
164 | /* undefine symbols from <sys/kbd.h> we don't need that conflict with enum
|
---|
165 | definitions in parser/xf86tokens.h */
|
---|
166 | # undef STRING
|
---|
167 | # undef LEFTALT
|
---|
168 | # undef RIGHTALT
|
---|
169 |
|
---|
170 | # define LED_CAP LED_CAPS_LOCK
|
---|
171 | # define LED_NUM LED_NUM_LOCK
|
---|
172 | # define LED_SCR LED_SCROLL_LOCK
|
---|
173 | # define LED_COMP LED_COMPOSE
|
---|
174 | # endif /* sun */
|
---|
175 |
|
---|
176 | # if !defined(VT_ACKACQ)
|
---|
177 | # define VT_ACKACQ 2
|
---|
178 | # endif /* !VT_ACKACQ */
|
---|
179 |
|
---|
180 | # if defined(__SCO__)
|
---|
181 | # include <sys/sysmacros.h>
|
---|
182 | # define POSIX_TTY
|
---|
183 | # endif /* __SCO__ */
|
---|
184 |
|
---|
185 | # if defined(SVR4) || defined(SCO325)
|
---|
186 | # include <sys/mman.h>
|
---|
187 | # if !(defined(sun) && defined (SVR4))
|
---|
188 | # define DEV_MEM "/dev/pmem"
|
---|
189 | # endif
|
---|
190 | # ifdef SCO325
|
---|
191 | # undef DEV_MEM
|
---|
192 | # define DEV_MEM "/dev/mem"
|
---|
193 | # endif
|
---|
194 | # define CLEARDTR_SUPPORT
|
---|
195 | # define POSIX_TTY
|
---|
196 | # endif /* SVR4 */
|
---|
197 |
|
---|
198 |
|
---|
199 | # if defined(sun) && defined(HAS_USL_VTS)
|
---|
200 | # define USE_VT_SYSREQ
|
---|
201 | # endif
|
---|
202 |
|
---|
203 | #endif /* (SYSV || SVR4) */
|
---|
204 |
|
---|
205 | /**************************************************************************/
|
---|
206 | /* Linux or Glibc-based system */
|
---|
207 | /**************************************************************************/
|
---|
208 | #if defined(__linux__) || defined(__GLIBC__)
|
---|
209 | # include <sys/ioctl.h>
|
---|
210 | # include <signal.h>
|
---|
211 | # include <stdlib.h>
|
---|
212 | # include <sys/types.h>
|
---|
213 | # include <assert.h>
|
---|
214 |
|
---|
215 | # ifdef __linux__
|
---|
216 | # include <termio.h>
|
---|
217 | # else /* __GLIBC__ */
|
---|
218 | # include <termios.h>
|
---|
219 | # endif
|
---|
220 | # ifdef __sparc__
|
---|
221 | # include <sys/param.h>
|
---|
222 | # endif
|
---|
223 |
|
---|
224 | # include <errno.h>
|
---|
225 |
|
---|
226 | # include <sys/stat.h>
|
---|
227 |
|
---|
228 | # include <sys/mman.h>
|
---|
229 | # ifdef __linux__
|
---|
230 | # define HAS_USL_VTS
|
---|
231 | # include <sys/kd.h>
|
---|
232 | # include <sys/vt.h>
|
---|
233 | # define LDGMAP GIO_SCRNMAP
|
---|
234 | # define LDSMAP PIO_SCRNMAP
|
---|
235 | # define LDNMAP LDSMAP
|
---|
236 | # define CLEARDTR_SUPPORT
|
---|
237 | # define USE_VT_SYSREQ
|
---|
238 | # endif
|
---|
239 |
|
---|
240 | # define POSIX_TTY
|
---|
241 |
|
---|
242 | #endif /* __linux__ || __GLIBC__ */
|
---|
243 |
|
---|
244 | /**************************************************************************/
|
---|
245 | /* 386BSD and derivatives, BSD/386 */
|
---|
246 | /**************************************************************************/
|
---|
247 |
|
---|
248 | #if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
|
---|
249 | # undef __386BSD__
|
---|
250 | #endif
|
---|
251 |
|
---|
252 | #ifdef CSRG_BASED
|
---|
253 | # include <sys/ioctl.h>
|
---|
254 | # include <signal.h>
|
---|
255 |
|
---|
256 | # include <termios.h>
|
---|
257 | # define termio termios
|
---|
258 | # define POSIX_TTY
|
---|
259 |
|
---|
260 | # include <errno.h>
|
---|
261 |
|
---|
262 | # include <sys/types.h>
|
---|
263 | # include <sys/mman.h>
|
---|
264 | # include <sys/stat.h>
|
---|
265 |
|
---|
266 | # if defined(__bsdi__)
|
---|
267 | # include <sys/param.h>
|
---|
268 | # if (_BSDI_VERSION < 199510)
|
---|
269 | # include <i386/isa/vgaioctl.h>
|
---|
270 | # endif
|
---|
271 | # endif /* __bsdi__ */
|
---|
272 |
|
---|
273 | #endif /* CSRG_BASED */
|
---|
274 |
|
---|
275 | /**************************************************************************/
|
---|
276 | /* Kernel of *BSD */
|
---|
277 | /**************************************************************************/
|
---|
278 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
|
---|
279 | defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__)
|
---|
280 |
|
---|
281 | # include <sys/param.h>
|
---|
282 | # if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version)
|
---|
283 | # define __FreeBSD_kernel_version __FreeBSD_version
|
---|
284 | # endif
|
---|
285 |
|
---|
286 | # if !defined(LINKKIT)
|
---|
287 | /* Don't need this stuff for the Link Kit */
|
---|
288 | # if defined(__bsdi__)
|
---|
289 | # include <i386/isa/pcconsioctl.h>
|
---|
290 | # define CONSOLE_X_MODE_ON PCCONIOCRAW
|
---|
291 | # define CONSOLE_X_MODE_OFF PCCONIOCCOOK
|
---|
292 | # define CONSOLE_X_BELL PCCONIOCBEEP
|
---|
293 | # else /* __bsdi__ */
|
---|
294 | # if defined(__OpenBSD__)
|
---|
295 | # ifdef PCCONS_SUPPORT
|
---|
296 | # include <machine/pccons.h>
|
---|
297 | # undef CONSOLE_X_MODE_ON
|
---|
298 | # undef CONSOLE_X_MODE_OFF
|
---|
299 | # undef CONSOLE_X_BELL
|
---|
300 | # endif
|
---|
301 | # endif
|
---|
302 | # ifdef SYSCONS_SUPPORT
|
---|
303 | # define COMPAT_SYSCONS
|
---|
304 | # if defined(__NetBSD__) || defined(__OpenBSD__)
|
---|
305 | # include <machine/console.h>
|
---|
306 | # else
|
---|
307 | # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
---|
308 | # if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000)
|
---|
309 | # include <sys/consio.h>
|
---|
310 | # include <sys/kbio.h>
|
---|
311 | # else
|
---|
312 | # include <machine/console.h>
|
---|
313 | # endif /* FreeBSD 4.1 RELEASE or lator */
|
---|
314 | # else
|
---|
315 | # include <sys/console.h>
|
---|
316 | # endif
|
---|
317 | # endif
|
---|
318 | # endif /* SYSCONS_SUPPORT */
|
---|
319 | # if defined(PCVT_SUPPORT)
|
---|
320 | # if !defined(SYSCONS_SUPPORT)
|
---|
321 | /* no syscons, so include pcvt specific header file */
|
---|
322 | # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
---|
323 | # include <machine/pcvt_ioctl.h>
|
---|
324 | # else
|
---|
325 | # if defined(__NetBSD__) || defined(__OpenBSD__)
|
---|
326 | # if !defined(WSCONS_SUPPORT)
|
---|
327 | # include <machine/pcvt_ioctl.h>
|
---|
328 | # endif /* WSCONS_SUPPORT */
|
---|
329 | # else
|
---|
330 | # include <sys/pcvt_ioctl.h>
|
---|
331 | # endif /* __NetBSD__ */
|
---|
332 | # endif /* __FreeBSD_kernel__ || __OpenBSD__ */
|
---|
333 | # else /* pcvt and syscons: hard-code the ID magic */
|
---|
334 | # define VGAPCVTID _IOWR('V',113, struct pcvtid)
|
---|
335 | struct pcvtid {
|
---|
336 | char name[16];
|
---|
337 | int rmajor, rminor;
|
---|
338 | };
|
---|
339 | # endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */
|
---|
340 | # endif /* PCVT_SUPPORT */
|
---|
341 | # ifdef WSCONS_SUPPORT
|
---|
342 | # include <dev/wscons/wsconsio.h>
|
---|
343 | # include <dev/wscons/wsdisplay_usl_io.h>
|
---|
344 | # endif /* WSCONS_SUPPORT */
|
---|
345 | # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
|
---|
346 | # if defined(__FreeBSD_kernel_version) && (__FreeBSD_kernel_version >= 500013)
|
---|
347 | # include <sys/mouse.h>
|
---|
348 | # else
|
---|
349 | # undef MOUSE_GETINFO
|
---|
350 | # include <machine/mouse.h>
|
---|
351 | # endif
|
---|
352 | # endif
|
---|
353 | /* Include these definitions in case ioctl_pc.h didn't get included */
|
---|
354 | # ifndef CONSOLE_X_MODE_ON
|
---|
355 | # define CONSOLE_X_MODE_ON _IO('t',121)
|
---|
356 | # endif
|
---|
357 | # ifndef CONSOLE_X_MODE_OFF
|
---|
358 | # define CONSOLE_X_MODE_OFF _IO('t',122)
|
---|
359 | # endif
|
---|
360 | # ifndef CONSOLE_X_BELL
|
---|
361 | # define CONSOLE_X_BELL _IOW('t',123,int[2])
|
---|
362 | # endif
|
---|
363 | # ifndef CONSOLE_X_TV_ON
|
---|
364 | # define CONSOLE_X_TV_ON _IOW('t',155,int)
|
---|
365 | # define XMODE_RGB 0
|
---|
366 | # define XMODE_NTSC 1
|
---|
367 | # define XMODE_PAL 2
|
---|
368 | # define XMODE_SECAM 3
|
---|
369 | # endif
|
---|
370 | # ifndef CONSOLE_X_TV_OFF
|
---|
371 | # define CONSOLE_X_TV_OFF _IO('t',156)
|
---|
372 | # endif
|
---|
373 | #ifndef CONSOLE_GET_LINEAR_INFO
|
---|
374 | # define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info)
|
---|
375 | #endif
|
---|
376 | #ifndef CONSOLE_GET_IO_INFO
|
---|
377 | # define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info)
|
---|
378 | #endif
|
---|
379 | #ifndef CONSOLE_GET_MEM_INFO
|
---|
380 | # define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info)
|
---|
381 | #endif
|
---|
382 | # endif /* __bsdi__ */
|
---|
383 | # endif /* !LINKKIT */
|
---|
384 |
|
---|
385 | #if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL)
|
---|
386 | #include <machine/sysarch.h>
|
---|
387 | #endif
|
---|
388 |
|
---|
389 | # define CLEARDTR_SUPPORT
|
---|
390 |
|
---|
391 | # if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
|
---|
392 | # define USE_VT_SYSREQ
|
---|
393 | # endif
|
---|
394 |
|
---|
395 | #endif
|
---|
396 | /* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */
|
---|
397 |
|
---|
398 | /**************************************************************************/
|
---|
399 | /* IRIX */
|
---|
400 | /**************************************************************************/
|
---|
401 |
|
---|
402 | /**************************************************************************/
|
---|
403 | /* Generic */
|
---|
404 | /**************************************************************************/
|
---|
405 |
|
---|
406 | #include <sys/wait.h> /* May need to adjust this for other OSs */
|
---|
407 |
|
---|
408 | /*
|
---|
409 | * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
|
---|
410 | * and it's safe, so just do it.
|
---|
411 | */
|
---|
412 | #if !defined(O_NDELAY) && defined(O_NONBLOCK)
|
---|
413 | # define O_NDELAY O_NONBLOCK
|
---|
414 | #endif /* !O_NDELAY && O_NONBLOCK */
|
---|
415 |
|
---|
416 | #if !defined(MAXHOSTNAMELEN)
|
---|
417 | # define MAXHOSTNAMELEN 32
|
---|
418 | #endif /* !MAXHOSTNAMELEN */
|
---|
419 |
|
---|
420 | #if defined(_POSIX_SOURCE)
|
---|
421 | # include <limits.h>
|
---|
422 | #else
|
---|
423 | # define _POSIX_SOURCE
|
---|
424 | # include <limits.h>
|
---|
425 | # undef _POSIX_SOURCE
|
---|
426 | #endif /* _POSIX_SOURCE */
|
---|
427 |
|
---|
428 | #if !defined(PATH_MAX)
|
---|
429 | # if defined(MAXPATHLEN)
|
---|
430 | # define PATH_MAX MAXPATHLEN
|
---|
431 | # else
|
---|
432 | # define PATH_MAX 1024
|
---|
433 | # endif /* MAXPATHLEN */
|
---|
434 | #endif /* !PATH_MAX */
|
---|
435 |
|
---|
436 |
|
---|
437 | #ifndef DEV_MEM
|
---|
438 | #define DEV_MEM "/dev/mem"
|
---|
439 | #endif
|
---|
440 |
|
---|
441 | #ifndef VT_SYSREQ_DEFAULT
|
---|
442 | #define VT_SYSREQ_DEFAULT FALSE
|
---|
443 | #endif
|
---|
444 |
|
---|
445 | #define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
|
---|
446 |
|
---|
447 | #define XF86_OS_PRIVS
|
---|
448 | #include "xf86_OSproc.h"
|
---|
449 |
|
---|
450 | #ifndef NO_COMPILER_H
|
---|
451 | #include "compiler.h"
|
---|
452 | #endif
|
---|
453 |
|
---|
454 | #endif /* _XF86_OSLIB_H */
|
---|