[PATCH 13/14] configure: wrap PCI code with macro and set it at build time
Tiago Vignatti
tiago.vignatti at nokia.com
Thu Jun 3 04:48:20 PDT 2010
--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>
---
configure.ac | 8 ++++++++
hw/xfree86/common/Makefile.am | 9 +++++++--
hw/xfree86/common/xf86.h | 10 ++++++++++
hw/xfree86/common/xf86AutoConfig.c | 4 ++--
hw/xfree86/common/xf86Bus.c | 18 +++++++++++++-----
hw/xfree86/common/xf86Config.c | 4 ++--
hw/xfree86/common/xf86Configure.c | 4 ++++
hw/xfree86/common/xf86DPMS.c | 3 ++-
hw/xfree86/common/xf86Init.c | 7 ++++++-
hw/xfree86/common/xf86fbBus.c | 2 ++
hw/xfree86/common/xf86str.h | 7 ++-----
hw/xfree86/loader/sdksyms.sh | 10 +++++++---
hw/xfree86/os-support/bus/Makefile.am | 5 ++++-
include/xorg-config.h.in | 3 +++
14 files changed, 72 insertions(+), 22 deletions(-)
diff --git a/configure.ac b/configure.ac
index 820d971..ddb90c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -644,6 +644,7 @@ AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with
AC_ARG_ENABLE(vbe, AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
+AC_ARG_ENABLE(pci, AS_HELP_STRING([--enable-pci], [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])
@@ -1584,6 +1585,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"
@@ -1603,6 +1607,10 @@ if test "x$XORG" = xyes; then
xorg_bus_sparc="yes"
;;
esac
+ fi
+ AC_MSG_RESULT([$PCI])
+
+ AM_CONDITIONAL([XORG_BUS_PCI], [test "x$PCI" = 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])
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 821a2b5..a8d7ca4 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
@@ -21,7 +26,7 @@ XISOURCES = xf86Xinput.c xisb.c
XISDKINCS = xf86Xinput.h xisb.h
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
@@ -35,7 +40,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 755d171..8790f12 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -89,6 +89,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;
@@ -115,6 +116,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 5b236af..918283f 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -256,9 +256,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 8276257..7b0deda 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
@@ -533,9 +536,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 da9e729..f09175e 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2526,7 +2526,7 @@ xf86HandleConfigFile(Bool autoconfig)
}
xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
-
+#ifdef XSERVER_LIBPCIACCESS
if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
; /* IsolateDevice specified; overrides SingleCard */
} else {
@@ -2541,7 +2541,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 04fa8f7..95ba2ea 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -88,9 +88,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;
+#endif
#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
case BUS_SBUS:
ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
@@ -119,10 +121,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 cd33e75..1f6a2b6 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 int DPMSKeyIndex;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index db88f70..819d6e0 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -77,7 +77,9 @@
#include "picturestr.h"
#include "xf86Bus.h"
+#ifdef XSERVER_LIBPCIACCESS
#include "xf86VGAarbiter.h"
+#endif
#include "globals.h"
#ifdef DPMSExtension
@@ -86,7 +88,6 @@
#endif
#include <hotplug.h>
-
#ifdef XF86PM
void (*xf86OSPMClose)(void) = NULL;
#endif
@@ -1338,6 +1339,7 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86DoShowOptions = TRUE;
return 1;
}
+#ifdef XSERVER_LIBPCIACCESS
if (!strcmp(argv[i], "-isolateDevice"))
{
CHECK_FOR_REQUIRED_ARGUMENT();
@@ -1347,6 +1349,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"))
{
@@ -1405,7 +1408,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 95b43e5..7d1a30e 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/loader/sdksyms.sh b/hw/xfree86/loader/sdksyms.sh
index 13c5ae5..7b2bf6f 100755
--- a/hw/xfree86/loader/sdksyms.sh
+++ b/hw/xfree86/loader/sdksyms.sh
@@ -115,14 +115,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"
@@ -167,7 +169,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/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index 643cb25..6c034dd 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_LINUXPCI
PCI_SOURCES += linuxPci.c
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 332d059..d4fdd64 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -127,4 +127,7 @@
/* Support PC98 */
#undef SUPPORT_PC98
+/* Use libpciaccess */
+#undef XSERVER_LIBPCIACCESS
+
#endif /* _XORG_CONFIG_H_ */
--
1.7.1.226.g770c5
More information about the xorg-devel
mailing list