2003-11-14 17:48:57 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2001 by J. Kean Johnston <jkj@caldera.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name J. Kean Johnston not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
* specific, written prior permission. J. Kean Johnston makes no
|
|
|
|
* representations about the suitability of this software for any purpose.
|
|
|
|
* It is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
|
|
|
|
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2003-11-14 17:48:57 +01:00
|
|
|
|
|
|
|
#include "compiler.h"
|
|
|
|
|
|
|
|
#define _NEED_SYSI86
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86Priv.h"
|
|
|
|
#include "xf86OSpriv.h"
|
|
|
|
#include "xf86_OSlib.h"
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/* I/O Permissions section */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is a right way and a wrong way of doing this. Unfortunately, we
|
|
|
|
* are forced to do it the wrong way. The right way is to be told the range
|
|
|
|
* or ranges of I/O ports the driver(s) need access to, in order to use the
|
|
|
|
* CONS_IOPERM ioctl() to grant access only to those ports we care about.
|
|
|
|
* This way we can guarantee some small level of stability because a driver
|
|
|
|
* does not have access to all ports (which would mean it could play with
|
|
|
|
* the PIT and thus affect scheduling times, or a whole slew of other
|
|
|
|
* nasty things). However, because XFree86 currently only enables or disables
|
|
|
|
* ALL port access, we need to run at IOPL 3, which basically means the
|
|
|
|
* X Server runs at the same level as the kernel. You can image why this is
|
|
|
|
* unsafe. Oh, and this is not a problem unique to OSR5, other OSes are
|
|
|
|
* affected by this as well.
|
|
|
|
*
|
|
|
|
* So, for the time being, we change our IOPL until such time as the XFree86
|
|
|
|
* architecture is changed to allow for tighter control of I/O ports. If and
|
|
|
|
* when it is, then the CONS_ADDIOP/DELIOP ioctl() should be used to enable
|
|
|
|
* or disable access to the desired ports.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern long sysi86 (int cmd, ...);
|
|
|
|
|
|
|
|
static Bool IOEnabled = FALSE;
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2005-11-08 07:33:30 +01:00
|
|
|
xf86EnableIO(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
if (IOEnabled)
|
2005-01-28 17:13:00 +01:00
|
|
|
return TRUE;
|
2003-11-14 17:48:57 +01:00
|
|
|
|
2005-01-28 17:13:00 +01:00
|
|
|
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
|
|
|
|
xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:48:57 +01:00
|
|
|
IOEnabled = TRUE;
|
2005-01-28 17:13:00 +01:00
|
|
|
return TRUE;
|
2003-11-14 17:48:57 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2005-11-08 07:33:30 +01:00
|
|
|
xf86DisableIO(void)
|
2003-11-14 17:48:57 +01:00
|
|
|
{
|
|
|
|
if (!IOEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sysi86(SI86V86, V86SC_IOPL, 0);
|
|
|
|
IOEnabled = FALSE;
|
|
|
|
}
|