[Xquartz-changes] xserver: Branch 'master' - 13 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Fri Oct 7 12:12:14 PDT 2011


Rebased ref, commits from common ancestor:
commit 75271556d3eebd8d1d4ddfaf52160b60c9005876
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Sep 24 00:01:11 2011 -0700

    Bump ABI_VIDEODRV_VERSION to 12
    
    The ABI changed in the previous series of changes, so bump the ABI version for
    the next release.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 330d87a..a9645e7 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -82,7 +82,7 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(11, 0)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(12, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(14, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(6, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
commit 83c18acd72e73129e63a8549f292f0077a62a7b8
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 13:45:18 2011 -0500

    xorg-server.pc.in: Remove libpciaccess and pixman-1 from Requires
    
    Every module building against xorg-server does not *Require* pixman nor
    libpciaccess.  If such modules need pixman or pciaccess, they should be
    depending on them directly rather than inheriting a dependency from
    xorg-server.  To do this, they should use PKG_CHECK_MODULES in configure.ac
    to check for pixman-1 or pciaccess and include the apporpriate _LIBS variable
    to the appropriate _LDFLAGS variable in Makefile.am
    
    This also moves pixman-1 to Requires.private, so CPPFLAGS is set right to
    to satisfy include dependencies but avoid linking needlessly.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index 50beb01..4bfa82c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -784,11 +784,6 @@ VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
 WINDOWSWMPROTO="windowswmproto"
 APPLEWMPROTO="applewmproto >= 1.4"
 
-dnl Core modules for most extensions, et al.
-SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto"
-# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
-AC_SUBST(SDK_REQUIRED_MODULES)
-
 dnl List of libraries that require a specific version
 LIBAPPLEWM="applewm >= 1.4"
 LIBDMX="dmx >= 1.0.99.1"
@@ -810,6 +805,11 @@ dnl specific modules against it
 PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN)
 REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau"
 
+dnl Core modules for most extensions, et al.
+SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.0.99.1] [kbproto >= 1.0.3] fontsproto $LIBPIXMAN"
+# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
+AC_SUBST(SDK_REQUIRED_MODULES)
+
 REQUIRED_MODULES="[fixesproto >= 5.0] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES"
 
 if test "x$CONFIG_UDEV" = xyes &&
@@ -1583,6 +1583,7 @@ if test "x$XORG" = xyes; then
 	if test "x$PCI" = xyes; then
 
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
+	SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $LIBPCIACCESS"
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index fb238b5..a98eca8 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -15,7 +15,6 @@ abi_extension=@abi_extension@
 Name: xorg-server
 Description: Modular X.Org X Server
 Version: @PACKAGE_VERSION@
-Requires: pixman-1 pciaccess
 Requires.private: @SDK_REQUIRED_MODULES@
 Cflags: -I${sdkdir} @symbol_visibility@
 Libs: -L${libdir}
commit bf7d5bec59d7b85ac7ba03b63853e0bdd72845f1
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 10:37:38 2011 -0500

    darwin: configure: Force some irrelevant options to off on darwin
    
    This removes the need to pass the following to configure on darwin:
    --disable-pciaccess -disable-int10-module --disable-vbe --disable-vgahw --disable-libdrm
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/configure.ac b/configure.ac
index 004c08d..50beb01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -719,6 +719,11 @@ case $host_os in
 		XV=no
 		;;
 	darwin*)
+		PCI=no
+		INT10MODULE=no
+		VGAHW=no
+		VBE=no
+		DRM=no
 		DRI2=no
 
 		if test x$XQUARTZ = xauto; then
commit fd68645b2736442c7dd30aa7a3fcffae52a9bdd9
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 15:42:19 2011 -0500

    xfree86: Link modules with -module
    
    This makes a difference on darwin (and apparently nowhere else)
    
    https://www.gnu.org/s/libtool/manual/libtool.html#Modules-for-libltdl
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 1a162ab..b6eb54f 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -30,21 +30,21 @@ INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/miext/shadow \
            -I$(top_srcdir)/glx
 
-libdbe_la_LDFLAGS = -avoid-version
+libdbe_la_LDFLAGS = -module -avoid-version
 libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
 libdbe_la_SOURCES = dbemodule.c
 
-libfb_la_LDFLAGS = -avoid-version
+libfb_la_LDFLAGS = -module -avoid-version
 libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
 libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
 libfb_la_CFLAGS = $(AM_CFLAGS)
 
-libwfb_la_LDFLAGS = -avoid-version
+libwfb_la_LDFLAGS = -module -avoid-version
 libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
 libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
 libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
 
-libglx_la_LDFLAGS = -avoid-version
+libglx_la_LDFLAGS = -module -avoid-version
 if AIGLX_DRI_LOADER
 GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
 endif
@@ -53,11 +53,11 @@ libglx_la_LIBADD = \
 	$(GLXDRI_LIBRARY)
 libglx_la_SOURCES = glxmodule.c
 
-librecord_la_LDFLAGS = -avoid-version
+librecord_la_LDFLAGS = -module -avoid-version
 librecord_la_LIBADD = $(top_builddir)/record/librecord.la
 librecord_la_SOURCES = recordmod.c
 
-libshadow_la_LDFLAGS = -avoid-version
+libshadow_la_LDFLAGS = -module -avoid-version
 libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
 libshadow_la_SOURCES = shmodule.c
 
diff --git a/hw/xfree86/dixmods/extmod/Makefile.am b/hw/xfree86/dixmods/extmod/Makefile.am
index cce19f7..87c28a4 100644
--- a/hw/xfree86/dixmods/extmod/Makefile.am
+++ b/hw/xfree86/dixmods/extmod/Makefile.am
@@ -21,7 +21,7 @@ INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/hw/xfree86/loader \
            -I$(top_srcdir)/miext/shadow
 
-libextmod_la_LDFLAGS = -avoid-version
+libextmod_la_LDFLAGS = -module -avoid-version
 libextmod_la_SOURCES = modinit.c \
                        modinit.h \
                        $(DGA_SRCS) \
diff --git a/hw/xfree86/exa/Makefile.am b/hw/xfree86/exa/Makefile.am
index 39f7a90..3ced531 100644
--- a/hw/xfree86/exa/Makefile.am
+++ b/hw/xfree86/exa/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = man
 
 module_LTLIBRARIES = libexa.la
 
-libexa_la_LDFLAGS = -avoid-version
+libexa_la_LDFLAGS = -module -avoid-version
 
 INCLUDES = \
 	$(XORG_INCS) \
diff --git a/hw/xfree86/fbdevhw/Makefile.am b/hw/xfree86/fbdevhw/Makefile.am
index 2a03890..4472acd 100644
--- a/hw/xfree86/fbdevhw/Makefile.am
+++ b/hw/xfree86/fbdevhw/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = man
 
 module_LTLIBRARIES = libfbdevhw.la
 
-libfbdevhw_la_LDFLAGS = -avoid-version
+libfbdevhw_la_LDFLAGS = -module -avoid-version
 
 if FBDEVHW
 libfbdevhw_la_SOURCES = fbdevhw.c
diff --git a/hw/xfree86/shadowfb/Makefile.am b/hw/xfree86/shadowfb/Makefile.am
index 02d2dd4..39c6610 100644
--- a/hw/xfree86/shadowfb/Makefile.am
+++ b/hw/xfree86/shadowfb/Makefile.am
@@ -1,5 +1,5 @@
 module_LTLIBRARIES = libshadowfb.la
-libshadowfb_la_LDFLAGS = -avoid-version
+libshadowfb_la_LDFLAGS = -module -avoid-version
 libshadowfb_la_SOURCES = sfbmodule.c shadow.c
 
 sdk_HEADERS = shadowfb.h
diff --git a/hw/xfree86/vbe/Makefile.am b/hw/xfree86/vbe/Makefile.am
index 85c6fd8..4b794e6 100644
--- a/hw/xfree86/vbe/Makefile.am
+++ b/hw/xfree86/vbe/Makefile.am
@@ -1,5 +1,5 @@
 module_LTLIBRARIES = libvbe.la
-libvbe_la_LDFLAGS = -avoid-version
+libvbe_la_LDFLAGS = -module -avoid-version
 libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c
 
 sdk_HEADERS = vbe.h vbeModes.h
diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am
index 5bfb4e9..7ebe0b9 100644
--- a/hw/xfree86/xaa/Makefile.am
+++ b/hw/xfree86/xaa/Makefile.am
@@ -8,7 +8,7 @@ MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c
 MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c
 POLYSEG = s-xaaLine.c s-xaaDashLine.c
 
-libxaa_la_LDFLAGS = -avoid-version
+libxaa_la_LDFLAGS = -module -avoid-version
 if COMPOSITE
 libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la
 endif
commit d6e92e9fb7754d9f160d81fd223247ac1da33129
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 12:14:56 2011 -0500

    xfree86: fbdevhw: Remove unused include of pciaccess.h
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/hw/xfree86/fbdevhw/fbdevhw.h b/hw/xfree86/fbdevhw/fbdevhw.h
index bc46b9c..34870c2 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.h
+++ b/hw/xfree86/fbdevhw/fbdevhw.h
@@ -5,8 +5,6 @@
 #include "xf86str.h"
 #include "colormapst.h"
 
-#include <pciaccess.h>
-
 #define FBDEVHW_PACKED_PIXELS		0	/* Packed Pixels	*/
 #define FBDEVHW_PLANES			1	/* Non interleaved planes */
 #define FBDEVHW_INTERLEAVED_PLANES	2	/* Interleaved planes	*/
commit d57f87892b698282eba69566690c26940a49aaa0
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Jun 1 13:05:47 2010 +0300

    configure: wrap PCI code with macro and set it at build time
    
    --disable-pciaccess, used together with --disable-module-int10, can be used to
    disable all pci code inside the server.
    
    Note that XSERVER_LIBPCIACCESS was previously used only in the driver side and
    now it defines also whether the library is used inside the server. Also,
    XORG_BUS_PCI automake variable is introduced to track PCI code needs.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 2edeb4d..004c08d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -638,6 +638,7 @@ AC_ARG_ENABLE(int10-module,     AS_HELP_STRING([--enable-int10-module], [Build X
 AC_ARG_ENABLE(windowswm,      AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
 AC_ARG_ENABLE(libdrm,         AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
 AC_ARG_ENABLE(clientids,      AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes])
+AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], [Build Xorg with pciaccess library (default: enabled)]), [PCI=$enableval], [PCI=yes])
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -1573,6 +1574,9 @@ if test "x$XORG" = xyes; then
 	xorg_bus_bsdpci=no
 	xorg_bus_sparc=no
 
+	AC_MSG_CHECKING([whether to build Xorg PCI functions])
+	if test "x$PCI" = xyes; then
+
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
@@ -1589,6 +1593,9 @@ if test "x$XORG" = xyes; then
 		xorg_bus_sparc="yes"
 		;;
 	esac
+	fi
+	AC_MSG_RESULT([$PCI])
+
 	dnl ===================================================================
 	dnl ==================== end of PCI configuration =====================
 	dnl ===================================================================
@@ -1768,6 +1775,7 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([abi_extension])
 fi
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
+AM_CONDITIONAL([XORG_BUS_PCI], [test "x$PCI" = xyes])
 AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
 AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 23ddb5c..a273721 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -1,5 +1,10 @@
 noinst_LTLIBRARIES = libcommon.la
 
+if XORG_BUS_PCI
+PCI_SOURCES = xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \
+              xf86VGAarbiterPriv.h
+endif
+
 if XORG_BUS_SPARC
 SBUS_SOURCES = xf86sbusBus.c
 endif
@@ -19,7 +24,7 @@ endif
 
 RANDRSOURCES = xf86RandR.c
 
-BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
+BUSSOURCES = xf86fbBus.c xf86noBus.c $(PCI_SOURCES) $(SBUS_SOURCES)
 
 MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
 
@@ -33,7 +38,7 @@ AM_LDFLAGS = -r
 libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
                       xf86Cursor.c $(DGASOURCES) xf86DPMS.c \
                       xf86Events.c xf86Globals.c xf86AutoConfig.c \
-                      xf86Option.c xf86Init.c xf86VGAarbiter.c \
+                      xf86Option.c xf86Init.c \
                       xf86VidMode.c xf86fbman.c xf86cmap.c \
                       xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
                       xf86Mode.c xorgHelper.c \
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index da9287b..3185baf 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -92,6 +92,7 @@ extern _X_EXPORT Bool VTSwitchEnabled;	/* kbd driver */
 #ifndef _NO_XF86_PROTOTYPES
 
 /* PCI related */
+#ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
 extern _X_EXPORT Bool pciSlotClaimed;
 
@@ -118,6 +119,15 @@ extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
 extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
         int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
         EntityProc enter, EntityProc leave, pointer private);
+#else
+#define xf86VGAarbiterInit() do {} while (0)
+#define xf86VGAarbiterFini() do {} while (0)
+#define xf86VGAarbiterLock(x) do {} while (0)
+#define xf86VGAarbiterUnlock(x) do {} while (0)
+#define xf86VGAarbiterScrnInit(x) do {} while (0)
+#define xf86VGAarbiterDeviceDecodes() do {} while (0)
+#define xf86VGAarbiterWrapFunctions() do {} while (0)
+#endif
 
 /* xf86Bus.c */
 
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 5c6e721..7fc6518 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -255,9 +255,9 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
 	    matches[i++] = xnfstrdup(sbusDriver);
     }
 #endif
-
+#ifdef XSERVER_LIBPCIACCESS
     i = xf86PciMatchDriver(matches, nmatches);
-
+#endif
     /* Fallback to platform default hardware */
     if (i < (nmatches - 1)) {
 #if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 8749a29..c665a20 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -47,8 +47,9 @@
 
 #define XF86_OS_PRIVS
 #include "xf86_OSproc.h"
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86VGAarbiter.h"
-
+#endif
 /* Entity data */
 EntityPtr *xf86Entities = NULL;	/* Bus slots claimed by drivers */
 int xf86NumEntities = 0;
@@ -75,7 +76,7 @@ Bool
 xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
 {
     Bool     foundScreen = FALSE;
-
+#ifdef XSERVER_LIBPCIACCESS
     if (drv->PciProbe != NULL) {
         if (xf86DoConfigure && xf86DoConfigurePass1) {
             assert(detect_only);
@@ -86,7 +87,7 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
             foundScreen = xf86PciProbeDev(drv);
         }
     }
-
+#endif
     if (!foundScreen && (drv->Probe != NULL)) {
         xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
                              drv->driverName);
@@ -195,7 +196,9 @@ xf86BusConfig(void)
 void
 xf86BusProbe(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     xf86PciProbe();
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
     xf86SbusProbe();
 #endif
@@ -504,9 +507,14 @@ xf86PostProbe(void)
 {
     int i;
 
-    if (fbSlotClaimed && (pciSlotClaimed
+    if (fbSlotClaimed && (
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-	    || sbusSlotClaimed
+	    sbusSlotClaimed ||
+#endif
+#ifdef XSERVER_LIBPCIACCESS
+	    pciSlotClaimed
+#else
+        TRUE
 #endif
 	    ))
 	    FatalError("Cannot run in framebuffer mode. Please specify busIDs "
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index f8c1b65..5c46152 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2398,7 +2398,7 @@ xf86HandleConfigFile(Bool autoconfig)
     }
 
     xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
-
+#ifdef XSERVER_LIBPCIACCESS
     if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
        ; /* IsolateDevice specified; overrides SingleCard */
     } else {
@@ -2413,7 +2413,7 @@ xf86HandleConfigFile(Bool autoconfig)
        } else
            xf86PciIsolateDevice(scanptr);
     }
-
+#endif
     /* Now process everything else */
     if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
              ErrorF ("Problem when converting the config data structures\n");
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index ab07515..99b8b48 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -87,9 +87,11 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
     /* Check for duplicates */
     for (i = 0;  i < nDevToConfig;  i++) {
         switch (bus) {
+#ifdef XSERVER_LIBPCIACCESS
             case BUS_PCI:
                 ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
-                break;
+	            break;
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
             case BUS_SBUS:
                 ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
@@ -118,10 +120,12 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
     for (j = 0;  (DevToConfig[i].GDev.driver[j] = tolower(driver[j]));  j++);
 
     switch (bus) {
+#ifdef XSERVER_LIBPCIACCESS
         case BUS_PCI:
             xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
                                    &DevToConfig[i].GDev, &chipset);
 	        break;
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
         case BUS_SBUS:
             xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index cd025dc..613c7cf 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -42,8 +42,9 @@
 #include <X11/extensions/dpmsconst.h>
 #include "dpmsproc.h"
 #endif
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86VGAarbiter.h"
-
+#endif
 
 #ifdef DPMSExtension
 static DevPrivateKeyRec DPMSKeyRec;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 350918d..74e0bc2 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -78,7 +78,9 @@
 #include "picturestr.h"
 
 #include "xf86Bus.h"
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86VGAarbiter.h"
+#endif
 #include "globals.h"
 #include "xserver-properties.h"
 
@@ -88,7 +90,6 @@
 #endif
 #include <hotplug.h>
 
-
 #ifdef XF86PM
 void (*xf86OSPMClose)(void) = NULL;
 #endif
@@ -1355,6 +1356,7 @@ ddxProcessArgument(int argc, char **argv, int i)
     xf86DoShowOptions = TRUE;
     return 1;
   }
+#ifdef XSERVER_LIBPCIACCESS
   if (!strcmp(argv[i], "-isolateDevice"))
   {
     CHECK_FOR_REQUIRED_ARGUMENT();
@@ -1364,6 +1366,7 @@ ddxProcessArgument(int argc, char **argv, int i)
     xf86PciIsolateDevice(argv[i]);
     return 2;
   }
+#endif
   /* Notice cmdline xkbdir, but pass to dix as well */
   if (!strcmp(argv[i], "-xkbdir"))
   {
@@ -1432,7 +1435,9 @@ ddxUseMsg(void)
 #endif
   ErrorF("-allowMouseOpenFail    start server even if the mouse can't be initialized\n");
   ErrorF("-ignoreABI             make module ABI mismatches non-fatal\n");
+#ifdef XSERVER_LIBPCIACCESS
   ErrorF("-isolateDevice bus_id  restrict device resets to bus_id (PCI only)\n");
+#endif
   ErrorF("-version               show the server version\n");
   ErrorF("-showDefaultModulePath show the server default module path\n");
   ErrorF("-showDefaultLibPath    show the server default library path\n");
diff --git a/hw/xfree86/common/xf86fbBus.c b/hw/xfree86/common/xf86fbBus.c
index 059e378..4592980 100644
--- a/hw/xfree86/common/xf86fbBus.c
+++ b/hw/xfree86/common/xf86fbBus.c
@@ -54,8 +54,10 @@ xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
     EntityPtr p;
     int num;
 
+#ifdef XSERVER_LIBPCIACCESS
     if (pciSlotClaimed)
 	return -1;
+#endif
 #if defined(__sparc__) || defined (__sparc64__)
     if (sbusSlotClaimed)
 	return -1;
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 43e9d1d..e2ca558 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -41,9 +41,6 @@
 #include "colormapst.h"
 #include "xf86Module.h"
 #include "xf86Opt.h"
-#include "xf86Pci.h"
-
-#include <pciaccess.h>
 
 /**
  * Integer type that is of the size of the addressable memory (machine size).
@@ -309,6 +306,8 @@ typedef struct {
 struct _SymTabRec;
 struct _PciChipsets;
 
+struct pci_device;
+
 typedef struct _DriverRec {
     int			driverVersion;
     char *		driverName;
@@ -350,8 +349,6 @@ typedef enum {
     BUS_last    /* Keep last */
 } BusType;
 
-struct pci_device;
-
 typedef struct {
     int		fbNum;
 } SbusBusId;
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 4a03428..669da0d 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -33,6 +33,7 @@
 #include <string.h>
 #include <stdio.h>
 
+#include <X11/Xarch.h>
 #include "xf86.h"
 #include "xf86DDC.h"
 #include "xf86Crtc.h"
diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index 16c1021..e09d4d2 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -1,7 +1,10 @@
 noinst_LTLIBRARIES = libbus.la
 sdk_HEADERS = xf86Pci.h
 
-PCI_SOURCES = Pci.c Pci.h
+PCI_SOURCES =
+if XORG_BUS_PCI
+PCI_SOURCES += Pci.c Pci.h
+endif
 
 if XORG_BUS_BSDPCI
 PCI_SOURCES += bsd_pci.c
diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 18bb735..19795d5 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -118,14 +118,16 @@ cat > sdksyms.c << EOF
 #include "xf86.h"
 #include "xf86Module.h"
 #include "xf86Opt.h"
-#include "xf86PciInfo.h"
+#ifdef XSERVER_LIBPCIACCESS
+ #include "xf86PciInfo.h"
+ #include "xf86VGAarbiter.h"
+#endif
 #include "xf86Priv.h"
 #include "xf86Privstr.h"
 #include "xf86cmap.h"
 #include "xf86fbman.h"
 #include "xf86str.h"
 #include "xf86Xinput.h"
-#include "xf86VGAarbiter.h"
 #include "xisb.h"
 #if XV
 # include "xf86xv.h"
@@ -170,7 +172,9 @@ cat > sdksyms.c << EOF
 
 
 /* hw/xfree86/os-support/bus/Makefile.am */
-#include "xf86Pci.h"
+#ifdef XSERVER_LIBPCIACCESS
+# include "xf86Pci.h"
+#endif
 #if defined(__sparc__) || defined(__sparc)
 # include "xf86Sbus.h"
 #endif
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 33bf908..6b9230f 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -127,4 +127,7 @@
 /* Build with libdrm support */
 #undef WITH_LIBDRM
 
+/* Use libpciaccess */
+#undef XSERVER_LIBPCIACCESS
+
 #endif /* _XORG_CONFIG_H_ */
commit cbabe831e615ee06bd58affba46c7af425cb6ddc
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon May 31 19:27:07 2010 +0300

    configure: make PCI configuration more sane
    
    No semantical changes. Just moved code around, grouping PCI related stuff in a
    single chunk.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index a7bec3d..2edeb4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1270,7 +1270,6 @@ if test "x$XDMAUTH" = xyes; then
 fi
 
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
-AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
 AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
 dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
@@ -1521,9 +1520,6 @@ if test "x$XORG" = xauto; then
 fi
 AC_MSG_RESULT([$XORG])
 
-xorg_bus_bsdpci=no
-xorg_bus_sparc=no
-
 if test "x$XORG" = xyes; then
 	XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
@@ -1571,10 +1567,32 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([symbol_visibility])
 	dnl ===================================================================
 
+	dnl ===================================================================
+	dnl ================= beginning of PCI configuration ==================
+	dnl ===================================================================
+	xorg_bus_bsdpci=no
+	xorg_bus_sparc=no
+
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
+	AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
+	AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
+	case $host_os in
+	  gnu* | freebsd* | kfreebsd*-gnu | netbsd* | openbsd* | solaris* | dragonfly*)
+		xorg_bus_bsdpci="yes"
+		;;
+	esac
+	case $host_cpu in
+	  sparc*)
+		xorg_bus_sparc="yes"
+		;;
+	esac
+	dnl ===================================================================
+	dnl ==================== end of PCI configuration =====================
+	dnl ===================================================================
+
 	case $host_os in
 	  linux*)
 		if test "x$LNXAPM" = xyes; then
@@ -1595,11 +1613,9 @@ if test "x$XORG" = xyes; then
 		;;
 	  freebsd* | kfreebsd*-gnu | dragonfly*)
 		XORG_OS_SUBDIR="bsd"
-		xorg_bus_bsdpci="yes"
 		;;
 	  netbsd*)
 		XORG_OS_SUBDIR="bsd"
-		xorg_bus_bsdpci="yes"
 		;;
 	  openbsd*)
 		if test "x$ac_cv_BSD_APM" = xyes \
@@ -1607,14 +1623,10 @@ if test "x$XORG" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		fi
 		XORG_OS_SUBDIR="bsd"
-		xorg_bus_bsdpci="yes"
 		;;
 	  solaris*)
 		XORG_OS_SUBDIR="solaris"
 		XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
-		# Use the same stubs as BSD for old functions, since we now
-		# use libpciaccess for PCI
-		xorg_bus_bsdpci="yes"
 		AC_CHECK_HEADERS([sys/kd.h])
 		AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no])
 		# Check for minimum supported release
@@ -1659,9 +1671,6 @@ if test "x$XORG" = xyes; then
 		;;
 	  gnu*)
 		XORG_OS_SUBDIR="hurd"
-		# Use the same stubs as BSD for old functions, since we now
-		# use libpciaccess for PCI
-		xorg_bus_bsdpci="yes"
 		;;
 	  *)
 		XORG_OS_SUBDIR="stub"
@@ -1674,9 +1683,6 @@ if test "x$XORG" = xyes; then
 	esac
 
 	case $host_cpu in
-	  sparc*)
-		xorg_bus_sparc="yes"
-		;;
 	  i*86)
 		;;
 	esac
@@ -1733,7 +1739,6 @@ if test "x$XORG" = xyes; then
 	AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
 	AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
 	AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
-	AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
 	if test "x$VGAHW" = xyes; then
 		AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
 	fi
commit 6d243a53e8a3ff6c5e9d92ab9fd22970c4916b04
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon May 31 18:50:50 2010 +0300

    configure: change PCI function checking by a meaningful version of the library
    
    People that don't want VGA arbiter active can go to the library and enable the
    stubs there.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/configure.ac b/configure.ac
index 2ff247d..a7bec3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1572,16 +1572,6 @@ if test "x$XORG" = xyes; then
 	dnl ===================================================================
 
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
-	SAVE_LIBS=$LIBS
-	SAVE_CFLAGS=$CFLAGS
-	CFLAGS=$PCIACCESS_CFLAGS
-	LIBS=$PCIACCESS_LIBS
-	AC_CHECK_FUNCS([pci_system_init_dev_mem])
-	AC_CHECK_FUNCS([pci_device_enable])
-	AC_CHECK_FUNCS([pci_device_is_boot_vga])
-	AC_CHECK_FUNCS([pci_device_vgaarb_init])
-	LIBS=$SAVE_LIBS
-	CFLAGS=$SAVE_CFLAGS
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 215e845..819ad6e 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -31,8 +31,6 @@
 #include "xorg-config.h"
 
 #include "xf86VGAarbiter.h"
-
-#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
 #include "xf86VGAarbiterPriv.h"
 #include "xf86Bus.h"
 #include "xf86Priv.h"
@@ -1112,16 +1110,3 @@ VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRe
     VGAPut();
     PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
 }
-#else
-/* dummy functions */
-void xf86VGAarbiterInit(void) {}
-void xf86VGAarbiterFini(void) {}
-
-void xf86VGAarbiterLock(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {}
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; }
-void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) {}
-Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; }
-
-#endif
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 2acf486..eb5323c 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -121,12 +121,10 @@ xf86PciProbe(void)
 	    xf86PciVideoInfo[num - 1] = info;
 
 	    pci_device_probe(info);
-#ifdef HAVE_PCI_DEVICE_IS_BOOT_VGA
 	    if (pci_device_is_boot_vga(info)) {
                 primaryBus.type = BUS_PCI;
                 primaryBus.id.pci = info;
             }
-#endif
 	    info->user_data = 0;
 	}
     }
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 7b4cea7..d54656f 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -175,10 +175,8 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	checkDevMem(TRUE);
 	pVidMem->linearSupported = useDevMem;
 
-#if HAVE_PCI_SYSTEM_INIT_DEV_MEM
 	if (useDevMem)
 		pci_system_init_dev_mem(devMemFd);
-#endif
 
 #ifdef HAS_MTRR_SUPPORT
 	if (useDevMem) {
diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c
index 2965b37..564447f 100644
--- a/hw/xfree86/os-support/linux/int10/linux.c
+++ b/hw/xfree86/os-support/linux/int10/linux.c
@@ -261,10 +261,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
 	    struct pci_device *rom_device =
 		xf86GetPciInfoForEntity(pInt->entityIndex);
 
-#if HAVE_PCI_DEVICE_ENABLE
 	    pci_device_enable(rom_device);
-#endif
-
 	    err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS));
 	    if (err) {
 		xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n",
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 0d1ea91..33bf908 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -118,18 +118,6 @@
 /* Have execinfo.h */
 #undef HAVE_EXECINFO_H
 
-/* Have pci_system_init_dev_mem() */
-#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM
-
-/* Define to 1 if you have the `pci_device_is_boot_vga' function. */
-#undef HAVE_PCI_DEVICE_IS_BOOT_VGA
-
-/* Have pci_enable_device */
-#undef HAVE_PCI_DEVICE_ENABLE
-
-/* Define to 1 if you have the `pci_device_vgaarb_init' function. */
-#undef HAVE_PCI_DEVICE_VGAARB_INIT
-
 /* Path to text files containing PCI IDs */
 #undef PCI_TXT_IDS_PATH
 
commit fc581a706b70429452c043c42f05870e2adafac1
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Sep 13 15:32:16 2011 -0500

    xfree86: Work around issue where ar may be told to make an archive with no contents
    
    Automake:
    
     "Be careful when selecting library components conditionally. Because building
     an empty library is not portable, you should ensure that any library
     always contains at least one object."
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index b1ca8f9..16c1021 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -12,7 +12,7 @@ PLATFORM_SOURCES = Sbus.c
 sdk_HEADERS += xf86Sbus.h
 endif
 
-libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES)
+libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES) nobus.c
 
 INCLUDES = $(XORG_INCS)
 
diff --git a/hw/xfree86/os-support/bus/nobus.c b/hw/xfree86/os-support/bus/nobus.c
new file mode 100644
index 0000000..ad23f52
--- /dev/null
+++ b/hw/xfree86/os-support/bus/nobus.c
@@ -0,0 +1 @@
+static void __noop_to_appease_ar__() { return; }
commit 2af7113965d3f026543145d4a61ee77ffed2be99
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Sep 13 15:38:45 2011 -0500

    xfree86: Add stubs for os-support to help adding new architecture support
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index 2148721..2ff247d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1674,8 +1674,8 @@ if test "x$XORG" = xyes; then
 		xorg_bus_bsdpci="yes"
 		;;
 	  *)
-		XORG_OS_SUBDIR="unknown"
-		AC_MSG_ERROR([m4_text_wrap(m4_join([ ],
+		XORG_OS_SUBDIR="stub"
+		AC_MSG_NOTICE([m4_text_wrap(m4_join([ ],
 		[Your OS is unknown. Xorg currently only supports Linux,],
 		[Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.],
 		[If you are interested in porting Xorg to your platform,],
@@ -2176,6 +2176,7 @@ hw/xfree86/os-support/hurd/Makefile
 hw/xfree86/os-support/misc/Makefile
 hw/xfree86/os-support/linux/Makefile
 hw/xfree86/os-support/solaris/Makefile
+hw/xfree86/os-support/stub/Makefile
 hw/xfree86/parser/Makefile
 hw/xfree86/ramdac/Makefile
 hw/xfree86/shadowfb/Makefile
diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 094563d..a0140a1 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -1,5 +1,5 @@
 SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
-DIST_SUBDIRS = bsd bus misc linux solaris hurd
+DIST_SUBDIRS = bsd bus misc linux solaris stub hurd
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
 
diff --git a/hw/xfree86/os-support/stub/Makefile.am b/hw/xfree86/os-support/stub/Makefile.am
new file mode 100644
index 0000000..a1156ef
--- /dev/null
+++ b/hw/xfree86/os-support/stub/Makefile.am
@@ -0,0 +1,19 @@
+noinst_LTLIBRARIES = libstub.la
+
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+
+INCLUDES = $(XORG_INCS)
+
+libstub_la_SOURCES = \
+	$(srcdir)/../shared/VTsw_noop.c \
+	$(srcdir)/../shared/agp_noop.c \
+	$(srcdir)/../shared/ioperm_noop.c \
+	$(srcdir)/../shared/kmod_noop.c \
+	$(srcdir)/../shared/pm_noop.c \
+	$(srcdir)/../shared/vidmem.c \
+	$(srcdir)/../shared/posix_tty.c \
+	$(srcdir)/../shared/sigio.c \
+	stub_bell.c \
+	stub_bios.c \
+	stub_init.c \
+	stub_video.c
diff --git a/hw/xfree86/os-support/stub/stub_bell.c b/hw/xfree86/os-support/stub/stub_bell.c
new file mode 100644
index 0000000..4862592
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_bell.c
@@ -0,0 +1,10 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+}
diff --git a/hw/xfree86/os-support/stub/stub_bios.c b/hw/xfree86/os-support/stub/stub_bios.c
new file mode 100644
index 0000000..8628316
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_bios.c
@@ -0,0 +1,12 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+		int Len)
+{
+	return -1;
+}
diff --git a/hw/xfree86/os-support/stub/stub_init.c b/hw/xfree86/os-support/stub/stub_init.c
new file mode 100644
index 0000000..36fd2b8
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_init.c
@@ -0,0 +1,26 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+void
+xf86OpenConsole()
+{
+}
+
+void
+xf86CloseConsole()
+{
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+	return 0;
+}
+
+void
+xf86UseMsg()
+{
+}
diff --git a/hw/xfree86/os-support/stub/stub_video.c b/hw/xfree86/os-support/stub/stub_video.c
new file mode 100644
index 0000000..3274968
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_video.c
@@ -0,0 +1,13 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+	pVidMem->initialised = TRUE;
+	return;
+}
commit eeff97722c3cfe9995fc62372bf2769303dc349e
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 19:26:13 2011 -0400

    incomplete: Remove xf86{Un,}MapVidMem
    
    And man does a lot of support code just fall away when you do that.
    
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index 15eb2a4..860bbd4 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -67,32 +67,6 @@ static unsigned long hae_mask;
 static unsigned long bus_base;
 static unsigned long sparse_size;
 
-static unsigned long
-memory_base(void)
-{
-    static unsigned long base = 0;
-
-    if (base == 0) {
-	size_t len = sizeof(base);
-	int error;
-#ifdef __OpenBSD__
-       int mib[3];
-
-       mib[0] = CTL_MACHDEP;
-       mib[1] = CPU_CHIPSET;
-       mib[2] = CPU_CHIPSET_MEM;
-
-       if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
-#else
-	if ((error = sysctlbyname("hw.chipset.memory", &base, &len,
-				  0, 0)) < 0)
-#endif
-	    FatalError("xf86MapVidMem: can't find memory\n");
-    }
-
-    return base;
-}
-
 static int
 has_bwx(void)
 {
@@ -156,30 +130,9 @@ dense_base(void)
 	return abw[0].abw_abst.abst_sys_start;
 }
 
-static unsigned long
-memory_base(void)
-{
-	if (abw_count < 0)
-		init_abw();
-	
-	if (abw_count > 1) {
-		xf86Msg(X_INFO, "memory base = %#lx\n", 
-			abw[1].abw_abst.abst_sys_start); /* XXXX */
-		return abw[1].abw_abst.abst_sys_start;
-	} else if (abw_count == 1) {
-		/* assume memory_base == dense_base */
-		xf86Msg(X_INFO, "memory base = %#lx\n",
-			abw[0].abw_abst.abst_sys_start); /* XXXX */
-		return abw[0].abw_abst.abst_sys_start;
-	} else {
-		xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
-		return 0;
-	}
-}
 #endif /* __NetBSD__ */
 
 #define BUS_BASE	dense_base()
-#define BUS_BASE_BWX	memory_base()
 
 /***************************************************************************/
 /* Video Memory Mapping section                                            */
@@ -199,11 +152,6 @@ static int  devMemFd = -1;
 #endif
 #define DEV_MEM "/dev/mem"
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
-static void unmapVidMemSparse(int, pointer, unsigned long);
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -286,12 +234,8 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
 	if (has_bwx()) {
 	    xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n");
-	    pVidMem->mapMem = mapVidMem;
-	    pVidMem->unmapMem = unmapVidMem;
 	} else {
 	    xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
-	    pVidMem->mapMem = mapVidMemSparse;
-	    pVidMem->unmapMem = unmapVidMemSparse;
 #ifndef __NetBSD__
 	    if (axpSystem == -1)
                 axpSystem = bsdGetAXP(); 
@@ -303,59 +247,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	pointer base;
-
-	checkDevMem(FALSE);
-	Base = Base & ((1L<<32) - 1);
-
-	if (useDevMem)
-	{
-	    if (devMemFd < 0) 
-	    {
-		FatalError("xf86MapVidMem: failed to open %s (%s)\n",
-			   DEV_MEM, strerror(errno));
-	    }
-	    base = mmap((caddr_t)0, Size,
-			(flags & VIDMEM_READONLY) ?
-			 PROT_READ : (PROT_READ | PROT_WRITE),
-			 MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
-	    if (base == MAP_FAILED)
-	    {
-		FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
-			   "xf86MapVidMem", DEV_MEM, Size, Base, 
-			   strerror(errno));
-	    }
-	    return base;
-	}
-		
-	/* else, mmap /dev/vga */
-	if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
-	{
-		FatalError("%s: Address 0x%lx outside allowable range\n",
-			   "xf86MapVidMem", Base);
-	}
-	base = mmap(0, Size,
-		    (flags & VIDMEM_READONLY) ?
-		     PROT_READ : (PROT_READ | PROT_WRITE),
-		    MAP_FLAGS, xf86Info.consoleFd,
-		    (unsigned long)Base + BUS_BASE);
-	if (base == MAP_FAILED)
-	{
-	    FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
-		       strerror(errno));
-	}
-	return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	munmap((caddr_t)Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -502,48 +393,6 @@ sethae(u_int64_t hae)
 }
 #endif /* __NetBSD__ */
 
-static pointer
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    static Bool was_here = FALSE;
-
-    if (!was_here) {
-      was_here = TRUE;
-
-      checkDevMem(FALSE);
-
-      xf86WriteMmio8 = writeSparse8;
-      xf86WriteMmio16 = writeSparse16;
-      xf86WriteMmio32 = writeSparse32;
-      xf86WriteMmioNB8 = writeSparseNB8;
-      xf86WriteMmioNB16 = writeSparseNB16;
-      xf86WriteMmioNB32 = writeSparseNB32;
-      xf86ReadMmio8 = readSparse8;
-      xf86ReadMmio16 = readSparse16;
-      xf86ReadMmio32 = readSparse32;
-	
-      memBase = mmap((caddr_t)0, 0x100000000,
-		     PROT_READ | PROT_WRITE,
-		     MAP_SHARED, devMemFd,
-		     (off_t) BUS_BASE);
-      memSBase = mmap((caddr_t)0, 0x100000000,
-		      PROT_READ | PROT_WRITE,
-		      MAP_SHARED, devMemFd,
-		      (off_t) BUS_BASE_BWX);
-      
-      if (memSBase == MAP_FAILED || memBase == MAP_FAILED)	{
-	FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
-		   strerror(errno));
-      }
-    }
-    return (pointer)((unsigned long)memBase + Base);
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
-{
-}
-
 static int
 readSparse8(pointer Base, register unsigned long Offset)
 {
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index eb631a7..b59c8e0 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -115,9 +115,6 @@ static int  devMemFd = -1;
 
 #define DEV_MEM "/dev/mem"
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -171,64 +168,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
 	checkDevMem(TRUE);
 	pVidMem->linearSupported = useDevMem;
-	pVidMem->mapMem = armMapVidMem;
-	pVidMem->unmapVidMem = armUnmapVidMem;
-
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	pointer base;
-
-	checkDevMem(FALSE);
-
-	if (useDevMem)
-	{
-	    if (devMemFd < 0) 
-	    {
-		FatalError("xf86MapVidMem: failed to open %s (%s)\n",
-			   DEV_MEM, strerror(errno));
-	    }
-	    base = mmap((caddr_t)0, Size,
-			(flags & VIDMEM_READONLY) ?
-			 PROT_READ : (PROT_READ | PROT_WRITE),
-			MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
-	    if (base == MAP_FAILED)
-	    {
-		FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
-			   "xf86MapVidMem", DEV_MEM, Size, Base, 
-			   strerror(errno));
-	    }
-	    return base;
-	}
-		
-	/* else, mmap /dev/vga */
-	if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
-	{
-		FatalError("%s: Address 0x%x outside allowable range\n",
-			   "xf86MapVidMem", Base);
-	}
-	base = mmap(0, Size,
-		    (flags & VIDMEM_READONLY) ?
-		     PROT_READ : (PROT_READ | PROT_WRITE),
-		    MAP_FLAGS, xf86Info.consoleFd,
-		    (unsigned long)Base - 0xA0000);
-	if (base == MAP_FAILED)
-	{
-	    FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
-		       strerror(errno));
-	}
-	return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	munmap((caddr_t)Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -403,50 +345,6 @@ xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
     }
 }
 
-static pointer
-armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	struct memAccess *memInfoP;
-	
-	if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
-	{
-	    /*
-	     ** xf86 passes in a physical address offset from the start
-	     ** of physical memory, but xf86MapInfoMap expects an 
-	     ** offset from the start of the specified region - it gets 
-	     ** the physical address of the region from the display driver.
-	     */
-	    switch(Region)
-	    {
-	        case LINEAR_REGION:
-		    if (vgaPhysLinearBase)
-		    {
-			Base -= vgaPhysLinearBase;
-		    }
-		    break;
-		case VGA_REGION:
-		    Base -= 0xA0000;
-		    break;
-	    }
-	    
-	    base = xf86MapInfoMap(memInfoP, Base, Size);
-	    return base;
-	}
-	return mapVidMem(ScreenNum, Base, Size, flags);
-}
-
-static void
-armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-        struct memAccess *memInfoP;
-	
-	if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
-	{
-	    xf86MapInfoUnmap(memInfoP, Base, Size);
-	}
-	unmapVidMem(ScreenNum, Base, Size);
-}
-
 #ifdef USE_DEV_IO
 static int IoFd = -1;
 
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 525bfb6..7b4cea7 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -44,17 +44,6 @@
 #define X_MTRR_ID "XFree86"
 #endif
 
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-#include <machine/mtrr.h>
-#include <machine/sysarch.h>
-#include <sys/queue.h>
-#ifdef __x86_64__
-#define i386_set_mtrr x86_64_set_mtrr
-#define i386_get_mtrr x86_64_get_mtrr
-#define i386_iopl x86_64_iopl
-#endif
-#endif
-
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
 
@@ -90,20 +79,6 @@ static int  devMemFd = -1;
 #endif
 #define DEV_MEM "/dev/mem"
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-
-#ifdef HAS_MTRR_SUPPORT
-static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, pointer);
-static Bool cleanMTRR(void);
-#endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
-			   MessageType);
-static void NetBSDundoWC(int, pointer);
-#endif
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -199,8 +174,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
 	checkDevMem(TRUE);
 	pVidMem->linearSupported = useDevMem;
-	pVidMem->mapMem = mapVidMem;
-	pVidMem->unmapMem = unmapVidMem;
 
 #if HAVE_PCI_SYSTEM_INIT_DEV_MEM
 	if (useDevMem)
@@ -210,71 +183,12 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 #ifdef HAS_MTRR_SUPPORT
 	if (useDevMem) {
 		if (cleanMTRR()) {
-			pVidMem->setWC = setWC;
-			pVidMem->undoWC = undoWC;
 		}
 	}
 #endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-	pVidMem->setWC = NetBSDsetWC;
-	pVidMem->undoWC = NetBSDundoWC;
-#endif
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	pointer base;
-
-	checkDevMem(FALSE);
-
-	if (useDevMem)
-	{
-	    if (devMemFd < 0) 
-	    {
-		FatalError("xf86MapVidMem: failed to open %s (%s)",
-			   DEV_MEM, strerror(errno));
-	    }
-	    base = mmap((caddr_t)0, Size,
-			(flags & VIDMEM_READONLY) ?
-			 PROT_READ : (PROT_READ | PROT_WRITE),
-			MAP_FLAGS, devMemFd, (off_t)Base);
-	    if (base == MAP_FAILED)
-	    {
-		FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
-			   "xf86MapVidMem", DEV_MEM, Size, Base, 
-			   strerror(errno));
-	    }
-	    return base;
-	}
-		
-	/* else, mmap /dev/vga */
-	if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
-	{
-		FatalError("%s: Address 0x%lx outside allowable range",
-			   "xf86MapVidMem", Base);
-	}
-	base = mmap(0, Size,
-		    (flags & VIDMEM_READONLY) ?
-		     PROT_READ : (PROT_READ | PROT_WRITE),
-		    MAP_FLAGS, xf86Info.consoleFd,
-		    (unsigned long)Base - 0xA0000
-	    );
-	if (base == MAP_FAILED)
-	{
-	    FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
-		       strerror(errno));
-	}
-	return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	munmap((caddr_t)Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -580,329 +494,4 @@ cleanMTRR()
 	return TRUE;
 }
 
-typedef struct x_RangeRec {
-	struct mem_range_desc	mrd;
-	Bool			wasWC;
-	struct x_RangeRec *	next;
-} RangeRec, *RangePtr;
-
-static void
-freeRangeList(RangePtr range)
-{
-	RangePtr rp;
-
-	while (range) {
-		rp = range;
-		range = rp->next;
-		free(rp);
-	}
-}
-
-static RangePtr
-dupRangeList(RangePtr list)
-{
-	RangePtr new = NULL, rp, p;
-
-	rp = list;
-	while (rp) {
-		p = xnfalloc(sizeof(RangeRec));
-		*p = *rp;
-		p->next = new;
-		new = p;
-		rp = rp->next;
-	}
-	return new;
-}
-
-static RangePtr
-sortRangeList(RangePtr list)
-{
-	RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
-	unsigned long minBase;
-
-	/* Sort by base address */
-	rp1 = copy = dupRangeList(list);
-	while (rp1) {
-		minBase = rp1->mrd.mr_base;
-		minp = rp1;
-		minprev = NULL;
-		prev = rp1;
-		rp2 = rp1->next;
-		while (rp2) {
-			if (rp2->mrd.mr_base < minBase) {
-				minBase = rp2->mrd.mr_base;
-				minp = rp2;
-				minprev = prev;
-			}
-			prev = rp2;
-			rp2 = rp2->next;
-		}
-		if (minprev) {
-			minprev->next = minp->next;
-			rp1 = copy;
-		} else {
-			rp1 = minp->next;
-		}
-		minp->next = sorted;
-		sorted = minp;
-	}
-	return sorted;
-}
-
-/*
- * findRanges returns a list of ranges that overlap the specified range.
- */
-
-static void
-findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp)
-{
-	struct mem_range_desc *mrd;
-	int nmr, i;
-	RangePtr rp, *p;
-	
-	if (!(mrd = getAllRanges(&nmr)))
-		return;
-
-	for (i = 0; i < nmr; i++) {
-		if ((mrd[i].mr_flags & MDF_ACTIVE) &&
-		    mrd[i].mr_base < base + size &&
-		    mrd[i].mr_base + mrd[i].mr_len > base) {
-			if (mrd[i].mr_flags & MDF_WRITECOMBINE)
-				p = wcp;
-			else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
-				p = ucp;
-			else
-				continue;
-			rp = xnfalloc(sizeof(RangeRec));
-			rp->mrd = mrd[i];
-			rp->next = *p;
-			*p = rp;
-		}
-	}
-	free(mrd);
-}
-
-/*
- * This checks if the existing overlapping ranges fully cover the requested
- * range.  Is this overkill?
- */
-
-static Bool
-fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
-{
-	RangePtr rp1, sorted = NULL;
-	unsigned long end;
-
-	sorted = sortRangeList(overlap);
-	/* Look for gaps */
-	rp1 = sorted;
-	end = base + size;
-	while (rp1) {
-		if (rp1->mrd.mr_base > base) {
-			freeRangeList(sorted);
-			return FALSE;
-		} else {
-			base = rp1->mrd.mr_base + rp1->mrd.mr_len;
-		}
-		if (base >= end) {
-			freeRangeList(sorted);
-			return TRUE;
-		}
-		rp1 = rp1->next;
-	}
-	freeRangeList(sorted);
-	return FALSE;
-}
-
-static pointer
-addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
-{
-	RangePtr uc = NULL, wc = NULL, retlist = NULL;
-	struct mem_range_desc mrd;
-	struct mem_range_op mro;
-
-	findRanges(base, size, &uc, &wc);
-
-	/* See of the full range is already WC */
-	if (!uc && fullCoverage(base, size, wc)) {
-		xf86DrvMsg(screenNum, from, 
-		   "Write-combining range (0x%lx,0x%lx) was already set\n",
-		    base, size);
-		return NULL;
-	}
-
-	/* Otherwise, try to add the new range */
-	mrd.mr_base = base;
-	mrd.mr_len = size;
-	strcpy(mrd.mr_owner, X_MTRR_ID);
-	mrd.mr_flags = MDF_WRITECOMBINE;
-	mro.mo_desc = &mrd;
-	mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-	if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
-		xf86DrvMsg(screenNum, X_WARNING,
-			   "Failed to set write-combining range "
-			   "(0x%lx,0x%lx)\n", base, size);
-		return NULL;
-	} else {
-		xf86DrvMsg(screenNum, from,
-			   "Write-combining range (0x%lx,0x%lx)\n", base, size);
-		retlist = xnfalloc(sizeof(RangeRec));
-		retlist->mrd = mrd;
-		retlist->wasWC = FALSE;
-		retlist->next = NULL;
-		return retlist;
-	}
-}
-
-static pointer
-delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
-{
-	RangePtr uc = NULL, wc = NULL, retlist = NULL;
-	struct mem_range_desc mrd;
-	struct mem_range_op mro;
-
-	findRanges(base, size, &uc, &wc);
-
-	/*
-	 * See of the full range is already not WC, or if there is full
-	 * coverage from UC ranges.
-	 */
-	if (!wc || fullCoverage(base, size, uc)) {
-		xf86DrvMsg(screenNum, from, 
-		   "Write-combining range (0x%lx,0x%lx) was already clear\n",
-		    base, size);
-		return NULL;
-	}
-
-	/* Otherwise, try to add the new range */
-	mrd.mr_base = base;
-	mrd.mr_len = size;
-	strcpy(mrd.mr_owner, X_MTRR_ID);
-	mrd.mr_flags = MDF_UNCACHEABLE;
-	mro.mo_desc = &mrd;
-	mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-	if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
-		xf86DrvMsg(screenNum, X_WARNING,
-			   "Failed to remove write-combining range "
-			   "(0x%lx,0x%lx)\n", base, size);
-		/* XXX Should then remove all of the overlapping WC ranges */
-		return NULL;
-	} else {
-		xf86DrvMsg(screenNum, from,
-			   "Removed Write-combining range (0x%lx,0x%lx)\n",
-			   base, size);
-		retlist = xnfalloc(sizeof(RangeRec));
-		retlist->mrd = mrd;
-		retlist->wasWC = TRUE;
-		retlist->next = NULL;
-		return retlist;
-	}
-}
-
-static pointer
-setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
-	MessageType from)
-{
-	if (enable)
-		return addWC(screenNum, base, size, from);
-	else
-		return delWC(screenNum, base, size, from);
-}
-
-static void
-undoWC(int screenNum, pointer list)
-{
-	RangePtr rp;
-	struct mem_range_op mro;
-	Bool failed;
-
-	rp = list;
-	while (rp) {
-#ifdef DEBUG
-		ErrorF("Undo for (0x%lx,0x%lx), %d\n",
-			(unsigned long)rp->mrd.mr_base,
-			(unsigned long)rp->mrd.mr_len, rp->wasWC);
-#endif
-		failed = FALSE;
-		if (rp->wasWC) {
-			mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-			rp->mrd.mr_flags = MDF_WRITECOMBINE;
-			strcpy(rp->mrd.mr_owner, "unknown");
-		} else {
-			mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
-		}
-		mro.mo_desc = &rp->mrd;
-
-		if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
-			if (!rp->wasWC) {
-				mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-				rp->mrd.mr_flags = MDF_UNCACHEABLE;
-				strcpy(rp->mrd.mr_owner, "unknown");
-				if (ioctl(devMemFd, MEMRANGE_SET, &mro))
-					failed = TRUE;
-			} else
-				failed = TRUE;
-		}
-		if (failed) {
-			xf86DrvMsg(screenNum, X_WARNING,
-				"Failed to restore MTRR range (0x%lx,0x%lx)\n",
-				(unsigned long)rp->mrd.mr_base,
-				(unsigned long)rp->mrd.mr_len);
-		}
-		rp = rp->next;
-	}
-}
-
 #endif /* HAS_MTRR_SUPPORT */
-
-
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static pointer
-NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
-	    MessageType from)
-{
-	struct mtrr *mtrrp;
-	int n;
-
-	xf86DrvMsg(screenNum, X_WARNING,
-		   "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
-		   base, (base + size));
-
-	mtrrp = xnfalloc(sizeof (struct mtrr));
-	mtrrp->base = base;
-	mtrrp->len = size;
-	mtrrp->type = MTRR_TYPE_WC;
-
-	/*
-	 * MTRR_PRIVATE will make this MTRR get reset automatically
-	 * if this process exits, so we have no need for an explicit
-	 * cleanup operation when starting a new server.
-	 */
-
-	if (enable)
-		mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
-	else
-		mtrrp->flags = 0;
-	n = 1;
-
-	if (i386_set_mtrr(mtrrp, &n) < 0) {
-		free(mtrrp);
-		return NULL;
-	}
-	return mtrrp;
-}
-
-static void
-NetBSDundoWC(int screenNum, pointer list)
-{
-	struct mtrr *mtrrp = (struct mtrr *)list;
-	int n;
-
-	if (mtrrp == NULL)
-		return;
-	n = 1;
-	mtrrp->flags &= ~MTRR_VALID;
-	i386_set_mtrr(mtrrp, &n);
-	free(mtrrp);
-}
-#endif
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index aeaf183..7bf3677 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -51,9 +51,6 @@
 #define DEV_MEM "/dev/xf86"
 #endif
 
-static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags);
-static void ppcUnmapVidMem(int, pointer, unsigned long);
-
 Bool xf86EnableIO(void);
 void xf86DisableIO(void);
 
@@ -61,42 +58,12 @@ void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
 	pVidMem->linearSupported = TRUE;
-	pVidMem->mapMem = ppcMapVidMem;
-	pVidMem->unmapMem = ppcUnmapVidMem;
 	pVidMem->initialised = TRUE;
 	xf86EnableIO();
 }
 
-
 volatile unsigned char *ioBase = MAP_FAILED;
 
-static pointer
-ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	int fd = xf86Info.consoleFd;
-	pointer base;
-#ifdef DEBUG
-	xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", 
-		    Base, Size, fd);
-#endif
-
-	base = mmap(0, Size,
-		    (flags & VIDMEM_READONLY) ?
-		     PROT_READ : (PROT_READ | PROT_WRITE),
-		    MAP_SHARED, fd, Base);
-	if (base == MAP_FAILED)
-		FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
-			   "xf86MapVidMem", Size, Base, strerror(errno));
-
-	return base;
-}
-
-static void
-ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	munmap(Base, Size);
-}
-
 int
 xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
 	     int Len)
diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c
index a2a30c9..e61ad13 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -42,50 +42,16 @@
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int);
-static void sparc64UnmapVidMem(int, pointer, unsigned long);
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
 	pVidMem->linearSupported = TRUE;
-	pVidMem->mapMem = sparc64MapVidMem;
-	pVidMem->unmapMem = sparc64UnmapVidMem;
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, 
-		 int flags)
-{
-	int fd = xf86Info.consoleFd;
-	pointer base;
-
-#ifdef DEBUG
-	xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", 
-		    Base, Size, fd);
-#endif
-
-	base = mmap(0, Size,
-		    (flags & VIDMEM_READONLY) ?
-		     PROT_READ : (PROT_READ | PROT_WRITE),
-		    MAP_SHARED, fd, Base);
-	if (base == MAP_FAILED)
-		FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
-			   "xf86MapVidMem", Size, Base, strerror(errno));
-	return base;
-}
-
-static void
-sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	munmap(Base, Size);
-}
-
 int
 xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
 	     int Len)
 {
-
 	return 0;
 }
diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index 39f353b..db280b5 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -39,75 +39,6 @@
 #include "xf86OSpriv.h"
 
 /**************************************************************************
- * Video Memory Mapping section                                            
- ***************************************************************************/
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
-{
-    mach_port_t device,mem_dev;
-    memory_object_t mem_obj;
-    kern_return_t err;
-    vm_address_t addr=(vm_address_t)0;
-
-    err = get_privileged_ports (NULL, &device);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",strerror(errno));
-    }
-    err = device_open(device,D_READ|D_WRITE,"mem",&mem_dev);
-    mach_port_deallocate (mach_task_self(), device);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86MapVidMem() can't device_open. (%s)\n",strerror(errno));
-    }
-
-    err = device_map(mem_dev,VM_PROT_READ|VM_PROT_WRITE, Base , Size ,&mem_obj,0);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno));
-    }
-    err = vm_map(mach_task_self(),
-		 &addr,
-		 Size,
-		 0,     /* mask */
-		 TRUE,  /* anywhere */
-		 mem_obj,
-		 (vm_offset_t)Base,
-		 FALSE, /* copy on write */
-		 VM_PROT_READ|VM_PROT_WRITE,
-		 VM_PROT_READ|VM_PROT_WRITE,
-		 VM_INHERIT_SHARE);
-    mach_port_deallocate(mach_task_self(),mem_obj);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86MapVidMem() can't vm_map.(mem_obj) (%s)\n",strerror(errno));
-    }
-    mach_port_deallocate(mach_task_self(),mem_dev);
-    if( err )
-    {
-	errno = err;
-	FatalError("xf86MapVidMem() can't mach_port_deallocate.(mem_dev) (%s)\n",strerror(errno));
-    }
-    return (pointer)addr;
-}
-
-static void
-unmapVidMem(int ScreenNum,pointer Base,unsigned long Size)
-{
-    kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size);
-    if( err )
-    {
-	errno = err;
-	ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno));
-    }
-    return;
-}
-
-/**************************************************************************
  * I/O Permissions section                                                 
  ***************************************************************************/
 
@@ -149,7 +80,5 @@ void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
 	pVidMem->linearSupported = TRUE;
-	pVidMem->mapMem = mapVidMem;
-	pVidMem->unmapMem = unmapVidMem;
 	pVidMem->initialised = TRUE;
 }
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 3d45511..18116bd 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -42,10 +42,6 @@
 #include "shared/xf86Axp.h"
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-#include <asm/mtrr.h>
-#endif
-
 #ifndef MAP_FAILED
 #define MAP_FAILED ((void *)-1)
 #endif
@@ -83,16 +79,12 @@ extern int iopl(int __level);
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
 #if defined (__alpha__) 
 extern void sethae(unsigned long hae);
 extern unsigned long _bus_base __P ((void)) __attribute__ ((const));
 extern unsigned long _bus_base_sparse __P ((void)) __attribute__ ((const));
 
-static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
 extern axpDevice lnxGetAXP(void);
-static void unmapVidMemSparse(int, pointer, unsigned long);
 static axpDevice axpSystem = -1;
 static Bool needSparse;
 static unsigned long hae_thresh;
@@ -100,269 +92,6 @@ static unsigned long hae_mask;
 static unsigned long bus_base;
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-
-#define SPLIT_WC_REGIONS 1
-
-static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, pointer);
-
-/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
-   driver will clean up when we exit. */
-#define MTRR_FD_UNOPENED (-1)	/* We have yet to open /proc/mtrr */
-#define MTRR_FD_PROBLEM (-2)	/* We tried to open /proc/mtrr, but had
-				   a problem. */
-static int mtrr_fd = MTRR_FD_UNOPENED;
-
-/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, 
-   and will fail on Linux 2.2 with MTRR support configured out,
-   so verbosity should be chosen appropriately. */
-static Bool
-mtrr_open(int verbosity)
-{
-	/* Only report absence of /proc/mtrr once. */
-	static Bool warned = FALSE;
-
-	if (mtrr_fd == MTRR_FD_UNOPENED) { 
-		mtrr_fd = open("/proc/mtrr", O_WRONLY);
-
-		if (mtrr_fd < 0)
-			mtrr_fd = MTRR_FD_PROBLEM;
-	}
-
-	if (mtrr_fd == MTRR_FD_PROBLEM) {
-		/* To make sure we only ever warn once, need to check
-		   verbosity outside xf86MsgVerb */
-		if (!warned && verbosity <= xf86GetVerbosity()) {
-			xf86MsgVerb(X_WARNING, verbosity,
-				  "System lacks support for changing MTRRs\n");
-			warned = TRUE;
-		}
-
-		return FALSE;
-	}
-	else
-		return TRUE;
-}
-
-/*
- * We maintain a list of WC regions for each physical mapping so they can
- * be undone when unmapping.
- */
-
-struct mtrr_wc_region {
-	struct mtrr_sentry	sentry;
-	Bool			added;		/* added WC or removed it */
-	struct mtrr_wc_region *	next;
-};
-
-
-static struct mtrr_wc_region *
-mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
-		      MessageType from)
-{
-	/* Some BIOS writers thought that setting wc over the mmio
-	   region of a graphics devices was a good idea. Try to fix
-	   it. */
-
-	struct mtrr_gentry gent;
-	struct mtrr_wc_region *wcreturn = NULL, *wcr;
-	int count, ret=0;
-
-	/* Linux 2.0 users should not get a warning without -verbose */
-	if (!mtrr_open(2))
-		return NULL;
-
-	for (gent.regnum = 0; 
-	     ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0;
-	     gent.regnum++) {
-		if (gent.type != MTRR_TYPE_WRCOMB
-		    || gent.base + gent.size <= base
-		    || base + size <= gent.base)
-			continue;
-
-		/* Found an overlapping region. Delete it. */
-		
-		wcr = malloc(sizeof(*wcr));
-		if (!wcr)
-			return NULL;
-		wcr->sentry.base = gent.base;
-		wcr->sentry.size = gent.size;
-		wcr->sentry.type = MTRR_TYPE_WRCOMB;
-		wcr->added = FALSE;
-		
-		count = 3;
-		while (count-- && 
-		       (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0);
-		
-		if (ret >= 0) {
-			xf86DrvMsg(screenNum, from,
-				   "Removed MMIO write-combining range "
-				   "(0x%lx,0x%lx)\n",
-				   (unsigned long) gent.base, (unsigned long) gent.size);
-			wcr->next = wcreturn;
-			wcreturn = wcr;
-			gent.regnum--;
-		} else {
-			free(wcr);
-			xf86DrvMsgVerb(screenNum, X_WARNING, 0,
-				   "Failed to remove MMIO "
-				   "write-combining range (0x%lx,0x%lx)\n",
-				       gent.base, (unsigned long) gent.size);
-		}
-	}
-	return wcreturn;
-}
-
-
-static struct mtrr_wc_region *
-mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size,
-		      MessageType from)
-{
-    struct mtrr_gentry gent;
-    struct mtrr_wc_region *wcreturn = NULL, **wcr;
-
-    if (!mtrr_open(2))
-	return NULL;
-
-    wcr = &wcreturn;
-    for (gent.regnum = 0; 
-	 ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++ ) {
-	if (gent.type == MTRR_TYPE_WRCOMB
-	    && ((gent.base >= base && gent.base + gent.size < base + size) || 
-		(gent.base >  base && gent.base + gent.size <= base + size))) {
-	    *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from);
-	    if (*wcr) gent.regnum--;
-	    while(*wcr) {
-		wcr = &((*wcr)->next);
-	    }
-	}
-    }
-    return wcreturn;
-}
-
-
-static struct mtrr_wc_region *
-mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
-		   MessageType from)
-{
-        struct mtrr_wc_region **wcr, *wcreturn, *curwcr;
-
-       /*
-        * There can be only one....
-        */
-
-	wcreturn = mtrr_remove_offending(screenNum, base, size, from);
-	wcr = &wcreturn;
-	while (*wcr) {
-	    wcr = &((*wcr)->next);
-	} 
-
-	/* Linux 2.0 should not warn, unless the user explicitly asks for
-	   WC. */
-
-	if (!mtrr_open(from == X_CONFIG ? 0 : 2))
-		return wcreturn;
-
-	*wcr = curwcr = malloc(sizeof(**wcr));
-	if (!curwcr)
-	    return wcreturn;
-
-	curwcr->sentry.base = base;
-	curwcr->sentry.size = size;
-	curwcr->sentry.type = MTRR_TYPE_WRCOMB;
-	curwcr->added = TRUE;
-	curwcr->next = NULL;
-
-#if SPLIT_WC_REGIONS
-	/*
-	 * Splits up the write-combining region if it is not aligned on a
- 	 * size boundary.
-	 */
-
-	{
-	    unsigned long lbase, d_size = 1;
-	    unsigned long n_size = size;
-	    unsigned long n_base = base;
-
-	    for (lbase = n_base, d_size = 1; !(lbase & 1);
-		 lbase = lbase >> 1, d_size <<= 1);
-	    while (d_size > n_size)
-		d_size = d_size >> 1;
-	    DebugF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1);
-	    n_base += d_size;
-	    n_size -= d_size;
-	    if (n_size) {
-		xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: "
-			       "base: 0x%lx, size: 0x%lx\n",base,size);
-		curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from);
-	    }
-	    curwcr->sentry.size = d_size;
-	} 
-	
-	/*****************************************************************/
-#endif /* SPLIT_WC_REGIONS */
-
-	if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) {
-		/* Avoid printing on every VT switch */
-		if (xf86ServerIsInitialising()) {
-			xf86DrvMsg(screenNum, from,
-				   "Write-combining range (0x%lx,0x%lx)\n",
-				   base, size);
-		}
-		return wcreturn;
-	}
-	else {
-	        *wcr = curwcr->next;
-		free(curwcr);
-		
-		/* Don't complain about the VGA region: MTRR fixed
-		   regions aren't currently supported, but might be in
-		   the future. */
-		if ((unsigned long)base >= 0x100000) {
-			xf86DrvMsgVerb(screenNum, X_WARNING, 0,
-				"Failed to set up write-combining range "
-				"(0x%lx,0x%lx)\n", base, size);
-		}
-		return wcreturn;
-	}
-}
-
-static void
-mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
-{
-	struct mtrr_wc_region *p, *prev;
-
-	if (mtrr_fd >= 0) {
-		p = wcr;
-		while (p) {
-			if (p->added)
-				ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
-			prev = p;
-			p = p->next;
-			free(prev);
-		}
-	}
-}
-
-static pointer
-setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
-      MessageType from)
-{
-	if (enable)
-		return mtrr_add_wc_region(screenNum, base, size, from);
-	else
-		return mtrr_cull_wc_region(screenNum, base, size, from);
-}
-
-static void
-undoWC(int screenNum, pointer regioninfo)
-{
-	mtrr_undo_wc_region(screenNum, regioninfo);
-}
-
-#endif /* HAS_MTRR_SUPPORT */
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
@@ -378,105 +107,14 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	}
 	if (needSparse) {
 	  xf86Msg(X_INFO,"Machine needs sparse mapping\n");
-	  pVidMem->mapMem = mapVidMemSparse;
-	  pVidMem->unmapMem = unmapVidMemSparse;
 	} else {
 	  xf86Msg(X_INFO,"Machine type has 8/16 bit access\n");
-	  pVidMem->mapMem = mapVidMem;
-	  pVidMem->unmapMem = unmapVidMem;
 	}	
-#else
-	pVidMem->mapMem = mapVidMem;
-	pVidMem->unmapMem = unmapVidMem;
 #endif /* __alpha__ */
 
-
-#ifdef HAS_MTRR_SUPPORT
-	pVidMem->setWC = setWC;
-	pVidMem->undoWC = undoWC;
-#endif
 	pVidMem->initialised = TRUE;
 }
 
-#ifdef __sparc__
-/* Basically, you simply cannot do this on Sparc.  You have to do something portable
- * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
- */
-static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	return NULL;
-}
-#else
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    pointer base;
-    int fd;
-    int mapflags = MAP_SHARED; 
-    int prot;
-    memType realBase, alignOff;
-
-    realBase = Base & ~(getpagesize() - 1);
-    alignOff = Base - realBase;
-    DebugF("base: %lx, realBase: %lx, alignOff: %lx \n",
-	   Base,realBase,alignOff);
-
-#if defined(__ia64__) || defined(__arm__) || defined(__s390__)
-#ifndef MAP_WRITECOMBINED
-#define MAP_WRITECOMBINED 0x00010000
-#endif
-#ifndef MAP_NONCACHED
-#define MAP_NONCACHED 0x00020000
-#endif
-    if(flags & VIDMEM_FRAMEBUFFER) 
-        mapflags |= MAP_WRITECOMBINED; 
-    else
-        mapflags |= MAP_NONCACHED; 
-#endif
-
-#if 0
-    /* this will disappear when people upgrade their kernels */
-    fd = open(DEV_MEM,
-	      ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC);
-#else
-    fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
-#endif
-    if (fd < 0)
-    {
-	FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
-		   strerror(errno));
-    }
-
-    if (flags & VIDMEM_READONLY)
-	prot = PROT_READ;
-    else
-	prot = PROT_READ | PROT_WRITE;
-
-    /* This requires linux-0.99.pl10 or above */
-    base = mmap((caddr_t)0, Size + alignOff, prot, mapflags, fd,
- 		(off_t)realBase  + BUS_BASE);
-    close(fd);
-    if (base == MAP_FAILED) {
-        FatalError("xf86MapVidMem: Could not mmap framebuffer"
-		   " (0x%08lx,0x%lx) (%s)\n", Base, Size,
-		   strerror(errno));
-    }
-    DebugF("base: %lx aligned base: %lx\n",base, (char *)base + alignOff);
-    return (char *)base + alignOff;
-}
-#endif /* !(__sparc__) */
-    
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-    memType alignOff = (memType)Base 
-	- ((memType)Base & ~(getpagesize() - 1));
-
-    DebugF("alignment offset: %lx\n",alignOff);
-    munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff));
-}
-
-
 /***************************************************************************/
 /* I/O Permissions section                                                 */
 /***************************************************************************/
@@ -599,115 +237,6 @@ writeSparse32(int Value, pointer Base, register unsigned long Offset);
 
 static unsigned long msb_set = 0;
 
-static pointer
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    int fd, prot;
-    unsigned long ret, rets = 0;
-
-    static Bool was_here = FALSE;
-
-    if (!was_here) {
-      was_here = TRUE;
-
-      xf86WriteMmio8 = writeSparse8;
-      xf86WriteMmio16 = writeSparse16;
-      xf86WriteMmio32 = writeSparse32;
-      xf86WriteMmioNB8 = writeSparseNB8;
-      xf86WriteMmioNB16 = writeSparseNB16;
-      xf86WriteMmioNB32 = writeSparseNB32;
-      xf86ReadMmio8 = readSparse8;
-      xf86ReadMmio16 = readSparse16;
-      xf86ReadMmio32 = readSparse32;
-    }
-	
-    fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
-    if (fd < 0) {
-        FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
-		   strerror(errno));
-    }
-
-#if 0
-    xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
-	    Base, Size, flags);
-#endif
-
-    if (flags & VIDMEM_READONLY)
-	prot = PROT_READ;
-    else
-	prot = PROT_READ | PROT_WRITE;
-
-    /* This requirers linux-0.99.pl10 or above */
-
-    /*
-     * Always do DENSE mmap, since read32/write32 currently require it.
-     */
-    ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size,
-		   prot, MAP_SHARED, fd,
-		   (off_t) (bus_base + Base));
-
-    /*
-     * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
-     * and SPARSE (which should require the use of read/write macros).
-     *
-     * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K
-     * bytes worth of pagetable (32 pages).
-     */
-    if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
-	((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
-    {
-        rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)),
-				   Size << 5, prot, MAP_SHARED, fd,
-				   (off_t) _bus_base_sparse() + (Base << 5));
-    }
-
-    close(fd);
-      
-    if (ret == (unsigned long)MAP_FAILED) {
-        FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
-		   strerror(errno));
-    }
-
-    if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
-	((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE)))
-    {
-        if (rets == (unsigned long)MAP_FAILED ||
-	    rets != (SPARSE_BASE + (Base << 5)))
-	{
-	    FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
-		       strerror(errno));
-	}
-    }
-
-#if 1
-    if (rets)
-        xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
-		" to DENSE at 0x%lx and SPARSE at 0x%lx\n",
-		Base, Size, ret, rets);
-    else
-        xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
-		" to DENSE only at 0x%lx\n",
-		Base, Size, ret);
-
-#endif
-    return (pointer) ret;
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
-{
-    unsigned long Offset = (unsigned long)Base - DENSE_BASE;
-#if 1
-    xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
-	    Base, Size);
-#endif
-    /* Unmap DENSE always. */
-    munmap((caddr_t)Base, Size);
-
-    /* Unmap SPARSE always, and ignore error in case we did not map it. */
-    munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5);
-}
-
 static int
 readSparse8(pointer Base, register unsigned long Offset)
 {
diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index 54f6c64..146ce8b 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -25,7 +25,6 @@
  * authorization from the copyright holder(s) and author(s).
  */
 
-
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
@@ -43,133 +42,7 @@
  * This file contains the common part of the video memory mapping functions
  */
 
-/*
- * Get a piece of the ScrnInfoRec.  At the moment, this is only used to hold
- * the MTRR option information, but it is likely to be expanded if we do
- * auto unmapping of memory at VT switch.
- *
- */
-
-typedef struct {
-	unsigned long 	size;
-	pointer		virtBase;
-	pointer 	mtrrInfo;
-} MappingRec, *MappingPtr;
-	
-typedef struct {
-	int		numMappings;
-	MappingPtr *	mappings;
-	Bool		mtrrEnabled;
-	MessageType	mtrrFrom;
-	Bool		mtrrOptChecked;
-	ScrnInfoPtr	pScrn;
-} VidMapRec, *VidMapPtr;
-
-static int vidMapIndex = -1;
-
-#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
-
 static VidMemInfo vidMemInfo = {FALSE, };
-static VidMapRec  vidMapRec  = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL};
-
-static VidMapPtr
-getVidMapRec(int scrnIndex)
-{
-	VidMapPtr vp;
-	ScrnInfoPtr pScrn;
-
-	if ((scrnIndex < 0) ||
-	    !(pScrn = xf86Screens[scrnIndex]))
-		return &vidMapRec;
-
-	if (vidMapIndex < 0)
-		vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
-
-	if (VIDMAPPTR(pScrn) != NULL)
-		return VIDMAPPTR(pScrn);
-
-	vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
-	vp->mtrrEnabled = TRUE;	/* default to enabled */
-	vp->mtrrFrom = X_DEFAULT;
-	vp->mtrrOptChecked = FALSE;
-	vp->pScrn = pScrn;
-	return vp;
-}
-
-static MappingPtr
-newMapping(VidMapPtr vp)
-{
-	vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
-				  (vp->numMappings + 1));
-	vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
-	return vp->mappings[vp->numMappings++];
-}
-
-static MappingPtr
-findMapping(VidMapPtr vp, pointer vbase, unsigned long size)
-{
-	int i;
-
-	for (i = 0; i < vp->numMappings; i++) {
-		if (vp->mappings[i]->virtBase == vbase &&
-		    vp->mappings[i]->size == size)
-			return vp->mappings[i];
-	}
-	return NULL;
-}
-
-static void
-removeMapping(VidMapPtr vp, MappingPtr mp)
-{
-	int i, found = 0;
-
-	for (i = 0; i < vp->numMappings; i++) {
-		if (vp->mappings[i] == mp) {
-			found = 1;
-			free(vp->mappings[i]);
-		} else if (found) {
-			vp->mappings[i - 1] = vp->mappings[i];
-		}
-	}
-	vp->numMappings--;
-	vp->mappings[vp->numMappings] = NULL;
-}
-
-enum { OPTION_MTRR };
-static const OptionInfoRec opts[] =
-{
-	{ OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE },
-	{ -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-
-static void
-checkMtrrOption(VidMapPtr vp)
-{
-	if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
-		OptionInfoPtr options;
-
-		options = xnfalloc(sizeof(opts));
-		(void)memcpy(options, opts, sizeof(opts));
-		xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
-					options);
-		if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
-			vp->mtrrFrom = X_CONFIG;
-		free(options);
-		vp->mtrrOptChecked = TRUE;
-	}
-}
-
-void
-xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
-{
-	VidMapPtr vp;
-	MappingPtr mp;
-
-	vp = getVidMapRec(ScreenNum);
-	mp = newMapping(vp);
-	mp->size = Size;
-	mp->virtBase = Vbase;
-}
 
 void
 xf86InitVidMem(void)
@@ -180,111 +53,9 @@ xf86InitVidMem(void)
 	}
 }
 
-pointer
-xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
-{
-	pointer vbase = NULL;
-	VidMapPtr vp;
-	MappingPtr mp;
-
-	if (((Flags & VIDMEM_FRAMEBUFFER) &&
-	     (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
-	    FatalError("Mapping memory with more than one type\n");
-	    
-	xf86InitVidMem();
-	if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
-		return NULL;
-
-	vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
-
-	if (!vbase || vbase == (pointer)-1)
-		return NULL;
-
-	vp = getVidMapRec(ScreenNum);
-	mp = newMapping(vp);
-	mp->size = Size;
-	mp->virtBase = vbase;
-
-	/*
-	 * Check the "mtrr" option even when MTRR isn't supported to avoid
-	 * warnings about unrecognised options.
-	 */
-	checkMtrrOption(vp);
-
-	if (vp->mtrrEnabled && vidMemInfo.setWC) {
-		if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
-			mp->mtrrInfo =
-				vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
-						 vp->mtrrFrom);
-		else if (Flags & VIDMEM_FRAMEBUFFER)
-			mp->mtrrInfo =
-				vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
-						 vp->mtrrFrom);
-	}
-	return vbase;
-}
-
-void
-xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	VidMapPtr vp;
-	MappingPtr mp;
-
-	if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
-		xf86DrvMsg(ScreenNum, X_WARNING,
-		  "xf86UnMapVidMem() called before xf86MapVidMem()\n");
-		return;
-	}
-
-	vp = getVidMapRec(ScreenNum);
-	mp = findMapping(vp, Base, Size);
-	if (!mp) {
-		xf86DrvMsg(ScreenNum, X_WARNING,
-		  "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
-		  Base, Size);
-		return;
-	}
-	if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
-		vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
-
-	vidMemInfo.unmapMem(ScreenNum, Base, Size);
-	removeMapping(vp, mp);
-}
-
-Bool
-xf86CheckMTRR(int ScreenNum)
-{
-	VidMapPtr vp = getVidMapRec(ScreenNum);
-
-	/*
-	 * Check the "mtrr" option even when MTRR isn't supported to avoid
-	 * warnings about unrecognised options.
-	 */
-	checkMtrrOption(vp);
-
-	if (vp->mtrrEnabled && vidMemInfo.setWC)
-		return TRUE;
-		
-	return FALSE;
-}
-
 Bool
 xf86LinearVidMem(void)
 {
 	xf86InitVidMem();
 	return vidMemInfo.linearSupported;
 }
-
-void
-xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
-			unsigned long Size)
-{
-	if (!(Flags & VIDMEM_READSIDEEFFECT))
-		return;
-
-	if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
-		return;
-
-	vidMemInfo.readSideEffects(ScreenNum, base, Size);
-}
-
diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h
index 754128d..cb85602 100644
--- a/hw/xfree86/os-support/xf86OSpriv.h
+++ b/hw/xfree86/os-support/xf86OSpriv.h
@@ -32,22 +32,8 @@
 #ifndef _XF86OSPRIV_H
 #define _XF86OSPRIV_H
 
-typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int);
-typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long);
-typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool,
-				MessageType);
-typedef void (*ProtectMemProcPtr)(int, pointer, unsigned long, Bool); 
-typedef void (*UndoWCProcPtr)(int, pointer);
-typedef void (*ReadSideEffectsProcPtr)(int, pointer, unsigned long);
-
 typedef struct {
 	Bool			initialised;
-	MapMemProcPtr		mapMem;
-	UnmapMemProcPtr		unmapMem;
-	ProtectMemProcPtr	protectMem;
-	SetWCProcPtr		setWC;
-	UndoWCProcPtr		undoWC;
-	ReadSideEffectsProcPtr	readSideEffects;
 	Bool			linearSupported;
 } VidMemInfo, *VidMemInfoPtr;
 
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 6a29fbd..e844d10 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -75,24 +75,6 @@
  */ 
 
 /*
- * Flags for xf86MapVidMem().  Multiple flags can be or'd together.  The
- * flags may be used as hints.  For example it would be permissible to
- * enable write combining for memory marked only for framebuffer use.
- */
-
-#define VIDMEM_FRAMEBUFFER	0x01	/* memory for framebuffer use */
-#define VIDMEM_MMIO		0x02	/* memory for I/O use */
-#define VIDMEM_MMIO_32BIT	0x04	/* memory accesses >= 32bit */
-#define VIDMEM_READSIDEEFFECT	0x08	/* reads can have side-effects */
-#define VIDMEM_SPARSE		0x10	/* sparse mapping required
-					 * assumed when VIDMEM_MMIO is
-					 * set. May be used with
-					 * VIDMEM_FRAMEBUFFER) */
-#define VIDMEM_READONLY		0x20	/* read-only mapping
-					 * used when reading BIOS images
-					 * through xf86MapVidMem() */
-
-/*
  * OS-independent modem state flags for xf86SetSerialModemState() and
  * xf86GetSerialModemState().
  */
@@ -132,10 +114,6 @@ _XFUNCPROTOBEGIN
 
 /* public functions */
 extern _X_EXPORT Bool xf86LinearVidMem(void);
-extern _X_EXPORT Bool xf86CheckMTRR(int);
-extern _X_EXPORT pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
-extern _X_EXPORT void xf86UnMapVidMem(int, pointer, unsigned long);
-extern _X_EXPORT void xf86MapReadSideEffects(int, int, pointer, unsigned long);
 extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
 extern _X_EXPORT Bool xf86EnableIO(void);
 extern _X_EXPORT void xf86DisableIO(void);
@@ -209,7 +187,6 @@ extern _X_EXPORT int xf86ProcessArgument(int, char **, int);
 extern _X_EXPORT void xf86UseMsg(void);
 extern _X_EXPORT PMClose xf86OSPMOpen(void);
 
-extern _X_EXPORT void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
 extern _X_EXPORT void xf86InitVidMem(void);
 
 #endif /* XF86_OS_PRIVS */
commit 049a2084edbaf15ffae3d6b9b3daf57884174b7c
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 19:00:02 2011 -0400

    int10: Port internal users off xf86MapVidMem
    
    This API is apparently semi-deprecated even by XFree86 standards, and
    there are only four drivers left using it.  Let's start chopping it off.
    
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 53cd525..fbc9b85 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -103,8 +103,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
     MapVRam(pInt);
 #ifdef _PC
     if (!sysMem)
-	sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS,
-			       BIOS_SIZE + SYS_BIOS - V_BIOS);
+	pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS,
+			      PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
     INTPriv(pInt)->sysMem = sysMem;
 
     if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index f74da47..638f566 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -680,10 +680,12 @@ static void
 SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
 {
     int pagesize = getpagesize();
-    unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
-					VIDMEM_MMIO, 0, pagesize);
+    unsigned char* base;
     int i;
 
+    if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
+	return; /* eek */
+
     if (set) {
 	for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
 	    MEM_WW(pInt, i, *(base + i));
@@ -692,7 +694,7 @@ SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
 	    *(base + i) = MEM_RW(pInt, i);
     }
     
-    xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
+    pci_device_unmap_legacy(pInt->dev, base, pagesize);
 }
 
 void
@@ -706,7 +708,9 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
 	|| (!save && !pInt->BIOSScratch))
 	return;
     
-    base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
+    if (pci_device_map_legacy(pInt->dev, 0, pagesize, PCI_DEV_MAP_FLAG_WRITABLE, (void **)&base))
+	return; /* eek */
+
     base += BIOS_SCRATCH_OFF;
     if (save) {
 	if ((pInt->BIOSScratch
@@ -722,7 +726,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
 	}
     }
     
-    xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
+    pci_device_unmap_legacy(pInt->dev, base, pagesize);
 }
 #endif
 
commit c71b2cc601ce2bd6fe08e918d2ae29e2b55eafb2
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 17:34:23 2011 -0400

    pci: Remove xf86MapDomainMemory
    
    This is slightly draconian, but that API is just awful.  In all but
    one case in the callers it's used to get a map of some legacy VGA
    memory, and it would be cleaner for the caller to just call
    pci_device_map_legacy.
    
    The sole exception is in the vesa driver, which uses it to avoid having
    to look up which device the BAR belongs to.  That's similarly trivial to
    fix.
    
    Having done that, Linux's PCI layer is now very small indeed.
    
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index 7055df5..2148721 100644
--- a/configure.ac
+++ b/configure.ac
@@ -793,7 +793,7 @@ LIBXEXT="xext >= 1.0.99.4"
 LIBXFONT="xfont >= 1.4.2"
 LIBXI="xi >= 1.2.99.1"
 LIBXTST="xtst >= 1.0.99.2"
-LIBPCIACCESS="pciaccess >= 0.8.0"
+LIBPCIACCESS="pciaccess >= 0.12.901"
 LIBUDEV="libudev >= 143"
 LIBSELINUX="libselinux >= 2.0.86"
 LIBDBUS="dbus-1 >= 1.0"
@@ -1521,7 +1521,6 @@ if test "x$XORG" = xauto; then
 fi
 AC_MSG_RESULT([$XORG])
 
-xorg_bus_linuxpci=no
 xorg_bus_bsdpci=no
 xorg_bus_sparc=no
 
@@ -1592,7 +1591,6 @@ if test "x$XORG" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		fi
 		XORG_OS_SUBDIR="linux"
-		xorg_bus_linuxpci="yes"
 		linux_acpi="no"
 		case $host_cpu in
 		  alpha*)
@@ -1775,7 +1773,6 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([abi_extension])
 fi
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
-AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
 AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 040d999..53cd525 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -238,9 +238,7 @@ MapVRam(xf86Int10InfoPtr pInt)
     int pagesize = getpagesize();
     int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
 
-    INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO,
-					      pInt->dev, V_RAM, size);
-
+    pci_device_map_legacy(pInt->dev, V_RAM, size, PCI_DEV_MAP_FLAG_WRITABLE, &(INTPriv(pInt)->vRam));
     pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024);
 }
 
@@ -251,8 +249,7 @@ UnmapVRam(xf86Int10InfoPtr pInt)
     int pagesize = getpagesize();
     int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
 
-    xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size);
-
+    pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size);
     pci_device_close_io(pInt->dev, pInt->io);
     pInt->io = NULL;
 }
diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index 643cb25..b1ca8f9 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -3,10 +3,6 @@ sdk_HEADERS = xf86Pci.h
 
 PCI_SOURCES = Pci.c Pci.h
 
-if XORG_BUS_LINUXPCI
-PCI_SOURCES += linuxPci.c
-endif
-
 if XORG_BUS_BSDPCI
 PCI_SOURCES += bsd_pci.c
 endif
diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c
index f51d5c0..7a5dbbb 100644
--- a/hw/xfree86/os-support/bus/bsd_pci.c
+++ b/hw/xfree86/os-support/bus/bsd_pci.c
@@ -48,13 +48,6 @@
 
 #include "pciaccess.h"
 
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-		    ADDRESS Base, unsigned long Size)
-{
-    return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-}
-
 void
 osPciInit(void)
 {
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
deleted file mode 100644
index 8f314b5..0000000
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * 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 of Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission.  Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose.  It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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.
- *
- * Copyright 1998 by Metro Link Incorporated
- *
- * 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 of Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission.  Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose.  It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include "xf86_OSlib.h"
-#include "Pci.h"
-
-/**
- * \bug
- * The generation of the procfs file name for the domain != 0 case may not be 
- * correct.
- */
-static int
-linuxPciOpenFile(struct pci_device *dev, Bool write)
-{
-    static struct pci_device *last_dev = NULL;
-    static int	fd = -1,is_write = 0;
-    char		file[64];
-
-    if (dev == NULL) {
-	return -1;
-    }
-
-    if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) {
-	if (fd != -1) {
-	    close(fd);
-	    fd = -1;
-	}
-
-	sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config",
-		dev->domain, dev->bus, dev->dev, dev->func);
-
-	if (write) {
-	    fd = open(file,O_RDWR);
-	    if (fd != -1) is_write = TRUE;
-	} else {
-	    switch (is_write) {
-	    case TRUE:
-		fd = open(file,O_RDWR);
-		if (fd > -1)
-		    break;
-	    default:
-		fd = open(file,O_RDONLY);
-		is_write = FALSE;
-	    }
-	}
-
-	last_dev = dev;
-    }
-
-    return fd;
-}
-
-/*
- * Compiling the following simply requires the presence of <linux/pci.c>.
- * Actually running this is another matter altogether...
- *
- * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O
- * and memory spaces through its /proc/bus/pci/BUS/DFN entry.  Which one is
- * determined by a prior ioctl().
- *
- * For the sparc64 port, this means 2.4.12 or later.  For ppc, this
- * functionality is almost, but not quite there yet.  Alpha and other kernel
- * ports to multi-domain architectures still need to implement this.
- *
- * TO DO:  Address the deleterious reaction some host bridges have to master
- *         aborts.  This is already done for secondary PCI buses, but not yet
- *         for accesses to primary buses (except for the SPARC port, where
- *         master aborts are avoided during PCI scans).
- */
-
-#include <linux/pci.h>
-
-#ifndef PCIIOC_BASE		/* Ioctls for /proc/bus/pci/X/Y nodes. */
-#define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-
-/* Get controller for PCI device. */
-#define PCIIOC_CONTROLLER	(PCIIOC_BASE | 0x00)
-/* Set mmap state to I/O space. */
-#define PCIIOC_MMAP_IS_IO	(PCIIOC_BASE | 0x01)
-/* Set mmap state to MEM space. */
-#define PCIIOC_MMAP_IS_MEM	(PCIIOC_BASE | 0x02)
-/* Enable/disable write-combining. */
-#define PCIIOC_WRITE_COMBINE	(PCIIOC_BASE | 0x03)
-
-#endif
-
-static pointer
-linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
-	    ADDRESS Base, unsigned long Size, int mmap_ioctl)
-{
-    /* Align to page boundary */
-    const ADDRESS realBase = Base & ~(getpagesize() - 1);
-    const ADDRESS Offset = Base - realBase;
-
-    do {
-	unsigned char *result;
-	int fd, mmapflags, prot;
-
-	xf86InitVidMem();
-
-	/* If dev is NULL, linuxPciOpenFile will return -1, and this routine
-	 * will fail gracefully.
-	 */
-        prot = ((Flags & VIDMEM_READONLY) == 0);
-        if (((fd = linuxPciOpenFile(dev, prot)) < 0) ||
-	    (ioctl(fd, mmap_ioctl, 0) < 0))
-	    break;
-
-/* Note:  IA-64 doesn't compile this and doesn't need to */
-#ifdef __ia64__
-
-# ifndef  MAP_WRITECOMBINED
-#  define MAP_WRITECOMBINED 0x00010000
-# endif
-# ifndef  MAP_NONCACHED
-#  define MAP_NONCACHED     0x00020000
-# endif
-
-	if (Flags & VIDMEM_FRAMEBUFFER)
-	    mmapflags = MAP_SHARED | MAP_WRITECOMBINED;
-	else
-	    mmapflags = MAP_SHARED | MAP_NONCACHED;
-
-#else /* !__ia64__ */
-
-	mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER;
-
-	if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0)
-	    break;
-
-	mmapflags = MAP_SHARED;
-
-#endif /* ?__ia64__ */
-
-
-	if (Flags & VIDMEM_READONLY)
-	    prot = PROT_READ;
-	else
-	    prot = PROT_READ | PROT_WRITE;
-
-	result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase);
-
-	if (!result || ((pointer)result == MAP_FAILED))
-	    return NULL;
-
-	xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result);
-
-	return result + Offset;
-    } while (0);
-
-    if (mmap_ioctl == PCIIOC_MMAP_IS_MEM)
-	return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-
-    return NULL;
-}
-
-static int
-linuxOpenLegacy(struct pci_device *dev, char *name)
-{
-    static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s";
-    char path[sizeof(PREFIX) + 10];
-    int fd = -1;
-
-    while (dev != NULL) {
-	snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name);
-	fd = open(path, O_RDWR);
-	if (fd >= 0) {
-	    return fd;
-	}
-
-	dev = pci_device_get_parent_bridge(dev);
-    }
-
-    return fd;
-}
-
-/*
- * xf86MapDomainMemory - memory map PCI domain memory
- *
- * This routine maps the memory region in the domain specified by Tag and
- * returns a pointer to it.  The pointer is saved for future use if it's in
- * the legacy ISA memory space (memory in a domain between 0 and 1MB).
- */
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-		    ADDRESS Base, unsigned long Size)
-{
-    int fd = -1;
-    pointer addr;
-
-    /*
-     * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs
-     * legacy_mem interface is unavailable.
-     */
-    if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0))
-	return linuxMapPci(ScreenNum, Flags, dev, Base, Size,
-			   PCIIOC_MMAP_IS_MEM);
-    else
-	addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
-
-    if (fd >= 0)
-	close(fd);
-    if (addr == NULL || addr == MAP_FAILED) {
-	perror("mmap failure");
-	FatalError("xf86MapDomainMem():  mmap() failure\n");
-    }
-    return addr;
-}
diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h
index 6c9a0a1..74ead20 100644
--- a/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/hw/xfree86/os-support/bus/xf86Pci.h
@@ -254,8 +254,6 @@ typedef enum {
 extern _X_EXPORT Bool xf86scanpci(void);
 
 /* Domain access functions.  Some of these probably shouldn't be public */
-extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-    ADDRESS Base, unsigned long Size);
 extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev);
 extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *);
 
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index 072c599..4036a01 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1741,7 +1741,6 @@ Bool
 vgaHWMapMem(ScrnInfoPtr scrp)
 {
     vgaHWPtr hwp = VGAHWPTR(scrp);
-    int scr_index = scrp->scrnIndex;
     
     if (hwp->Base)
 	return TRUE;
@@ -1759,8 +1758,7 @@ vgaHWMapMem(ScrnInfoPtr scrp)
      * for now.
      */
     DebugF("Mapping VGAMem\n");
-    hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev,
-				    hwp->MapPhys, hwp->MapSize);
+    pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize, PCI_DEV_MAP_FLAG_WRITABLE, &hwp->Base);
     return hwp->Base != NULL;
 }
 
@@ -1769,13 +1767,12 @@ void
 vgaHWUnmapMem(ScrnInfoPtr scrp)
 {
     vgaHWPtr hwp = VGAHWPTR(scrp);
-    int scr_index = scrp->scrnIndex;
 
     if (hwp->Base == NULL)
 	return;
     
     DebugF("Unmapping VGAMem\n");
-    xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize);
+    pci_device_unmap_legacy(hwp->dev, hwp->Base, hwp->MapSize);
     hwp->Base = NULL;
 }
 


More information about the Xquartz-changes mailing list