Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / os-support / usl / usl_iop.c
blobc6382fc7effb87e068a7ffc1ef5c214a248f9f80
1 /*
2 * Copyright 2001,2005 by Kean Johnston <jkj@sco.com>
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name Kean Johnston not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. Kean Johnston makes no
11 * representations about the suitability of this software for any purpose.
12 * It is provided "as is" without express or implied warranty.
14 * KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
24 #include "X.h"
26 #include "compiler.h"
28 #define _NEED_SYSI86
29 #include "xf86.h"
30 #include "xf86Priv.h"
31 #include "xf86OSpriv.h"
32 #include "xf86_OSlib.h"
35 /***************************************************************************/
36 /* I/O Permissions section */
37 /***************************************************************************/
39 static Bool IOEnabled = FALSE;
41 _X_EXPORT Bool
42 xf86EnableIO(void)
44 if (IOEnabled)
45 return TRUE;
47 if (sysi86(SI86IOPL, 3) < 0)
48 FatalError("Failed to set IOPL for extended I/O\n");
49 IOEnabled = TRUE;
50 return TRUE;
53 _X_EXPORT void
54 xf86DisableIO(void)
56 if (!IOEnabled)
57 return;
59 sysi86(SI86IOPL, 0);
60 IOEnabled = FALSE;
63 /***************************************************************************/
64 /* Interrupt Handling section */
65 /***************************************************************************/
67 _X_EXPORT Bool
68 xf86DisableInterrupts(void)
70 if (!IOEnabled) {
71 if (sysi86(SI86IOPL, 3) < 0)
72 return FALSE;
75 #ifdef __GNUC__
76 __asm__ __volatile__("cli");
77 #else
78 asm("cli");
79 #endif /* __GNUC__ */
81 if (!IOEnabled) {
82 sysi86(SI86IOPL, 0);
85 return(TRUE);
88 _X_EXPORT void
89 xf86EnableInterrupts(void)
91 if (!IOEnabled) {
92 if (sysi86(SI86IOPL, 3) < 0)
93 return;
96 #ifdef __GNUC__
97 __asm__ __volatile__("sti");
98 #else
99 asm("sti");
100 #endif /* __GNUC__ */
102 if (!IOEnabled) {
103 sysi86(SI86IOPL, 0);