[RFC][PATCH 5/6] xfree86: set PCI code optionally

Tiago Vignatti tiago.vignatti at nokia.com
Tue Jul 14 10:06:42 PDT 2009


Wrap all the code with XSERVER_LIBPCIACCESS. Now this macro has another
meaning: it's also internal to the server and tells if it needs or not pci
accesses, and not particularly the libpciaccess.

The highlights here are:
    - xf86pciBus.c is now optional
    - os-support/bus/ (which is not a "bus" directory but a PCI dir) is now
      optional
    - Change of fbdevHWProbe and fbdevHWInit interfaces

This patch tends to get a lot better (e.g. removing a lot of code inside
 #if XSERVER_LIBPCIACCESS) when we integrate the VGA arbiter Xorg part (the
kernel  piece was just queued for reviews on LKML)

And yeah, the driver side will need some redesign as well to set properly the
code that XSERVER_LIBPCIACCESS hits.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
 hw/xfree86/common/Makefile.am      |    6 +++-
 hw/xfree86/common/xf86.h           |   59 +++++++++++++++++++----------------
 hw/xfree86/common/xf86AutoConfig.c |   16 +++++++--
 hw/xfree86/common/xf86Bus.c        |   40 ++++++++++++++++++++++++
 hw/xfree86/common/xf86Bus.h        |    2 +-
 hw/xfree86/common/xf86Config.c     |    5 ++-
 hw/xfree86/common/xf86Helper.c     |   13 ++++++--
 hw/xfree86/common/xf86Init.c       |   13 +++++++-
 hw/xfree86/common/xf86str.h        |    7 +++-
 hw/xfree86/fbdevhw/fbdevhw.c       |   16 ++++++++++
 hw/xfree86/fbdevhw/fbdevhw.h       |    5 +++
 hw/xfree86/loader/sdksyms.sh       |    3 +-
 hw/xfree86/os-support/Makefile.am  |   12 ++++++-
 13 files changed, 154 insertions(+), 43 deletions(-)

diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 0b0f582..63ea2bd 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -17,11 +17,15 @@ if DGA
 DGASOURCES = xf86DGA.c
 endif
 
+if XORG_LIBPCIACCESS
+PCIBUS_SOURCES = xf86pciBus.c
+endif
+
 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 $(PCIBUS_SOURCES) $(SBUS_SOURCES)
 
 MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
 
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 93bfd84..4a37115 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -41,7 +41,9 @@
 #include <dix-config.h>
 #endif
 
+#ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
+#endif
 
 #include "xf86str.h"
 #include "xf86Opt.h"
@@ -60,7 +62,6 @@ extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey;
 extern _X_EXPORT DevPrivateKey xf86PixmapKey;
 extern _X_EXPORT ScrnInfoPtr *xf86Screens;	/* List of pointers to ScrnInfoRecs */
 extern _X_EXPORT const unsigned char byte_reversed[256];
-extern _X_EXPORT Bool pciSlotClaimed;
 extern _X_EXPORT Bool fbSlotClaimed;
 #if defined(__sparc__) || defined(__sparc)
 extern _X_EXPORT Bool sbusSlotClaimed;
@@ -89,8 +90,9 @@ extern _X_EXPORT Bool VTSwitchEnabled;	/* kbd driver */
 /* Function Prototypes */
 #ifndef _NO_XF86_PROTOTYPES
 
-/* xf86Bus.c */
-
+/* PCI related (TODO: set a new header file for this) */
+#ifdef XSERVER_LIBPCIACCESS
+extern _X_EXPORT Bool pciSlotClaimed;
 extern _X_EXPORT Bool xf86CheckPciSlot( const struct pci_device * );
 extern _X_EXPORT int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp,
 		     int chipset, GDevPtr dev, Bool active);
@@ -99,13 +101,38 @@ extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, int *de
 			   int *func);
 extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func);
 extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer);
+extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
+extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
+extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base);
+extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, int vendorID,
+		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
+		      GDevPtr *devList, int numDevs, DriverPtr drvp,
+		      int **foundEntities);
+extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag,
+				int entityIndex,PciChipsets *p_chip,
+				resList res, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+/* Obsolete! don't use */
+extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
+				int entityIndex,PciChipsets *p_chip,
+				resList res, EntityProc init,
+				EntityProc enter, EntityProc leave,
+				pointer private);
+/* Obsolete! don't use */
+extern _X_EXPORT void xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
+				 resList res, EntityProc init,
+				 EntityProc enter, EntityProc leave,
+				 pointer private);
+
+#endif /* XSERVER_LIBPCIACCESS */
+
 extern _X_EXPORT resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex);
 extern _X_EXPORT int  xf86GetFbInfoForScreen(int scrnIndex);
 extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
 extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
 extern _X_EXPORT void xf86EnableAccess(ScrnInfoPtr pScrn);
 extern _X_EXPORT void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn);
-extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
 /* new RAC */
 extern _X_EXPORT resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex);
 extern _X_EXPORT void xf86FreeResList(resPtr rlist);
@@ -118,13 +145,11 @@ extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex);
 extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
 extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
 extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex);
-extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
 extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
 			EntityProc enter, EntityProc leave, pointer);
 extern _X_EXPORT void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type);
 extern _X_EXPORT resPtr xf86RegisterResources(int entityIndex, resList list,
 			     unsigned long Access);
-extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base);
 extern _X_EXPORT void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
 			xf86SetAccessFuncPtr oldFuncs);
 extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex);
@@ -233,15 +258,11 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
 extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg,
 		       SymTabPtr chips);
 extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
-extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, int vendorID,
-		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
-		      GDevPtr *devList, int numDevs, DriverPtr drvp,
-		      int **foundEntities);
 extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
 		   Bool (*ClockFunc)(ScrnInfoPtr, int),
 		   void (*ProtectRegs)(ScrnInfoPtr, Bool),
 		   void (*BlankScreen)(ScrnInfoPtr, Bool),
-		   IOADDRESS vertsyncreg, int maskval,
+		   unsigned long vertsyncreg, int maskval,
 		   int knownclkindex, int knownclkvalue);
 extern _X_EXPORT const char *xf86GetVisualName(int visual);
 extern _X_EXPORT int xf86GetVerbosity(void);
@@ -274,26 +295,10 @@ extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen);
 extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
 			  char **adaptor_name, pointer *adaptor_options);
 extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag,
-				int entityIndex,PciChipsets *p_chip,
-				resList res, EntityProc init,
-				EntityProc enter, EntityProc leave,
-				pointer private);
 extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
 			       int entityIndex, EntityProc init,
 			       EntityProc enter, EntityProc leave,
 			       pointer private);
-/* Obsolete! don't use */
-extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
-				int entityIndex,PciChipsets *p_chip,
-				resList res, EntityProc init,
-				EntityProc enter, EntityProc leave,
-				pointer private);
-/* Obsolete! don't use */
-extern _X_EXPORT void xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
-				 resList res, EntityProc init,
-				 EntityProc enter, EntityProc leave,
-				 pointer private);
 extern _X_EXPORT void xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
 				EntityProc enter, EntityProc leave,
 				pointer private);
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index bc4c80b..481dd2e 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -140,6 +140,7 @@ AppendToConfig(const char *s)
     AppendToList(s, &builtinConfig, &builtinLines);
 }
 
+#ifdef XSERVER_LIBPCIACCESS
 static int
 videoPtrToDriverList(struct pci_device *dev,
 		     char *returnList[], int returnListMax)
@@ -222,6 +223,7 @@ videoPtrToDriverList(struct pci_device *dev,
     }
     return i;	/* Number of entries added */
 }
+#endif
 
 Bool
 xf86AutoConfig(void)
@@ -327,7 +329,7 @@ autoConfigDevice(GDevPtr preconf_device)
     return ptr;
 }
 
-#ifdef __linux__
+#if defined(__linux__) && defined(XSERVER_LIBPCIACCESS)
 /* This function is used to provide a workaround for binary drivers that
  * don't export their PCI ID's properly. If distros don't end up using this
  * feature it can and should be removed because the symbol-based resolution
@@ -430,13 +432,15 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
     xfree(line);
     closedir(idsdir);
 }
-#endif /* __linux__ */
+#endif /* __linux__ || XSERVER_LIBPCIACCESS */
 
 static void
 listPossibleVideoDrivers(char *matches[], int nmatches)
 {
+#ifdef XSERVER_LIBPCIACCESS
     struct pci_device * info = NULL;
     struct pci_device_iterator *iter;
+#endif
     int i;
     
     for (i = 0 ; i < nmatches ; i++) {
@@ -485,6 +489,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
     }
 #endif
 
+#ifdef XSERVER_LIBPCIACCESS
     /* Find the primary device, and get some information about it. */
     iter = pci_slot_match_iterator_create(NULL);
     while ((info = pci_device_next(iter)) != NULL) {
@@ -498,19 +503,22 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
     if (!info) {
 	ErrorF("Primary device is not PCI\n");
     }
-#ifdef __linux__
+#endif
+#if defined(__linux__) && defined(XSERVER_LIBPCIACCESS)
     else {
 	matchDriverFromFiles(matches, info->vendor_id, info->device_id);
     }
-#endif /* __linux__ */
+#endif /* __linux__ || XSERVER_LIBPCIACCESS */
 
     for (i = 0; (i < nmatches) && (matches[i]); i++) {
 	/* find end of matches list */
     }
 
+#ifdef XSERVER_LIBPCIACCESS
     if ((info != NULL) && (i < nmatches)) {
 	i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
     }
+#endif
 
     /* Fallback to platform default hardware */
     if (i < (nmatches - 1)) {
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 0d732d0..abf18d1 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -50,8 +50,10 @@
 #define NEED_OS_RAC_PROTOS
 #include "xf86_OSproc.h"
 
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86RAC.h"
 #include "Pci.h"
+#endif
 
 /* Entity data */
 EntityPtr *xf86Entities = NULL;	/* Bus slots claimed by drivers */
@@ -102,7 +104,9 @@ static void notifyStateChange(xf86NotifyState state);
 void
 xf86BusProbe(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     xf86PciProbe();
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
     xf86SbusProbe();
 #endif
@@ -544,12 +548,14 @@ clearAccess(void)
 void
 xf86AccessInit(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     initPciState();
     initPciBusState();
     DisablePciBusAccess();
     DisablePciAccess();
     
     xf86ResAccessEnter = TRUE;
+#endif
 }
 
 /*
@@ -559,6 +565,7 @@ xf86AccessInit(void)
 void
 xf86AccessEnter(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     if (xf86ResAccessEnter) 
 	return;
 
@@ -574,6 +581,7 @@ xf86AccessEnter(void)
     notifyStateChange(NOTIFY_ENTER);
     xf86EnterServerState(SETUP);
     xf86ResAccessEnter = TRUE;
+#endif
 }
 
 /*
@@ -588,22 +596,26 @@ xf86AccessEnter(void)
 void
 xf86AccessLeave(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     if (!xf86ResAccessEnter)
 	return;
     notifyStateChange(NOTIFY_LEAVE);
     disableAccess();
     DisablePciBusAccess();
     EntityLeave();
+#endif
 }
 
 void
 xf86AccessLeaveState(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     if (!xf86ResAccessEnter)
 	return;
     xf86ResAccessEnter = FALSE;
     PciStateLeave();
     PciBusStateLeave();
+#endif
 }
 
 /*
@@ -613,10 +625,12 @@ xf86AccessLeaveState(void)
 static void 
 xf86AccessRestoreState(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     if (!xf86ResAccessEnter)
 	return;
     PciStateLeave();
     PciBusStateLeave();
+#endif
 }
 
 /*
@@ -637,6 +651,7 @@ xf86AccessRestoreState(void)
 void
 xf86EnableAccess(ScrnInfoPtr pScrn)
 {
+#ifdef XSERVER_LIBPCIACCESS
     register EntityAccessPtr peAcc = (EntityAccessPtr) pScrn->access;
     register EntityAccessPtr pceAcc;
     register xf86AccessPtr pAcc;
@@ -751,11 +766,13 @@ xf86EnableAccess(ScrnInfoPtr pScrn)
 	}
 	return;
     }
+#endif
 }
 
 void
 xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn)
 {
+#ifdef XSERVER_LIBPCIACCESS
     EntityAccessPtr pceAcc2 = NULL;
     register EntityAccessPtr pceAcc = NULL;
     register xf86AccessPtr pAcc;
@@ -791,12 +808,14 @@ xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn)
 	    pceAcc2 = NULL;
 	}
     }
+#endif
 }
 
 void
 xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
 		   xf86SetAccessFuncPtr oldFuncs)
 {
+#ifdef XSERVER_LIBPCIACCESS
     AccessFuncPtr rac;
 
     if (!xf86Entities[pEnt->index]->rac)
@@ -809,6 +828,7 @@ xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
     rac->io_mem_new = funcs->io_mem;
     
     rac->old = oldFuncs;
+#endif
 }
 
 /*
@@ -1268,12 +1288,14 @@ xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex)
 void
 xf86ResourceBrokerInit(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     Acc = NULL;
 
     /* Get the ranges used exclusively by the system */
     Acc = xf86AccResFromOS(Acc);
     xf86MsgVerb(X_INFO, 3, "System resource ranges:\n");
     xf86PrintResList(3, Acc);
+#endif
 }
 
 /*
@@ -1285,9 +1307,11 @@ convertRange2Host(int entityIndex, resRange *pRange)
 {
     if (pRange->type & ResBus) {
 	switch (xf86Entities[entityIndex]->bus.type) {
+#ifdef XSERVER_LIBPCIACCESS
 	case BUS_PCI:
 	    pciConvertRange2Host(entityIndex,pRange);
 	    break;
+#endif
 	default:
 	    break;
 	}
@@ -1351,6 +1375,7 @@ busTypeSpecific(EntityPtr pEnt, xf86AccessPtr *acc_mem,
     case BUS_SBUS:
 	*acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
 	break;
+#ifdef XSERVER_LIBPCIACCESS
     case BUS_PCI: {
 	struct pci_device *const dev = pEnt->bus.id.pci;
 
@@ -1371,6 +1396,7 @@ busTypeSpecific(EntityPtr pEnt, xf86AccessPtr *acc_mem,
 	}
 	break;
     }
+#endif
     default:
 	*acc_mem = *acc_io = *acc_mem_io = NULL;
 	break;
@@ -1382,6 +1408,7 @@ static void
 setAccess(EntityPtr pEnt, xf86State state)
 {
 
+#ifdef XSERVER_LIBPCIACCESS
     xf86AccessPtr acc_mem, acc_io, acc_mem_io;
     xf86AccessPtr org_mem = NULL, org_io = NULL, org_mem_io = NULL;
     int prop;
@@ -1507,6 +1534,7 @@ setAccess(EntityPtr pEnt, xf86State state)
 	&& (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP :
 				NEED_VGA_ROUTED)))
 	((BusAccPtr)pEnt->busAcc)->set_f(pEnt->busAcc);
+#endif
 }
 
     
@@ -1534,6 +1562,7 @@ SetSIGIOForState(xf86State state)
 void
 xf86EnterServerState(xf86State state)
 {
+#ifdef XSERVER_LIBPCIACCESS
     EntityPtr pEnt;
     ScrnInfoPtr pScrn;
     int i,j;
@@ -1628,6 +1657,7 @@ xf86EnterServerState(xf86State state)
 	notifyStateChange(NOTIFY_SETUP);
     else
 	notifyStateChange(NOTIFY_OPERATING);
+#endif
 }
 
 /*
@@ -1636,6 +1666,7 @@ xf86EnterServerState(xf86State state)
 resPtr
 xf86SetOperatingState(resList list, int entityIndex, int mask)
 {
+#ifdef XSERVER_LIBPCIACCESS
     resPtr acc;
     resPtr r_fail = NULL;
     resRange range;
@@ -1664,6 +1695,7 @@ xf86SetOperatingState(resList list, int entityIndex, int mask)
     }
     
      return r_fail;
+#endif
 }
 
 /*
@@ -1677,6 +1709,7 @@ xf86SetOperatingState(resList list, int entityIndex, int mask)
 void
 xf86ClaimFixedResources(resList list, int entityIndex)
 {
+#ifdef XSERVER_LIBPCIACCESS
     resPtr ptr = NULL;
     resRange range;	
 
@@ -1720,11 +1753,13 @@ xf86ClaimFixedResources(resList list, int entityIndex)
 	xf86PrintResList(3,ptr);
     }
 #endif
+#endif
 }
 
 static void
 checkRoutingForScreens(xf86State state)
 {
+#ifdef XSERVER_LIBPCIACCESS
     resList list = resVgaUnusedExclusive;
     resPtr pResVGA = NULL;
     resPtr pResVGAHost;
@@ -1798,6 +1833,7 @@ checkRoutingForScreens(xf86State state)
 	}
     }
     xf86FreeResList(pResVGA);
+#endif
 }
 
 /*
@@ -1807,6 +1843,7 @@ checkRoutingForScreens(xf86State state)
 void
 xf86PostProbe(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     memType val;
     int i,j;
     resPtr resp, acc, tmp, resp_x;
@@ -1868,11 +1905,13 @@ xf86PostProbe(void)
 		break;
 	}
     }
+#endif
 }
 
 static void
 checkRequiredResources(int entityIndex)
 {
+#ifdef XSERVER_LIBPCIACCESS
     resRange range;
     resPtr pAcc = Acc;
     const EntityPtr pEnt = xf86Entities[entityIndex];
@@ -1917,6 +1956,7 @@ checkRequiredResources(int entityIndex)
     if ((pEnt->entityProp & NEED_IO_SHARED)
 	&& (!(pEnt->entityProp & NEED_IO)))
 	pEnt->entityProp &= ~(unsigned long)NEED_IO_SHARED;
+#endif
 }
 
 void
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index 83ba83c..b7df57f 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -70,7 +70,7 @@ typedef struct {
     DevUnion *                  entityPrivates;
     int                         numInstances;
     GDevPtr *                   devices;   
-    IOADDRESS                   domainIO;
+    unsigned long               domainIO;
 } EntityRec, *EntityPtr;
 
 #define NO_SEPARATE_IO_FROM_MEM 0x0001
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 60e66ab..97bf3fe 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -60,7 +60,9 @@
 #include "configProcs.h"
 #include "globals.h"
 #include "extension.h"
+#ifdef XSERVER_LIBPCIACCESS
 #include "Pci.h"
+#endif
 
 #include "xf86Xinput.h"
 extern DeviceAssocRec mouse_assoc;
@@ -2521,6 +2523,7 @@ xf86HandleConfigFile(Bool autoconfig)
 
     xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
 
+#ifdef XSERVER_LIBPCIACCESS
     if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
        ; /* IsolateDevice specified; overrides SingleCard */
     } else {
@@ -2542,7 +2545,7 @@ xf86HandleConfigFile(Bool autoconfig)
                    "Isolating PCI bus \"%d:%d:%d\"\n", bus, device, func);
        }
     }
-
+#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/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 574ff2d..44235f5 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -38,8 +38,11 @@
 #include <xorg-config.h>
 #endif
 
+#ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
 #include "Pci.h"
+#include "xf86PciInfo.h"
+#endif
 
 #include <X11/X.h>
 #include "os.h"
@@ -53,7 +56,6 @@
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
 #include "micmap.h"
-#include "xf86PciInfo.h"
 #include "xf86DDC.h"
 #include "xf86Xinput.h"
 #include "xf86InPriv.h"
@@ -1520,6 +1522,7 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
     return i;
 }
 
+#ifdef XSERVER_LIBPCIACCESS
 static Bool
 pciDeviceHasBars(struct pci_device *pci)
 {
@@ -1910,6 +1913,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
 	
     return numFound;
 }
+#endif
 
 static void
 xf86SetPriority(Bool up)
@@ -1941,7 +1945,7 @@ xf86SetPriority(Bool up)
 void
 xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
 	      void (*ProtectRegs)(ScrnInfoPtr, Bool),
-	      void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
+	      void (*BlankScreen)(ScrnInfoPtr, Bool), unsigned long vertsyncreg,
 	      int maskval, int knownclkindex, int knownclkvalue)
 {
     register int status = vertsyncreg;
@@ -2368,6 +2372,7 @@ xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
 
 /* new RAC */
 
+#ifdef XSERVER_LIBPCIACCESS
 ScrnInfoPtr
 xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
 			  PciChipsets *p_chip, resList res, EntityProc init,
@@ -2411,6 +2416,7 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
 
     return pScrn;
 }
+#endif
 
 ScrnInfoPtr
 xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
@@ -2445,7 +2451,7 @@ xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
  *  OBSOLETE ! xf86ConfigActivePciEntity() is an obsolete function.
  *             It is likely to be removed. Don't use!
  */
-
+#ifdef XSERVER_LIBPCIACCESS
 Bool
 xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
                           PciChipsets *p_chip, resList res, EntityProc init,
@@ -2504,6 +2510,7 @@ xf86ConfigPciEntityInactive(EntityInfoPtr pEnt, PciChipsets *p_chip,
     xf86DeallocateResourcesForEntity(pEnt->index, ResShared);
     xf86SetEntityFuncs(pEnt->index,init,enter,leave,private);
 }
+#endif
 
 void
 xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 42f47fc..e562651 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -86,9 +86,11 @@
 #include "dpmsproc.h"
 #endif
 
+#ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
 #include "Pci.h"
 #include "xf86Bus.h"
+#endif
 
 #ifdef XF86PM
 void (*xf86OSPMClose)(void) = NULL;
@@ -317,7 +319,7 @@ InstallSignalHandlers(void)
     }
 }
 
-
+#ifdef XSERVER_LIBPCIACCESS
 #define END_OF_MATCHES(m) \
     (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
 
@@ -424,6 +426,7 @@ probe_devices_from_device_sections(DriverPtr drvp)
 
     return foundScreen;
 }
+#endif
 
 /**
  * Call the driver's correct probe function.
@@ -445,8 +448,10 @@ xf86CallDriverProbe(DriverPtr drv)
 {
     Bool     foundScreen = FALSE;
 
+#ifdef XSERVER_LIBPCIACCESS
     if ( drv->PciProbe != NULL )
 	    foundScreen = probe_devices_from_device_sections( drv );
+#endif
 
     if ( ! foundScreen && (drv->Probe != NULL) ) {
 	xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
@@ -616,6 +621,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
 	    xorgHWAccess = TRUE;
     }
 
+#ifdef XSERVER_LIBPCIACCESS
     /* Enable full I/O access */
     if (xorgHWAccess)
 	xorgHWAccess = xf86EnableIO();
@@ -627,6 +633,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
         xf86AccessInit();
         xf86FindPrimaryDevice();
     }
+#endif
     /*
      * Now call each of the Probe functions.  Each successful probe will
      * result in an extra entry added to the xf86Screens[] list for each
@@ -1522,6 +1529,7 @@ ddxProcessArgument(int argc, char **argv, int i)
     xf86DoShowOptions = TRUE;
     return 1;
   }
+#ifdef XSERVER_LIBPCIACCESS
   if (!strcmp(argv[i], "-isolateDevice"))
   {
     int bus, device, func;
@@ -1539,6 +1547,7 @@ ddxProcessArgument(int argc, char **argv, int i)
        FatalError("Invalid isolated device specification\n");
     }
   }
+#endif
   /* Notice cmdline xkbdir, but pass to dix as well */
   if (!strcmp(argv[i], "-xkbdir"))
   {
@@ -1595,7 +1604,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/xf86str.h b/hw/xfree86/common/xf86str.h
index 3b1346f..60b35e6 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -41,9 +41,11 @@
 #include "colormapst.h"
 #include "xf86Module.h"
 #include "xf86Opt.h"
-#include "xf86Pci.h"
 
+#ifdef XSERVER_LIBPCIACCESS
+#include "xf86Pci.h"
 #include <pciaccess.h>
+#endif
 
 /**
  * Integer type that is of the size of the addressable memory (machine size).
@@ -320,7 +322,6 @@ typedef struct {
 } DriverRec1;
 
 struct _SymTabRec;
-struct _PciChipsets;
 
 typedef struct _DriverRec {
     int			driverVersion;
@@ -333,8 +334,10 @@ typedef struct _DriverRec {
     xorgDriverFuncProc  *driverFunc;
 
     const struct pci_id_match * supported_devices;
+#ifdef XSERVER_LIBPCIACCESS
     Bool (*PciProbe)( struct _DriverRec * drv, int entity_num,
         struct pci_device * dev, intptr_t match_data );
+#endif
 } DriverRec, *DriverPtr;
 
 /*
diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c
index 3eee070..a1eda56 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/hw/xfree86/fbdevhw/fbdevhw.c
@@ -9,8 +9,10 @@
 #include "xf86_OSproc.h"
 
 /* pci stuff */
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86PciInfo.h"
 #include "xf86Pci.h"
+#endif
 
 #include "xf86cmap.h"
 
@@ -306,6 +308,7 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
 /* -------------------------------------------------------------------- */
 /* open correct framebuffer device                                      */
 
+#ifdef XSERVER_LIBPCIACCESS
 /**
  * Try to find the framebuffer device for a given PCI device 
  */
@@ -400,6 +403,7 @@ fbdev_open_pci(struct pci_device * pPci, char **namep)
 	       "Unable to find a valid framebuffer device\n");
     return -1;
 }
+#endif
 
 static int
 fbdev_open(int scrnIndex, char *dev, char** namep)
@@ -443,13 +447,19 @@ fbdev_open(int scrnIndex, char *dev, char** namep)
 /* -------------------------------------------------------------------- */
 
 Bool
+#ifdef XSERVER_LIBPCIACCESS
 fbdevHWProbe(struct pci_device * pPci, char *device,char **namep)
+#else
+fbdevHWProbe(char *device,char **namep)
+#endif
 {
 	int fd;
 
+#ifdef XSERVER_LIBPCIACCESS
 	if (pPci)
 		fd = fbdev_open_pci(pPci,namep);
 	else
+#endif
 		fd = fbdev_open(-1,device,namep);
 
 	if (-1 == fd)
@@ -459,7 +469,11 @@ fbdevHWProbe(struct pci_device * pPci, char *device,char **namep)
 }
 
 Bool
+#ifdef XSERVER_LIBPCIACCESS
 fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device)
+#else
+fbdevHWInit(ScrnInfoPtr pScrn, char *device)
+#endif
 {
 	fbdevHWPtr fPtr;
 
@@ -469,9 +483,11 @@ fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device)
 	fPtr = FBDEVHWPTR(pScrn);
 
 	/* open device */
+#ifdef XSERVER_LIBPCIACCESS
 	if (pPci)
 		fPtr->fd = fbdev_open_pci(pPci,NULL);
 	else
+#endif
 		fPtr->fd = fbdev_open(pScrn->scrnIndex,device,NULL);
 	if (-1 == fPtr->fd) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
diff --git a/hw/xfree86/fbdevhw/fbdevhw.h b/hw/xfree86/fbdevhw/fbdevhw.h
index bc46b9c..75b384d 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.h
+++ b/hw/xfree86/fbdevhw/fbdevhw.h
@@ -18,8 +18,13 @@ extern _X_EXPORT void  fbdevHWFreeRec(ScrnInfoPtr pScrn);
 
 extern _X_EXPORT int   fbdevHWGetFD(ScrnInfoPtr pScrn);
 
+#ifdef XSERVER_LIBPCIACCESS
 extern _X_EXPORT Bool  fbdevHWProbe(struct pci_device * pPci, char *device, char **namep);
 extern _X_EXPORT Bool  fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device);
+#else
+extern _X_EXPORT Bool  fbdevHWProbe(char *device, char **namep);
+extern _X_EXPORT Bool  fbdevHWInit(ScrnInfoPtr pScrn, char *device);
+#endif
 
 extern _X_EXPORT char* fbdevHWGetName(ScrnInfoPtr pScrn);
 extern _X_EXPORT int   fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp);
diff --git a/hw/xfree86/loader/sdksyms.sh b/hw/xfree86/loader/sdksyms.sh
index b320661..d988a10 100755
--- a/hw/xfree86/loader/sdksyms.sh
+++ b/hw/xfree86/loader/sdksyms.sh
@@ -114,7 +114,6 @@ cat > sdksyms.c << EOF
 #include "xf86.h"
 #include "xf86Module.h"
 #include "xf86Opt.h"
-#include "xf86PciInfo.h"
 #include "xf86Priv.h"
 #include "xf86Privstr.h"
 #include "xf86Resources.h"
@@ -167,7 +166,9 @@ cat > sdksyms.c << EOF
 
 
 /* hw/xfree86/os-support/bus/Makefile.am */
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86Pci.h"
+#endif
 #if defined(__sparc__) || defined(__sparc)
 # include "xf86Sbus.h"
 #endif
diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 04997a6..3b3a11a 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -1,4 +1,9 @@
-SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
+# XXX: it's not the right label. Well, the name of the directory also...
+if XORG_LIBPCIACCESS
+BUS_DIR = bus
+endif
+
+SUBDIRS = @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) $(BUS_DIR)
 DIST_SUBDIRS = bsd bus misc linux solaris sysv sco hurd
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
@@ -11,9 +16,12 @@ EXTRA_DIST = int10Defines.h xf86OSpriv.h
 noinst_LTLIBRARIES = libxorgos.la
 libxorgos_la_SOURCES = xorgos.c
 libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib at XORG_OS_SUBDIR@.la \
-                      bus/libbus.la \
                       misc/libmisc.la
 
+if XORG_LIBPCIACCESS
+libxorgos_la_LIBADD += bus/libbus.la
+endif
+
 AM_CFLAGS = $(DIX_CFLAGS) 
 
 xorgos.c:
-- 
1.5.6.3



More information about the xorg-devel mailing list