PageRenderTime 54ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/hw/xfree86/os-support/xf86_OSlib.h

https://github.com/cubanismo/xserver
C Header | 371 lines | 224 code | 49 blank | 98 comment | 33 complexity | 3db4c4b2ba0ded0992c84b24f3d137c6 MD5 | raw file
Possible License(s): MIT
  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. * The ARM32 code here carries the following copyright:
  36. *
  37. * Copyright 1997
  38. * Digital Equipment Corporation. All rights reserved.
  39. * This software is furnished under license and may be used and copied only in
  40. * accordance with the following terms and conditions. Subject to these
  41. * conditions, you may download, copy, install, use, modify and distribute
  42. * this software in source and/or binary form. No title or ownership is
  43. * transferred hereby.
  44. *
  45. * 1) Any source code used, modified or distributed must reproduce and retain
  46. * this copyright notice and list of conditions as they appear in the
  47. * source file.
  48. *
  49. * 2) No right is granted to use any trade name, trademark, or logo of Digital
  50. * Equipment Corporation. Neither the "Digital Equipment Corporation"
  51. * name nor any trademark or logo of Digital Equipment Corporation may be
  52. * used to endorse or promote products derived from this software without
  53. * the prior written permission of Digital Equipment Corporation.
  54. *
  55. * 3) This software is provided "AS-IS" and any express or implied warranties,
  56. * including but not limited to, any implied warranties of merchantability,
  57. * fitness for a particular purpose, or non-infringement are disclaimed.
  58. * In no event shall DIGITAL be liable for any damages whatsoever, and in
  59. * particular, DIGITAL shall not be liable for special, indirect,
  60. * consequential, or incidental damages or damages for lost profits, loss
  61. * of revenue or loss of use, whether such damages arise in contract,
  62. * negligence, tort, under statute, in equity, at law or otherwise, even
  63. * if advised of the possibility of such damage.
  64. *
  65. */
  66. /*
  67. * This is private, and should not be included by any drivers. Drivers
  68. * may include xf86_OSproc.h to get prototypes for public interfaces.
  69. */
  70. #ifndef _XF86_OSLIB_H
  71. #define _XF86_OSLIB_H
  72. #include <X11/Xos.h>
  73. #include <X11/Xfuncproto.h>
  74. #include <stdio.h>
  75. #include <ctype.h>
  76. #include <stddef.h>
  77. /**************************************************************************/
  78. /* SYSV386 (SVR3, SVR4), including Solaris */
  79. /**************************************************************************/
  80. #if (defined(SYSV) || defined(SVR4)) && \
  81. (defined(sun) || defined(__i386__))
  82. #include <sys/ioctl.h>
  83. #include <signal.h>
  84. #include <termio.h>
  85. #include <sys/stat.h>
  86. #include <sys/types.h>
  87. #include <errno.h>
  88. #if defined(_NEED_SYSI86)
  89. #if !(defined (sun) && defined (SVR4))
  90. #include <sys/immu.h>
  91. #include <sys/region.h>
  92. #include <sys/proc.h>
  93. #endif
  94. #include <sys/tss.h>
  95. #include <sys/sysi86.h>
  96. #if defined(SVR4) && !defined(sun)
  97. #include <sys/seg.h>
  98. #endif /* SVR4 && !sun */
  99. /* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */
  100. #if !defined(V86SC_IOPL) /* Solaris 7 or later? */
  101. #include <sys/v86.h> /* Nope */
  102. #endif
  103. #if defined(sun) && (defined (__i386__) || defined(__i386) || defined(__x86)) && defined (SVR4)
  104. #include <sys/psw.h>
  105. #endif
  106. #endif /* _NEED_SYSI86 */
  107. #if defined(HAS_SVR3_MMAPDRV)
  108. #include <sys/sysmacros.h>
  109. #if !defined(_NEED_SYSI86)
  110. #include <sys/immu.h>
  111. #include <sys/region.h>
  112. #endif
  113. #include <sys/mmap.h> /* MMAP driver header */
  114. #endif
  115. #if !defined(sun) || defined(HAVE_SYS_VT_H)
  116. #define HAS_USL_VTS
  117. #endif
  118. #if !defined(sun)
  119. #include <sys/emap.h>
  120. #endif
  121. #if defined(HAS_USL_VTS)
  122. #if !defined(sun)
  123. #include <sys/at_ansi.h>
  124. #endif
  125. #include <sys/kd.h>
  126. #include <sys/vt.h>
  127. #endif
  128. #if defined(sun)
  129. #include <sys/fbio.h>
  130. #include <sys/kbd.h>
  131. #include <sys/kbio.h>
  132. /* undefine symbols from <sys/kbd.h> we don't need that conflict with enum
  133. definitions in parser/xf86tokens.h */
  134. #undef STRING
  135. #undef LEFTALT
  136. #undef RIGHTALT
  137. #define LED_CAP LED_CAPS_LOCK
  138. #define LED_NUM LED_NUM_LOCK
  139. #define LED_SCR LED_SCROLL_LOCK
  140. #define LED_COMP LED_COMPOSE
  141. #endif /* sun */
  142. #if !defined(VT_ACKACQ)
  143. #define VT_ACKACQ 2
  144. #endif /* !VT_ACKACQ */
  145. #if defined(SVR4)
  146. #include <sys/mman.h>
  147. #if !(defined(sun) && defined (SVR4))
  148. #define DEV_MEM "/dev/pmem"
  149. #endif
  150. #define CLEARDTR_SUPPORT
  151. #define POSIX_TTY
  152. #endif /* SVR4 */
  153. #endif /* (SYSV || SVR4) */
  154. /**************************************************************************/
  155. /* Linux or Glibc-based system */
  156. /**************************************************************************/
  157. #if defined(__linux__) || defined(__GLIBC__) || defined(__CYGWIN__)
  158. #include <sys/ioctl.h>
  159. #include <signal.h>
  160. #include <stdlib.h>
  161. #include <sys/types.h>
  162. #include <assert.h>
  163. #ifdef __linux__
  164. #include <termio.h>
  165. #else /* __GLIBC__ */
  166. #include <termios.h>
  167. #endif
  168. #ifdef __sparc__
  169. #include <sys/param.h>
  170. #endif
  171. #include <errno.h>
  172. #include <sys/stat.h>
  173. #include <sys/mman.h>
  174. #ifdef __linux__
  175. #define HAS_USL_VTS
  176. #include <sys/kd.h>
  177. #include <sys/vt.h>
  178. #define LDGMAP GIO_SCRNMAP
  179. #define LDSMAP PIO_SCRNMAP
  180. #define LDNMAP LDSMAP
  181. #define CLEARDTR_SUPPORT
  182. #endif
  183. #define POSIX_TTY
  184. #endif /* __linux__ || __GLIBC__ */
  185. /**************************************************************************/
  186. /* 386BSD and derivatives, BSD/386 */
  187. /**************************************************************************/
  188. #if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
  189. #undef __386BSD__
  190. #endif
  191. #ifdef CSRG_BASED
  192. #include <sys/ioctl.h>
  193. #include <signal.h>
  194. #include <termios.h>
  195. #define termio termios
  196. #define POSIX_TTY
  197. #include <errno.h>
  198. #include <sys/types.h>
  199. #include <sys/mman.h>
  200. #include <sys/stat.h>
  201. #endif /* CSRG_BASED */
  202. /**************************************************************************/
  203. /* Kernel of *BSD */
  204. /**************************************************************************/
  205. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
  206. defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
  207. #include <sys/param.h>
  208. #if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version)
  209. #define __FreeBSD_kernel_version __FreeBSD_version
  210. #endif
  211. #if !defined(LINKKIT)
  212. /* Don't need this stuff for the Link Kit */
  213. #ifdef SYSCONS_SUPPORT
  214. #define COMPAT_SYSCONS
  215. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
  216. #if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000)
  217. #include <sys/consio.h>
  218. #include <sys/kbio.h>
  219. #else
  220. #include <machine/console.h>
  221. #endif /* FreeBSD 4.1 RELEASE or lator */
  222. #else
  223. #include <sys/console.h>
  224. #endif
  225. #endif /* SYSCONS_SUPPORT */
  226. #if defined(PCVT_SUPPORT) && !defined(__NetBSD__) && !defined(__OpenBSD__)
  227. #if !defined(SYSCONS_SUPPORT)
  228. /* no syscons, so include pcvt specific header file */
  229. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
  230. #include <machine/pcvt_ioctl.h>
  231. #else
  232. #include <sys/pcvt_ioctl.h>
  233. #endif /* __FreeBSD_kernel__ */
  234. #else /* pcvt and syscons: hard-code the ID magic */
  235. #define VGAPCVTID _IOWR('V',113, struct pcvtid)
  236. struct pcvtid {
  237. char name[16];
  238. int rmajor, rminor;
  239. };
  240. #endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */
  241. #endif /* PCVT_SUPPORT */
  242. #ifdef WSCONS_SUPPORT
  243. #include <dev/wscons/wsconsio.h>
  244. #include <dev/wscons/wsdisplay_usl_io.h>
  245. #endif /* WSCONS_SUPPORT */
  246. #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
  247. #include <sys/mouse.h>
  248. #endif
  249. /* Include these definitions in case ioctl_pc.h didn't get included */
  250. #ifndef CONSOLE_X_MODE_ON
  251. #define CONSOLE_X_MODE_ON _IO('t',121)
  252. #endif
  253. #ifndef CONSOLE_X_MODE_OFF
  254. #define CONSOLE_X_MODE_OFF _IO('t',122)
  255. #endif
  256. #ifndef CONSOLE_X_BELL
  257. #define CONSOLE_X_BELL _IOW('t',123,int[2])
  258. #endif
  259. #ifndef CONSOLE_X_TV_ON
  260. #define CONSOLE_X_TV_ON _IOW('t',155,int)
  261. #define XMODE_RGB 0
  262. #define XMODE_NTSC 1
  263. #define XMODE_PAL 2
  264. #define XMODE_SECAM 3
  265. #endif
  266. #ifndef CONSOLE_X_TV_OFF
  267. #define CONSOLE_X_TV_OFF _IO('t',156)
  268. #endif
  269. #ifndef CONSOLE_GET_LINEAR_INFO
  270. #define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info)
  271. #endif
  272. #ifndef CONSOLE_GET_IO_INFO
  273. #define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info)
  274. #endif
  275. #ifndef CONSOLE_GET_MEM_INFO
  276. #define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info)
  277. #endif
  278. #endif /* !LINKKIT */
  279. #if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL)
  280. #include <machine/sysarch.h>
  281. #endif
  282. #define CLEARDTR_SUPPORT
  283. #endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
  284. /**************************************************************************/
  285. /* IRIX */
  286. /**************************************************************************/
  287. /**************************************************************************/
  288. /* Generic */
  289. /**************************************************************************/
  290. #include <sys/wait.h> /* May need to adjust this for other OSs */
  291. /* For PATH_MAX */
  292. #include "misc.h"
  293. /*
  294. * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
  295. * and it's safe, so just do it.
  296. */
  297. #if !defined(O_NDELAY) && defined(O_NONBLOCK)
  298. #define O_NDELAY O_NONBLOCK
  299. #endif /* !O_NDELAY && O_NONBLOCK */
  300. #if !defined(MAXHOSTNAMELEN)
  301. #define MAXHOSTNAMELEN 32
  302. #endif /* !MAXHOSTNAMELEN */
  303. #if defined(_POSIX_SOURCE)
  304. #include <limits.h>
  305. #else
  306. #define _POSIX_SOURCE
  307. #include <limits.h>
  308. #undef _POSIX_SOURCE
  309. #endif /* _POSIX_SOURCE */
  310. #ifndef DEV_MEM
  311. #define DEV_MEM "/dev/mem"
  312. #endif
  313. #ifndef MAP_FAILED
  314. #define MAP_FAILED ((void *)-1)
  315. #endif
  316. #define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
  317. #define XF86_OS_PRIVS
  318. #include "xf86_OSproc.h"
  319. #ifndef NO_COMPILER_H
  320. #include "compiler.h"
  321. #endif
  322. #endif /* _XF86_OSLIB_H */