1 /* 2 * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany 3 * Copyright 1992 by David Dawes <dawes (at) XFree86.org> 4 * Copyright 1992 by Jim Tsillas <jtsilla (at) damon.ccs.northeastern.edu> 5 * Copyright 1992 by Rich Murphey <Rich (at) Rice.edu> 6 * Copyright 1992 by Robert Baron <Robert.Baron (at) ernst.mach.cs.cmu.edu> 7 * Copyright 1992 by Orest Zborowski <obz (at) eskimo.com> 8 * Copyright 1993 by Vrije Universiteit, The Netherlands 9 * Copyright 1993 by David Wexelblat <dwex (at) XFree86.org> 10 * Copyright 1994, 1996 by Holger Veit <Holger.Veit (at) gmd.de> 11 * Copyright 1997 by Takis Psarogiannakopoulos <takis (at) dpmms.cam.ac.uk> 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 # include <sys/ioctl.h> 89 # include <signal.h> 90 # include <termio.h> 91 # include <sys/stat.h> 92 # include <sys/types.h> 93 94 95 # include <errno.h> 96 97 # if defined(_NEED_SYSI86) 98 # if !(defined (sun) && defined (SVR4)) 99 # include <sys/immu.h> 100 # include <sys/region.h> 101 # endif 102 # include <sys/proc.h> 103 # include <sys/tss.h> 104 # include <sys/sysi86.h> 105 # if defined(SVR4) && !defined(sun) 106 # include <sys/seg.h> 107 # endif /* SVR4 && !sun */ 108 /* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */ 109 # if !defined(V86SC_IOPL) /* Solaris 7 or later? */ 110 # include <sys/v86.h> /* Nope */ 111 # endif 112 # if defined(sun) && (defined (__i386__) || defined(__i386) || defined(__x86)) && defined (SVR4) 113 # include <sys/psw.h> 114 # endif 115 # endif /* _NEED_SYSI86 */ 116 117 # if defined(HAS_SVR3_MMAPDRV) 118 # include <sys/sysmacros.h> 119 # if !defined(_NEED_SYSI86) 120 # include <sys/immu.h> 121 # include <sys/region.h> 122 # endif 123 # include <sys/mmap.h> /* MMAP driver header */ 124 # endif 125 126 # if !defined(sun) || defined(HAVE_SYS_VT_H) 127 # define HAS_USL_VTS 128 # endif 129 # if !defined(sun) 130 # include <sys/emap.h> 131 # endif 132 # if defined(HAS_USL_VTS) 133 # if !defined(sun) 134 # include <sys/at_ansi.h> 135 # endif 136 # include <sys/kd.h> 137 # include <sys/vt.h> 138 # endif 139 140 # if defined(sun) 141 # include <sys/fbio.h> 142 # include <sys/kbd.h> 143 # include <sys/kbio.h> 144 145 /* undefine symbols from <sys/kbd.h> we don't need that conflict with enum 146 definitions in parser/xf86tokens.h */ 147 # undef STRING 148 # undef LEFTALT 149 # undef RIGHTALT 150 151 # define LED_CAP LED_CAPS_LOCK 152 # define LED_NUM LED_NUM_LOCK 153 # define LED_SCR LED_SCROLL_LOCK 154 # define LED_COMP LED_COMPOSE 155 # endif /* sun */ 156 157 # if !defined(VT_ACKACQ) 158 # define VT_ACKACQ 2 159 # endif /* !VT_ACKACQ */ 160 161 162 # if defined(SVR4) 163 # include <sys/mman.h> 164 # if !(defined(sun) && defined (SVR4)) 165 # define DEV_MEM "/dev/pmem" 166 # endif 167 # define CLEARDTR_SUPPORT 168 # define POSIX_TTY 169 # endif /* SVR4 */ 170 171 172 # if defined(sun) && defined(HAS_USL_VTS) 173 # define USE_VT_SYSREQ 174 # endif 175 176 #endif /* (SYSV || SVR4) */ 177 178 /**************************************************************************/ 179 /* Linux or Glibc-based system */ 180 /**************************************************************************/ 181 #if defined(__linux__) || defined(__GLIBC__) 182 # include <sys/ioctl.h> 183 # include <signal.h> 184 # include <stdlib.h> 185 # include <sys/types.h> 186 # include <assert.h> 187 188 # ifdef __linux__ 189 # include <termio.h> 190 # else /* __GLIBC__ */ 191 # include <termios.h> 192 # endif 193 # ifdef __sparc__ 194 # include <sys/param.h> 195 # endif 196 197 # include <errno.h> 198 199 # include <sys/stat.h> 200 201 # include <sys/mman.h> 202 # ifdef __linux__ 203 # define HAS_USL_VTS 204 # include <sys/kd.h> 205 # include <sys/vt.h> 206 # define LDGMAP GIO_SCRNMAP 207 # define LDSMAP PIO_SCRNMAP 208 # define LDNMAP LDSMAP 209 # define CLEARDTR_SUPPORT 210 # define USE_VT_SYSREQ 211 # endif 212 213 # define POSIX_TTY 214 215 #endif /* __linux__ || __GLIBC__ */ 216 217 /**************************************************************************/ 218 /* 386BSD and derivatives, BSD/386 */ 219 /**************************************************************************/ 220 221 #if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__)) 222 # undef __386BSD__ 223 #endif 224 225 #ifdef CSRG_BASED 226 # include <sys/ioctl.h> 227 # include <signal.h> 228 229 # include <termios.h> 230 # define termio termios 231 # define POSIX_TTY 232 233 # include <errno.h> 234 235 # include <sys/types.h> 236 # include <sys/mman.h> 237 # include <sys/stat.h> 238 239 # if defined(__bsdi__) 240 # include <sys/param.h> 241 # if (_BSDI_VERSION < 199510) 242 # include <i386/isa/vgaioctl.h> 243 # endif 244 # endif /* __bsdi__ */ 245 246 #endif /* CSRG_BASED */ 247 248 /**************************************************************************/ 249 /* Kernel of *BSD */ 250 /**************************************************************************/ 251 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ 252 defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) 253 254 # include <sys/param.h> 255 # if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version) 256 # define __FreeBSD_kernel_version __FreeBSD_version 257 # endif 258 259 # if !defined(LINKKIT) 260 /* Don't need this stuff for the Link Kit */ 261 # if defined(__bsdi__) 262 # include <i386/isa/pcconsioctl.h> 263 # define CONSOLE_X_MODE_ON PCCONIOCRAW 264 # define CONSOLE_X_MODE_OFF PCCONIOCCOOK 265 # define CONSOLE_X_BELL PCCONIOCBEEP 266 # else /* __bsdi__ */ 267 # ifdef SYSCONS_SUPPORT 268 # define COMPAT_SYSCONS 269 # if defined(__NetBSD__) || defined(__OpenBSD__) 270 # include <machine/console.h> 271 # else 272 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 273 # if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000) 274 # include <sys/consio.h> 275 # include <sys/kbio.h> 276 # else 277 # include <machine/console.h> 278 # endif /* FreeBSD 4.1 RELEASE or lator */ 279 # else 280 # include <sys/console.h> 281 # endif 282 # endif 283 # endif /* SYSCONS_SUPPORT */ 284 # if defined(PCVT_SUPPORT) 285 # if !defined(SYSCONS_SUPPORT) 286 /* no syscons, so include pcvt specific header file */ 287 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 288 # include <machine/pcvt_ioctl.h> 289 # else 290 # if defined(__NetBSD__) || defined(__OpenBSD__) 291 # if !defined(WSCONS_SUPPORT) 292 # include <machine/pcvt_ioctl.h> 293 # endif /* WSCONS_SUPPORT */ 294 # else 295 # include <sys/pcvt_ioctl.h> 296 # endif /* __NetBSD__ */ 297 # endif /* __FreeBSD_kernel__ || __OpenBSD__ */ 298 # else /* pcvt and syscons: hard-code the ID magic */ 299 # define VGAPCVTID _IOWR('V',113, struct pcvtid) 300 struct pcvtid { 301 char name[16]; 302 int rmajor, rminor; 303 }; 304 # endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */ 305 # endif /* PCVT_SUPPORT */ 306 # ifdef WSCONS_SUPPORT 307 # include <dev/wscons/wsconsio.h> 308 # include <dev/wscons/wsdisplay_usl_io.h> 309 # endif /* WSCONS_SUPPORT */ 310 # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 311 # if defined(__FreeBSD_kernel_version) && (__FreeBSD_kernel_version >= 500013) 312 # include <sys/mouse.h> 313 # else 314 # undef MOUSE_GETINFO 315 # include <machine/mouse.h> 316 # endif 317 # endif 318 /* Include these definitions in case ioctl_pc.h didn't get included */ 319 # ifndef CONSOLE_X_MODE_ON 320 # define CONSOLE_X_MODE_ON _IO('t',121) 321 # endif 322 # ifndef CONSOLE_X_MODE_OFF 323 # define CONSOLE_X_MODE_OFF _IO('t',122) 324 # endif 325 # ifndef CONSOLE_X_BELL 326 # define CONSOLE_X_BELL _IOW('t',123,int[2]) 327 # endif 328 # ifndef CONSOLE_X_TV_ON 329 # define CONSOLE_X_TV_ON _IOW('t',155,int) 330 # define XMODE_RGB 0 331 # define XMODE_NTSC 1 332 # define XMODE_PAL 2 333 # define XMODE_SECAM 3 334 # endif 335 # ifndef CONSOLE_X_TV_OFF 336 # define CONSOLE_X_TV_OFF _IO('t',156) 337 # endif 338 #ifndef CONSOLE_GET_LINEAR_INFO 339 # define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info) 340 #endif 341 #ifndef CONSOLE_GET_IO_INFO 342 # define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info) 343 #endif 344 #ifndef CONSOLE_GET_MEM_INFO 345 # define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info) 346 #endif 347 # endif /* __bsdi__ */ 348 # endif /* !LINKKIT */ 349 350 #if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) 351 #include <machine/sysarch.h> 352 #endif 353 354 # define CLEARDTR_SUPPORT 355 356 # if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) 357 # define USE_VT_SYSREQ 358 # endif 359 360 #endif 361 /* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */ 362 363 /**************************************************************************/ 364 /* IRIX */ 365 /**************************************************************************/ 366 367 /**************************************************************************/ 368 /* Generic */ 369 /**************************************************************************/ 370 371 #include <sys/wait.h> /* May need to adjust this for other OSs */ 372 373 /* 374 * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere, 375 * and it's safe, so just do it. 376 */ 377 #if !defined(O_NDELAY) && defined(O_NONBLOCK) 378 # define O_NDELAY O_NONBLOCK 379 #endif /* !O_NDELAY && O_NONBLOCK */ 380 381 #if !defined(MAXHOSTNAMELEN) 382 # define MAXHOSTNAMELEN 32 383 #endif /* !MAXHOSTNAMELEN */ 384 385 #if defined(_POSIX_SOURCE) 386 # include <limits.h> 387 #else 388 # define _POSIX_SOURCE 389 # include <limits.h> 390 # undef _POSIX_SOURCE 391 #endif /* _POSIX_SOURCE */ 392 393 #if !defined(PATH_MAX) 394 # if defined(MAXPATHLEN) 395 # define PATH_MAX MAXPATHLEN 396 # else 397 # define PATH_MAX 1024 398 # endif /* MAXPATHLEN */ 399 #endif /* !PATH_MAX */ 400 401 402 #ifndef DEV_MEM 403 #define DEV_MEM "/dev/mem" 404 #endif 405 406 #ifndef VT_SYSREQ_DEFAULT 407 #define VT_SYSREQ_DEFAULT FALSE 408 #endif 409 410 #define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) 411 412 #define XF86_OS_PRIVS 413 #include "xf86_OSproc.h" 414 415 #ifndef NO_COMPILER_H 416 #include "compiler.h" 417 #endif 418 419 #endif /* _XF86_OSLIB_H */ 420