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