summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'x11-base/xorg-server/files/xorg-server-disable-iopl.patch')
-rw-r--r--x11-base/xorg-server/files/xorg-server-disable-iopl.patch255
1 files changed, 255 insertions, 0 deletions
diff --git a/x11-base/xorg-server/files/xorg-server-disable-iopl.patch b/x11-base/xorg-server/files/xorg-server-disable-iopl.patch
new file mode 100644
index 0000000..25f7e4a
--- /dev/null
+++ b/x11-base/xorg-server/files/xorg-server-disable-iopl.patch
@@ -0,0 +1,255 @@
+diff -r -u a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
+--- a/hw/xfree86/common/xf86.h 2012-10-25 00:41:02.000000000 -0400
++++ b/hw/xfree86/common/xf86.h 2013-02-06 09:54:06.560035830 -0500
+@@ -55,6 +55,7 @@
+ extern _X_EXPORT int xf86DoConfigure;
+ extern _X_EXPORT int xf86DoShowOptions;
+ extern _X_EXPORT Bool xf86DoConfigurePass1;
++extern _X_EXPORT Bool xorgHWAccess;
+
+ extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
+
+diff -r -u a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
+--- a/hw/xfree86/common/xf86Bus.c 2012-11-02 00:17:59.000000000 -0400
++++ b/hw/xfree86/common/xf86Bus.c 2013-02-06 09:54:06.560035830 -0500
+@@ -127,17 +127,6 @@
+ * instance of the hardware found.
+ */
+ for (i = 0; i < xf86NumDrivers; i++) {
+- xorgHWFlags flags;
+-
+- if (!xorgHWAccess) {
+- if (!xf86DriverList[i]->driverFunc
+- || !xf86DriverList[i]->driverFunc(NULL,
+- GET_REQUIRED_HW_INTERFACES,
+- &flags)
+- || NEED_IO_ENABLED(flags))
+- continue;
+- }
+-
+ xf86CallDriverProbe(xf86DriverList[i], FALSE);
+ }
+
+diff -r -u a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
+--- a/hw/xfree86/common/xf86Configure.c 2012-10-13 19:38:50.000000000 -0400
++++ b/hw/xfree86/common/xf86Configure.c 2013-02-06 09:54:06.560035830 -0500
+@@ -545,41 +545,16 @@
+
+ free(vlist);
+
+- for (i = 0; i < xf86NumDrivers; i++) {
+- xorgHWFlags flags;
+-
+- if (!xf86DriverList[i]->driverFunc
+- || !xf86DriverList[i]->driverFunc(NULL,
+- GET_REQUIRED_HW_INTERFACES,
+- &flags)
+- || NEED_IO_ENABLED(flags)) {
+- xorgHWAccess = TRUE;
+- break;
+- }
+- }
+- /* Enable full I/O access */
+- if (xorgHWAccess) {
+- if (!xf86EnableIO())
+- /* oops, we have failed */
+- xorgHWAccess = FALSE;
+- }
++ xorgHWAccess = xf86EnableIO();
+
+ /* Create XF86Config file structure */
+ xf86config = calloc(1, sizeof(XF86ConfigRec));
+
+ /* Call all of the probe functions, reporting the results. */
+ for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
+- xorgHWFlags flags;
+ Bool found_screen;
+ DriverRec *const drv = xf86DriverList[CurrentDriver];
+
+- if (!xorgHWAccess) {
+- if (!drv->driverFunc
+- || !drv->driverFunc(NULL, GET_REQUIRED_HW_INTERFACES, &flags)
+- || NEED_IO_ENABLED(flags))
+- continue;
+- }
+-
+ found_screen = xf86CallDriverProbe(drv, TRUE);
+ if (found_screen && drv->Identify) {
+ (*drv->Identify) (0);
+diff -r -u a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
+--- a/hw/xfree86/common/xf86Init.c 2012-10-13 19:38:50.000000000 -0400
++++ b/hw/xfree86/common/xf86Init.c 2013-02-06 09:54:06.560035830 -0500
+@@ -530,23 +530,22 @@
+ */
+
+ for (i = 0; i < xf86NumDrivers; i++) {
++ xorgHWFlags flags = HW_IO;
++
+ if (xf86DriverList[i]->Identify != NULL)
+ xf86DriverList[i]->Identify(0);
+
+- if (!xorgHWAccess || !xorgHWOpenConsole) {
+- xorgHWFlags flags;
++ if (xf86DriverList[i]->driverFunc)
++ xf86DriverList[i]->driverFunc(NULL,
++ GET_REQUIRED_HW_INTERFACES,
++ &flags);
++
++ /* this is "do we want it" at this point */
++ if (NEED_IO_ENABLED(flags))
++ xorgHWAccess = TRUE;
+
+- if (!xf86DriverList[i]->driverFunc
+- || !xf86DriverList[i]->driverFunc(NULL,
+- GET_REQUIRED_HW_INTERFACES,
+- &flags))
+- flags = HW_IO;
+-
+- if (NEED_IO_ENABLED(flags))
+- xorgHWAccess = TRUE;
+- if (!(flags & HW_SKIP_CONSOLE))
+- xorgHWOpenConsole = TRUE;
+- }
++ if (!(flags & HW_SKIP_CONSOLE))
++ xorgHWOpenConsole = TRUE;
+ }
+
+ if (xorgHWOpenConsole)
+diff -r -u a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
+--- a/hw/xfree86/common/xf86Priv.h 2012-10-13 19:38:50.000000000 -0400
++++ b/hw/xfree86/common/xf86Priv.h 2013-02-06 09:54:06.560035830 -0500
+@@ -91,7 +91,6 @@
+ extern _X_EXPORT const char *xf86VisualNames[];
+ extern _X_EXPORT int xf86Verbose; /* verbosity level */
+ extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
+-extern _X_EXPORT Bool xorgHWAccess;
+
+ extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
+
+diff -r -u a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
+--- a/hw/xfree86/os-support/linux/lnx_video.c 2012-10-13 19:38:51.000000000 -0400
++++ b/hw/xfree86/os-support/linux/lnx_video.c 2013-02-06 09:47:22.710032993 -0500
+@@ -479,45 +479,39 @@
+ #define __NR_pciconfig_iobase 200
+ #endif
+
+-#endif
+-
+-Bool
+-xf86EnableIO(void)
++static Bool
++hwEnableIO(void)
+ {
+-#if defined(__powerpc__)
+ int fd;
+- unsigned int ioBase_phys;
+-#endif
+-
+- if (ExtendedEnabled)
+- return TRUE;
+-
+-#if defined(__powerpc__)
+- ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
++ unsigned int ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
+
+ fd = open("/dev/mem", O_RDWR);
+ if (ioBase == NULL) {
+ ioBase = (volatile unsigned char *) mmap(0, 0x20000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, ioBase_phys);
+-/* Should this be fatal or just a warning? */
+-#if 0
+- if (ioBase == MAP_FAILED) {
+- xf86Msg(X_WARNING,
+- "xf86EnableIOPorts: Failed to map iobase (%s)\n",
+- strerror(errno));
+- return FALSE;
+- }
+-#endif
+ }
+ close(fd);
+-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__) && !defined(__nds32__)
++
++ return ioBase != MAP_FAILED;
++}
++
++static void
++hwDisableIO(void)
++{
++ munmap(ioBase, 0x20000);
++ ioBase = NULL;
++}
++
++#elif defined(__i386__) || defined(__x86_64__) || defined(__ia64__) || \
++ defined(__alpha__)
++
++static Bool
++hwEnableIO(void)
++{
+ if (ioperm(0, 1024, 1) || iopl(3)) {
+- if (errno == ENODEV)
+- ErrorF("xf86EnableIOPorts: no I/O ports found\n");
+- else
+- FatalError("xf86EnableIOPorts: failed to set IOPL"
+- " for I/O (%s)\n", strerror(errno));
++ ErrorF("xf86EnableIOPorts: failed to set IOPL for I/O (%s)\n",
++ strerror(errno));
+ return FALSE;
+ }
+ #if !defined(__alpha__)
+@@ -526,27 +520,44 @@
+ ioperm(0x40, 4, 0); /* trap access to the timer chip */
+ ioperm(0x60, 4, 0); /* trap access to the keyboard controller */
+ #endif
+-#endif
+- ExtendedEnabled = TRUE;
+
+ return TRUE;
+ }
+
++static void
++hwDisableIO(void)
++{
++ iopl(0);
++ ioperm(0, 1024, 0);
++}
++
++#else /* non-IO architectures */
++
++#define hwEnableIO() TRUE
++#define hwDisableIO() do {} while (0)
++
++#endif
++
++Bool
++xf86EnableIO(void)
++{
++ if (ExtendedEnabled)
++ return TRUE;
++
++ ExtendedEnabled = hwEnableIO();
++
++ return ExtendedEnabled;
++}
++
+ void
+ xf86DisableIO(void)
+ {
+ if (!ExtendedEnabled)
+ return;
+-#if defined(__powerpc__)
+- munmap(ioBase, 0x20000);
+- ioBase = NULL;
+-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__) && !defined(__nds32__)
+- iopl(0);
+- ioperm(0, 1024, 0);
+-#endif
+- ExtendedEnabled = FALSE;
+
+- return;
++ hwDisableIO();
++
++ ExtendedEnabled = FALSE;
+ }
+
+ #if defined (__alpha__)