configure.ac | 8 hw/xfree86/Makefile.am | 4 hw/xfree86/common/Makefile.am | 2 hw/xfree86/common/xf86.h | 33 hw/xfree86/common/xf86AutoConfig.c | 14 hw/xfree86/common/xf86Bus.c | 55 hw/xfree86/common/xf86Bus.h | 2 hw/xfree86/common/xf86Configure.c | 52 hw/xfree86/common/xf86DoProbe.c | 4 hw/xfree86/common/xf86DoScanPci.c | 130 + hw/xfree86/common/xf86Helper.c | 245 +++ hw/xfree86/common/xf86Init.c | 62 hw/xfree86/common/xf86Priv.h | 7 hw/xfree86/common/xf86pciBus.c | 2254 ++++------------------------------ hw/xfree86/common/xf86pciBus.h | 8 hw/xfree86/common/xf86str.h | 17 hw/xfree86/dri/dri.c | 11 hw/xfree86/dri/dri.h | 4 hw/xfree86/fbdevhw/fbdevhw.c | 88 - hw/xfree86/fbdevhw/fbdevhw.h | 6 hw/xfree86/int10/generic.c | 8 hw/xfree86/int10/pci.c | 21 hw/xfree86/int10/xf86int10.c | 62 hw/xfree86/loader/Makefile.am | 2 hw/xfree86/loader/xf86sym.c | 13 hw/xfree86/os-support/bus/Pci.c | 397 ----- hw/xfree86/os-support/bus/linuxPci.c | 8 hw/xfree86/os-support/bus/xf86Pci.h | 8 hw/xfree86/os-support/bus/zx1PCI.c | 8 hw/xfree86/os-support/linux/lnx_agp.c | 6 hw/xfree86/utils/Makefile.am | 2 hw/xfree86/utils/xorgcfg/loadmod.c | 26 hw/xfree86/vgahw/vgaHW.c | 7 33 files changed, 906 insertions(+), 2668 deletions(-) Signed-off-by: Ian Romanick Index: configure.ac =================================================================== RCS file: /cvs/xorg/xserver/xorg/configure.ac,v retrieving revision 1.192 diff -u -d -r1.192 configure.ac --- configure.ac 6 Apr 2006 18:59:10 -0000 1.192 +++ configure.ac 27 Apr 2006 17:26:44 -0000 @@ -1043,6 +1043,10 @@ AC_CHECK_LIB([dl], [dlopen], XORG_LIBS="$XORG_LIBS -ldl") + PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.3.0]) + XORG_LIBS="$XORG_LIBS $PCIACCESS_LIBS" + XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" + case $host_os in linux*) XORG_OS="linux" @@ -1192,7 +1196,6 @@ AC_SUBST([XORG_OS_SUBDIR]) AC_SUBST([XORG_OS_KBD]) - dnl only used in hw/xfree86/scanpci, TTBOMK AC_PATH_PROG(PERL, perl, no) dnl unlikely as this may be ... if test "x$PERL" = xno; then @@ -1671,7 +1674,6 @@ hw/xfree86/parser/Makefile hw/xfree86/rac/Makefile hw/xfree86/ramdac/Makefile -hw/xfree86/scanpci/Makefile hw/xfree86/shadowfb/Makefile hw/xfree86/vbe/Makefile hw/xfree86/vgahw/Makefile @@ -1686,8 +1688,6 @@ hw/xfree86/utils/gtf/Makefile hw/xfree86/utils/ioport/Makefile hw/xfree86/utils/kbd_mode/Makefile -hw/xfree86/utils/pcitweak/Makefile -hw/xfree86/utils/scanpci/Makefile hw/xfree86/utils/xorgcfg/Makefile hw/xfree86/utils/xorgconfig/Makefile hw/dmx/config/Makefile Index: hw/xfree86/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/Makefile.am,v retrieving revision 1.38 diff -u -d -r1.38 Makefile.am --- hw/xfree86/Makefile.am 25 Jan 2006 23:05:26 -0000 1.38 +++ hw/xfree86/Makefile.am 27 Apr 2006 17:26:44 -0000 @@ -6,12 +6,12 @@ SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support parser rac \ ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp xf8_16bpp \ - xf8_32bpp loader scanpci dixmods exa \ + xf8_32bpp loader dixmods exa \ $(DRI_SUBDIR) utils $(DOC_SUBDIR) getconfig DIST_SUBDIRS = common ddc dummylib i2c x86emu int10 fbdevhw os-support \ parser rac ramdac shadowfb vbe vgahw xaa xf1bpp xf4bpp \ - xf8_16bpp xf8_32bpp loader scanpci dixmods dri exa \ + xf8_16bpp xf8_32bpp loader dixmods dri exa \ utils doc getconfig bin_PROGRAMS = Xorg Index: hw/xfree86/common/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/Makefile.am,v retrieving revision 1.17 diff -u -d -r1.17 Makefile.am --- hw/xfree86/common/Makefile.am 2 Dec 2005 06:02:40 -0000 1.17 +++ hw/xfree86/common/Makefile.am 27 Apr 2006 17:26:44 -0000 @@ -46,7 +46,7 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ -I$(srcdir)/../loader -I$(srcdir)/../rac -I$(srcdir)/../parser \ - -I$(srcdir)/../scanpci -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \ Index: hw/xfree86/common/xf86.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86.h,v retrieving revision 1.12 diff -u -d -r1.12 xf86.h --- hw/xfree86/common/xf86.h 7 Mar 2006 23:58:22 -0000 1.12 +++ hw/xfree86/common/xf86.h 27 Apr 2006 17:26:44 -0000 @@ -37,6 +37,8 @@ #ifndef _XF86_H #define _XF86_H +#include + #include "xf86str.h" #include "xf86Opt.h" #include @@ -94,16 +96,13 @@ /* xf86Bus.c */ -Bool xf86CheckPciSlot(int bus, int device, int func); -int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp, +Bool xf86CheckPciSlot( const struct pci_device * ); +int xf86ClaimPciSlot( struct pci_device *, DriverPtr drvp, int chipset, GDevPtr dev, Bool active); Bool xf86ParsePciBusString(const char *busID, int *bus, int *device, int *func); Bool xf86ComparePciBusString(const char *busID, int bus, int device, int func); void xf86FormatPciBusNumber(int busnum, char *buffer); -pciVideoPtr *xf86GetPciVideoInfo(void); -pciConfigPtr *xf86GetPciConfigInfo(void); -void xf86SetPciVideo(pciVideoPtr, resType); void xf86PrintResList(int verb, resPtr list); resPtr xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex); int xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); @@ -114,7 +113,7 @@ int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); void xf86EnableAccess(ScrnInfoPtr pScrn); void xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn); -Bool xf86IsPrimaryPci(pciVideoPtr pPci); +Bool xf86IsPrimaryPci(struct pci_device * pPci); Bool xf86IsPrimaryIsa(void); /* new RAC */ resPtr xf86AddResToList(resPtr rlist, resRange *Range, int entityIndex); @@ -130,19 +129,17 @@ GDevPtr xf86GetDevFromEntity(int entityIndex, int instance); void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex); EntityInfoPtr xf86GetEntityInfo(int entityIndex); -pciVideoPtr xf86GetPciInfoForEntity(int entityIndex); +struct pci_device * xf86GetPciInfoForEntity(int entityIndex); int xf86GetPciEntity(int bus, int dev, int func); Bool xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter, EntityProc leave, pointer); void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type); resPtr xf86RegisterResources(int entityIndex, resList list, unsigned long Access); -Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base); +Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base); void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs, xf86SetAccessFuncPtr oldFuncs); Bool xf86IsEntityPrimary(int entityIndex); -Bool xf86FixPciResource(int entityIndex, int prt, memType alignment, - unsigned long type); resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes); resPtr xf86SetOperatingState(resList list, int entityIndex, int mask); void xf86EnterServerState(xf86State state); @@ -153,17 +150,13 @@ memType decode_mask, memType address_mask, resPtr avoid); memType xf86ChkConflict(resRange *rgp, int entityIndex); -Bool xf86IsPciDevPresent(int bus, int dev, int func); ScrnInfoPtr xf86FindScreenForEntity(int entityIndex); Bool xf86NoSharedResources(int screenIndex, resType res); resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2); -pciVideoPtr xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID, - char n, pciVideoPtr pvp_exclude); -pciVideoPtr xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class, - char n, pciVideoPtr pvp_exclude); -#ifdef INCLUDE_DEPRECATED -void xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable); -#endif +struct pci_device * xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID, + char n, const struct pci_device * pvp_exclude); +struct pci_device * xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class, + char n, const struct pci_device * pvp_exclude); void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg); Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func); #ifdef async @@ -185,8 +178,8 @@ /* xf86Configure.c */ GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset); -GDevPtr xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, - int chipset); +GDevPtr xf86AddDeviceToConfigure( const char *driver, + struct pci_device * pVideo, int chipset ); /* xf86Cursor.c */ Index: hw/xfree86/common/xf86AutoConfig.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86AutoConfig.c,v retrieving revision 1.4 diff -u -d -r1.4 xf86AutoConfig.c --- hw/xfree86/common/xf86AutoConfig.c 23 Aug 2005 20:12:26 -0000 1.4 +++ hw/xfree86/common/xf86AutoConfig.c 27 Apr 2006 17:26:44 -0000 @@ -176,7 +176,8 @@ { const char **p; char buf[1024]; - pciVideoPtr *pciptr, info = NULL; + struct pci_device ** pciptr; + struct pci_device * info = NULL; char *driver = NULL; FILE *gp = NULL; ConfigStatus ret; @@ -267,8 +268,8 @@ } strcat(searchPath, GETCONFIG_DIR); - ErrorF("xf86AutoConfig: Primary PCI is %d:%d:%d\n", - info->bus, info->device, info->func); + ErrorF("xf86AutoConfig: Primary PCI is %u@%u:%u:%u\n", + info->domain, info->bus, info->dev, info->func); snprintf(buf, sizeof(buf), "%s" #ifdef DEBUG @@ -281,9 +282,9 @@ path, (unsigned int)xorgGetVersion(), searchPath, - info->vendor, info->chipType, info->chipRev, - info->subsysVendor, info->subsysCard, - info->class << 8 | info->subclass); + info->vendor_id, info->device_id, info->revision, + info->subvendor_id, info->subdevice_id, + info->device_class >> 8); ErrorF("Running \"%s\"\n", buf); gp = Popen(buf, "r"); if (gp) { @@ -365,4 +366,3 @@ return FALSE; } } - Index: hw/xfree86/common/xf86Bus.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Bus.c,v retrieving revision 1.11 diff -u -d -r1.11 xf86Bus.c --- hw/xfree86/common/xf86Bus.c 25 Mar 2006 19:52:03 -0000 1.11 +++ hw/xfree86/common/xf86Bus.c 27 Apr 2006 17:26:45 -0000 @@ -53,6 +53,7 @@ #include "xf86_OSproc.h" #include "xf86RAC.h" +#include "Pci.h" /* Entity data */ EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */ @@ -1402,7 +1403,9 @@ void xf86ResourceBrokerInit(void) { +#if 0 resPtr resPci; +#endif osRes = NULL; @@ -1417,8 +1420,12 @@ xf86PrintResList(3, osRes); /* Bus dep initialization */ +#if 0 resPci = ResourceBrokerInitPci(&osRes); Acc = xf86JoinResLists(xf86DupResList(osRes), resPci); +#else + Acc = xf86DupResList( osRes ); +#endif xf86MsgVerb(X_INFO, 3, "All system resource ranges:\n"); xf86PrintResList(3, Acc); @@ -1806,7 +1813,7 @@ case BUS_SBUS: return NULL; case BUS_PCI: - return GetImplicitPciResources(entityIndex); + return NULL; case BUS_last: return NULL; } @@ -1888,31 +1895,32 @@ } static void -busTypeSpecific(EntityPtr pEnt, xf86State state, xf86AccessPtr *acc_mem, - xf86AccessPtr *acc_io, xf86AccessPtr *acc_mem_io) +busTypeSpecific( EntityPtr pEnt, xf86AccessPtr *acc_mem, + xf86AccessPtr *acc_io, xf86AccessPtr *acc_mem_io ) { - pciAccPtr *ppaccp; - switch (pEnt->bus.type) { case BUS_ISA: case BUS_SBUS: - *acc_mem = *acc_io = *acc_mem_io = &AccessNULL; - break; + *acc_mem = *acc_io = *acc_mem_io = &AccessNULL; break; - case BUS_PCI: - ppaccp = xf86PciAccInfo; - while (*ppaccp) { - if ((*ppaccp)->busnum == pEnt->pciBusId.bus - && (*ppaccp)->devnum == pEnt->pciBusId.device - && (*ppaccp)->funcnum == pEnt->pciBusId.func) { - *acc_io = &(*ppaccp)->ioAccess; - *acc_mem = &(*ppaccp)->memAccess; - *acc_mem_io = &(*ppaccp)->io_memAccess; - break; + case BUS_PCI: { + struct pci_device * dev = + pci_device_find_by_slot( PCI_DOM_FROM_BUS( pEnt->pciBusId.bus ), + PCI_BUS_NO_DOMAIN( pEnt->pciBusId.bus ), + pEnt->pciBusId.device, + pEnt->pciBusId.func ); + + if ( dev != NULL ) { + pciAccPtr paccp = (pciAccPtr) dev->user_data; + + if ( paccp != NULL ) { + *acc_io = & paccp->ioAccess; + *acc_mem = & paccp->memAccess; + *acc_mem_io = & paccp->io_memAccess; } - ppaccp++; } break; + } default: *acc_mem = *acc_io = *acc_mem_io = NULL; break; @@ -1928,7 +1936,7 @@ xf86AccessPtr org_mem = NULL, org_io = NULL, org_mem_io = NULL; int prop; - busTypeSpecific(pEnt,state,&acc_mem,&acc_io,&acc_mem_io); + busTypeSpecific( pEnt, &acc_mem, &acc_io, &acc_mem_io ); /* The replacement function needs to handle _all_ shared resources */ /* unless they are handeled locally and disabled otherwise */ @@ -2481,15 +2489,6 @@ #endif } xf86FreeResList(acc); -#if !(defined(__alpha__) && defined(linux)) && \ - !(defined(__ia64__) && defined(linux)) && \ - !(defined(__sparc64__) && defined(__OpenBSD__)) - /* - * No need to validate on Alpha Linux or OpenBSD/sparc64, - * trust the kernel. - */ - ValidatePci(); -#endif xf86MsgVerb(X_INFO, 3, "resource ranges after probing:\n"); xf86PrintResList(3, Acc); Index: hw/xfree86/common/xf86Bus.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Bus.h,v retrieving revision 1.2 diff -u -d -r1.2 xf86Bus.h --- hw/xfree86/common/xf86Bus.h 3 Jul 2005 07:01:24 -0000 1.2 +++ hw/xfree86/common/xf86Bus.h 27 Apr 2006 17:26:45 -0000 @@ -124,7 +124,7 @@ struct { int bus; int primary_bus; - PCITAG acc; + struct pci_device * dev; pciBridgesSave save; } pci; } busdep; Index: hw/xfree86/common/xf86Configure.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Configure.c,v retrieving revision 1.18 diff -u -d -r1.18 xf86Configure.c --- hw/xfree86/common/xf86Configure.c 25 Mar 2006 19:52:03 -0000 1.18 +++ hw/xfree86/common/xf86Configure.c 27 Apr 2006 17:26:45 -0000 @@ -36,6 +36,8 @@ #include #include #include +#include +#include "Pci.h" #include "os.h" #ifdef XFree86LOADER #include "loaderProcs.h" @@ -44,7 +46,6 @@ #include "xf86Config.h" #include "xf86_OSlib.h" #include "xf86Priv.h" -#include "xf86PciData.h" #define IN_XSERVER #include "xf86Parser.h" #include "xf86tokens.h" @@ -59,7 +60,7 @@ typedef struct _DevToConfig { GDevRec GDev; - pciVideoPtr pVideo; + struct pci_device * pVideo; #if defined(__sparc__) && !defined(__OpenBSD__) sbusDevicePtr sVideo; #endif @@ -104,7 +105,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset) { int i, j; - pciVideoPtr pVideo = NULL; + struct pci_device * pVideo = NULL; Bool isPrimary = FALSE; if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1) @@ -113,11 +114,12 @@ /* Check for duplicates */ switch (bus) { case BUS_PCI: - pVideo = (pciVideoPtr) busData; + pVideo = (struct pci_device *) busData; for (i = 0; i < nDevToConfig; i++) if (DevToConfig[i].pVideo && + (DevToConfig[i].pVideo->domain == pVideo->domain) && (DevToConfig[i].pVideo->bus == pVideo->bus) && - (DevToConfig[i].pVideo->device == pVideo->device) && + (DevToConfig[i].pVideo->dev == pVideo->dev) && (DevToConfig[i].pVideo->func == pVideo->func)) return NULL; isPrimary = xf86IsPrimaryPci(pVideo); @@ -176,9 +178,9 @@ char busnum[8]; NewDevice.pVideo = pVideo; - xf86FindPciNamesByDevice(pVideo->vendor, pVideo->chipType, - NOVENDOR, NOSUBSYS, - &VendorName, &CardName, NULL, NULL); + + VendorName = pci_device_get_vendor_name( pVideo ); + CardName = pci_device_get_device_name( pVideo ); if (!VendorName) { VendorName = xnfalloc(15); @@ -200,13 +202,13 @@ NewDevice.GDev.busID = xnfalloc(16); xf86FormatPciBusNumber(pVideo->bus, busnum); sprintf(NewDevice.GDev.busID, "PCI:%s:%d:%d", - busnum, pVideo->device, pVideo->func); + busnum, pVideo->dev, pVideo->func); - NewDevice.GDev.chipID = pVideo->chipType; - NewDevice.GDev.chipRev = pVideo->chipRev; + NewDevice.GDev.chipID = pVideo->device_id; + NewDevice.GDev.chipRev = pVideo->revision; if (chipset < 0) - chipset = (pVideo->vendor << 16) | pVideo->chipType; + chipset = (pVideo->vendor_id << 16) | pVideo->device_id; } break; case BUS_ISA: @@ -252,7 +254,8 @@ * Backwards compatibility */ _X_EXPORT GDevPtr -xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset) +xf86AddDeviceToConfigure(const char *driver, struct pci_device * pVideo, + int chipset) { return xf86AddBusDeviceToConfigure(driver, pVideo ? BUS_PCI : BUS_ISA, pVideo, chipset); @@ -832,22 +835,20 @@ /* Call all of the probe functions, reporting the results. */ for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) { xorgHWFlags flags; - + Bool found_screen; + DriverRec * const drv = xf86DriverList[CurrentDriver]; + if (!xorgHWAccess) { - if (!xf86DriverList[CurrentDriver]->driverFunc - || !xf86DriverList[CurrentDriver]->driverFunc(NULL, - GET_REQUIRED_HW_INTERFACES, - &flags) + if (!drv->driverFunc + || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags ) || NEED_IO_ENABLED(flags)) continue; } - if (xf86DriverList[CurrentDriver]->Probe == NULL) continue; - - if ((*xf86DriverList[CurrentDriver]->Probe)( - xf86DriverList[CurrentDriver], PROBE_DETECT) && - xf86DriverList[CurrentDriver]->Identify) - (*xf86DriverList[CurrentDriver]->Identify)(0); + found_screen = xf86CallDriverProbe( drv, TRUE ); + if ( found_screen && drv->Identify ) { + (*drv->Identify)(0); + } } if (nDevToConfig <= 0) { @@ -936,7 +937,7 @@ oldNumScreens = xf86NumScreens; - (*xf86DriverList[i]->Probe)(xf86DriverList[i], 0); + xf86CallDriverProbe( xf86DriverList[i], FALSE ); /* reorder */ k = screennum > 0 ? screennum : 1; @@ -964,7 +965,6 @@ } } } - xf86SetPciVideo(NULL,NONE); } xfree(driverProbed); } Index: hw/xfree86/common/xf86DoProbe.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86DoProbe.c,v retrieving revision 1.7 diff -u -d -r1.7 xf86DoProbe.c --- hw/xfree86/common/xf86DoProbe.c 7 Mar 2006 23:58:22 -0000 1.7 +++ hw/xfree86/common/xf86DoProbe.c 27 Apr 2006 17:26:45 -0000 @@ -97,9 +97,7 @@ xf86MsgVerb(X_INFO, 3, "Probing in driver %s\n", drv->driverName); - if (drv->Probe == NULL) continue; - - probeResult = (*drv->Probe)( drv, PROBE_DETECT ); + probeResult = xf86CallDriverProbe( drv, TRUE ); if (!probeResult) { xf86ErrorF("Probe in driver `%s' returns FALSE\n", drv->driverName); Index: hw/xfree86/common/xf86DoScanPci.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86DoScanPci.c,v retrieving revision 1.5 diff -u -d -r1.5 xf86DoScanPci.c --- hw/xfree86/common/xf86DoScanPci.c 3 Jul 2005 08:53:42 -0000 1.5 +++ hw/xfree86/common/xf86DoScanPci.c 27 Apr 2006 17:26:45 -0000 @@ -39,6 +39,7 @@ #include #include #include +#include #include "os.h" #ifdef XFree86LOADER #include "loaderProcs.h" @@ -46,17 +47,100 @@ #include "xf86.h" #include "xf86Priv.h" #include "xf86Pci.h" -#include "xf86ScanPci.h" + +static void ScanPciDisplayPCICardInfo( int verbosity ); + +void +ScanPciDisplayPCICardInfo(int verbosity) +{ + struct pci_id_match match; + pciConfigPtr pcrp, *pcrpp; + int i; + + xf86EnableIO(); + pcrpp = xf86scanpci(0); + + if (pcrpp == NULL) { + xf86MsgVerb(X_NONE,0,"No PCI info available\n"); + return; + } + xf86MsgVerb(X_NONE,0,"Probing for PCI devices (Bus:Device:Function)\n\n"); + for (i = 0; (pcrp = pcrpp[i]); i++) { + const char *svendorname = NULL, *subsysname = NULL; + const char *vendorname = NULL, *devicename = NULL; + Bool noCard = FALSE; + const char *prefix1 = "", *prefix2 = ""; + + xf86MsgVerb(X_NONE, -verbosity, "(%d:%d:%d) ", + pcrp->busnum, pcrp->devnum, pcrp->funcnum); + + /* + * Lookup as much as we can about the device. + */ + match.vendor_id = pcrp->pci_vendor; + match.device_id = pcrp->_pci_device; + match.subvendor_id = (pcrp->pci_subsys_vendor != 0) + ? pcrp->pci_subsys_vendor : PCI_MATCH_ANY; + match.subdevice_id = (pcrp->pci_subsys_card != 0) + ? pcrp->pci_subsys_card : PCI_MATCH_ANY; + match.device_class = 0; + match.device_class_mask = 0; + + pci_get_strings( & match, & vendorname, & devicename, + & svendorname, & subsysname); + + if (svendorname) + xf86MsgVerb(X_NONE, -verbosity, "%s ", svendorname); + if (subsysname) + xf86MsgVerb(X_NONE, -verbosity, "%s ", subsysname); + if (svendorname && !subsysname) { + if ( match.subdevice_id != PCI_MATCH_ANY ) { + xf86MsgVerb(X_NONE, -verbosity, "unknown card (0x%04x) ", + match.subdevice_id); + } else { + xf86MsgVerb(X_NONE, -verbosity, "card "); + } + } + if (!svendorname && !subsysname) { + /* + * We didn't find a text representation of the information + * about the card. + */ + if ( (match.subvendor_id != PCI_MATCH_ANY) + || (match.subdevice_id != PCI_MATCH_ANY) ) { + /* + * If there was information and we just couldn't interpret + * it, print it out as unknown, anyway. + */ + xf86MsgVerb(X_NONE, -verbosity, + "unknown card (0x%04x/0x%04x) ", + match.subvendor_id, match.subdevice_id); + } else + noCard = TRUE; + } + if (!noCard) { + prefix1 = "using a "; + prefix2 = "using an "; + } + if (vendorname && devicename) { + xf86MsgVerb(X_NONE, -verbosity,"%s%s %s\n", prefix1, vendorname, + devicename); + } else if (vendorname) { + xf86MsgVerb(X_NONE, -verbosity, + "%sunknown chip (DeviceId 0x%04x) from %s\n", + prefix2, match.device_id, vendorname); + } else { + xf86MsgVerb(X_NONE, -verbosity, + "%sunknown chipset(0x%04x/0x%04x)\n", + prefix2, match.vendor_id, match.device_id); + } + } +} void DoScanPci(int argc, char **argv, int i) { - int j,skip,globalVerbose,scanpciVerbose; - ScanPciSetupProcPtr PciSetup; - ScanPciDisplayCardInfoProcPtr DisplayPCICardInfo; -#ifdef XFree86LOADER - int errmaj, errmin; -#endif + int j,skip,globalVerbose; /* * first we need to finish setup of the OS so that we can call other @@ -90,37 +174,7 @@ * Setting scanpciVerbose to 0 will ensure that the output will go to * stderr for all reasonable default stderr verbosity levels. */ - scanpciVerbose = 0; - - /* - * now get the loader set up and load the scanpci module - */ -#ifdef XFree86LOADER - /* Initialise the loader */ - LoaderInit(); - /* Tell the loader the default module search path */ - LoaderSetPath(xf86ModulePath); - - if (!LoadModule("scanpci", NULL, NULL, NULL, NULL, NULL, - &errmaj, &errmin)) { - LoaderErrorMsg(NULL, "scanpci", errmaj, errmin); - exit(1); - } - if (LoaderCheckUnresolved(LD_RESOLV_IFDONE)) { - /* For now, just a warning */ - xf86Msg(X_WARNING, "Some symbols could not be resolved!\n"); - } - PciSetup = (ScanPciSetupProcPtr)LoaderSymbol("ScanPciSetupPciIds"); - DisplayPCICardInfo = - (ScanPciDisplayCardInfoProcPtr)LoaderSymbol("ScanPciDisplayPCICardInfo"); -#else - PciSetup = ScanPciSetupPciIds; - DisplayPCICardInfo = ScanPciDisplayPCICardInfo; -#endif - - if (!(*PciSetup)()) - FatalError("ScanPciSetupPciIds() failed\n"); - (*DisplayPCICardInfo)(scanpciVerbose); + ScanPciDisplayPCICardInfo( 0 ); /* * That's it; we really should clean things up, but a simple Index: hw/xfree86/common/xf86Helper.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Helper.c,v retrieving revision 1.13 diff -u -d -r1.13 xf86Helper.c --- hw/xfree86/common/xf86Helper.c 14 Apr 2006 23:32:22 -0000 1.13 +++ hw/xfree86/common/xf86Helper.c 27 Apr 2006 17:26:46 -0000 @@ -40,6 +40,9 @@ #include #endif +#include +#include "Pci.h" + #include #include "os.h" #include "servermd.h" @@ -1591,7 +1594,7 @@ } struct Inst { - pciVideoPtr pci; + struct pci_device * pci; GDevPtr dev; Bool foundHW; /* PCIid in list of supported chipsets */ Bool claimed; /* BusID matches with a device section */ @@ -1600,6 +1603,192 @@ }; +#define END_OF_MATCHES(m) \ + (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0)) + +Bool +probe_devices_from_device_sections( DriverPtr drvp ) +{ + int i, j; + struct pci_device * pPci; + struct pci_device **ppPci; + Bool foundScreen = FALSE; + const struct pci_id_match * const devices = drvp->supported_devices; + GDevPtr *devList; + const unsigned numDevs = xf86MatchDevice( drvp->driverName, & devList ); + + + for ( i = 0 ; i < numDevs ; i++ ) { + unsigned device_id; + + + /* Find the pciVideoRec associated with this device section. + */ + pPci = NULL; + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + pPci = *ppPci; + + if ( devList[i]->busID && *devList[i]->busID ) { + if (xf86ComparePciBusString(devList[i]->busID, + ((pPci->domain << 8) + | pPci->bus), + pPci->dev, + pPci->func) ) { + break; + } + } + else if ( xf86IsPrimaryPci( pPci ) ) { + break; + } + } + + if ( pPci == NULL ) { + continue; + } + + device_id = (devList[i]->chipID > 0) + ? devList[i]->chipID : pPci->device_id; + + + /* Once the pciVideoRec is found, determine if the device is supported + * by the driver. If it is, probe it! + */ + for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + int entry; + + /* Allow the same entity to be used more than once for + * devices with multiple screens per entity. This assumes + * implicitly that there will be a screen == 0 instance. + * + * FIXME Need to make sure that two different drivers don't + * FIXME claim the same screen > 0 instance. + */ + if ( (devList[i]->screen == 0) && !xf86CheckPciSlot( pPci ) ) + continue; + +#ifdef DEBUG + ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n", + drvp->driverName, pPci->bus, pPci->device, pPci->func); +#endif + + /* Allocate an entry in the lists to be returned */ + entry = xf86ClaimPciSlot( pPci, drvp, device_id, + devList[i], devList[i]->active ); + + if ( (entry == -1) && (devList[i]->screen > 0) ) { + unsigned k; + + for ( k = 0; k < xf86NumEntities; k++ ) { + EntityPtr pEnt = xf86Entities[k]; + if (pEnt->busType != BUS_PCI) + continue; + + if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) && + pEnt->pciBusId.device == pPci->dev && + pEnt->pciBusId.func == pPci->func) { + entry = k; + xf86AddDevToEntity( k, devList[i] ); + break; + } + } + } + + if ( entry != -1 ) { + if ( (*drvp->PciProbe)( drvp, entry, pPci, + devices[j].match_data ) ) { + foundScreen = TRUE; + } + } + + break; + } + } + } + + + return foundScreen; +} + + +Bool +add_matching_devices_to_configure_list( DriverPtr drvp ) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + struct pci_device ** ppPci; + int numFound = 0; + + + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + const struct pci_device * pPci = *ppPci; + + + /* Determine if this device is supported by the driver. If it is, + * add it to the list of devices to configure. + */ + for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + if ( xf86CheckPciSlot( pPci ) ) { + GDevPtr pGDev = + xf86AddDeviceToConfigure( drvp->driverName, pPci, -1 ); + if ( pGDev != NULL ) { + /* After configure pass 1, chipID and chipRev are + * treated as over-rides, so clobber them here. + */ + pGDev->chipID = -1; + pGDev->chipRev = -1; + } + + numFound++; + } + + break; + } + } + } + + + return (numFound != 0); +} + + +Bool +check_for_matching_devices( DriverPtr drvp ) +{ + const struct pci_id_match * const devices = drvp->supported_devices; + int j; + struct pci_device ** ppPci; + + + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + const struct pci_device * pPci = *ppPci; + + + /* Determine if this device is supported by the driver. If it is, + * add it to the list of devices to configure. + */ + for ( j = 0 ; ! END_OF_MATCHES( devices[j] ) ; j++ ) { + if ( PCI_ID_COMPARE( devices[j].vendor_id, pPci->vendor_id ) + && PCI_ID_COMPARE( devices[j].device_id, pPci->device_id ) + && ((devices[j].device_class_mask & pPci->device_class) + == devices[j].device_class) ) { + return TRUE; + } + } + } + + + return FALSE; +} + + /** * Find set of unclaimed devices matching a given vendor ID. * @@ -1639,7 +1828,8 @@ int **foundEntities) { int i,j; - pciVideoPtr pPci, *ppPci; + struct pci_device * pPci; + struct pci_device ** ppPci; struct Inst *instances = NULL; int numClaimedInstances = 0; int allocatedInstances = 0; @@ -1667,8 +1857,7 @@ } for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { - unsigned device_class = ((*ppPci)->class << 16) - | ((*ppPci)->subclass << 8) | ((*ppPci)->interface); + unsigned device_class = (*ppPci)->device_class; Bool foundVendor = FALSE; @@ -1698,7 +1887,7 @@ const unsigned device_id = (id->PCIid & 0x0000FFFF); const unsigned match_class = 0x00030000 | id->PCIid; - if ( (vendor_id == pPci->vendor) + if ( (vendor_id == pPci->vendor_id) || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class)) ) { if ( !foundVendor && (instances != NULL) ) { ++allocatedInstances; @@ -1707,9 +1896,11 @@ instances[allocatedInstances - 1].claimed = FALSE; instances[allocatedInstances - 1].foundHW = FALSE; instances[allocatedInstances - 1].screen = 0; - foundVendor = TRUE; } - if ( (device_id == pPci->chipType) + + foundVendor = TRUE; + + if ( (device_id == pPci->device_id) || ((vendorID == PCI_VENDOR_GENERIC) && (match_class == device_class)) ) { if ( instances != NULL ) { @@ -1719,8 +1910,7 @@ if ( xf86DoConfigure && xf86DoConfigurePass1 ) { - if ( xf86CheckPciSlot(pPci->bus, pPci->device, - pPci->func) ) { + if ( xf86CheckPciSlot( pPci ) ) { GDevPtr pGDev = xf86AddDeviceToConfigure( drvp->driverName, pPci, -1 ); @@ -1783,8 +1973,9 @@ && *devList[j]->busID) { for (i = 0; i < allocatedInstances; i++) { pPci = instances[i].pci; - if (xf86ComparePciBusString(devList[j]->busID, pPci->bus, - pPci->device, + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, pPci->func)) { allocatedInstances++; instances[allocatedInstances - 1] = instances[i]; @@ -1804,9 +1995,10 @@ pPci = instances[i].pci; for (j = 0; j < numDevs; j++) { if (devList[j]->busID && *devList[j]->busID) { - if (xf86ComparePciBusString(devList[j]->busID, pPci->bus, - pPci->device, - pPci->func) && + if (xf86ComparePciBusString(devList[j]->busID, + PCI_MAKE_BUS( pPci->domain, pPci->bus ), + pPci->dev, + pPci->func) && devList[j]->screen == instances[i].screen) { if (devBus) @@ -1837,10 +2029,11 @@ } if (devBus) dev = devBus; /* busID preferred */ if (!dev) { - if (xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func)) { + if ( xf86CheckPciSlot( pPci ) ) { xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section " - "for instance (BusID PCI:%i:%i:%i) found\n", - driverName, pPci->bus, pPci->device, pPci->func); + "for instance (BusID PCI:%u@%u:%u:%u) found\n", + driverName, pPci->domain, pPci->bus, pPci->dev, + pPci->func); } } else { numClaimedInstances++; @@ -1951,30 +2144,28 @@ * XXX Need to make sure that two different drivers don't claim * the same screen > 0 instance. */ - if (instances[i].screen == 0 && - !xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func)) + if (instances[i].screen == 0 && !xf86CheckPciSlot( pPci )) continue; #ifdef DEBUG ErrorF("%s: card at %d:%d:%d is claimed by a Device section\n", - driverName, pPci->bus, pPci->device, pPci->func); + driverName, pPci->bus, pPci->dev, pPci->func); #endif /* Allocate an entry in the lists to be returned */ numFound++; retEntities = xnfrealloc(retEntities, numFound * sizeof(int)); - retEntities[numFound - 1] - = xf86ClaimPciSlot(pPci->bus, pPci->device, - pPci->func,drvp, instances[i].chip, - instances[i].dev,instances[i].dev->active ? - TRUE : FALSE); + retEntities[numFound - 1] = xf86ClaimPciSlot( pPci, drvp, + instances[i].chip, + instances[i].dev, + instances[i].dev->active); if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) { for (j = 0; j < xf86NumEntities; j++) { EntityPtr pEnt = xf86Entities[j]; if (pEnt->busType != BUS_PCI) continue; - if (pEnt->pciBusId.bus == pPci->bus && - pEnt->pciBusId.device == pPci->device && + if (pEnt->pciBusId.bus == PCI_MAKE_BUS( pPci->domain, pPci->bus ) && + pEnt->pciBusId.device == pPci->dev && pEnt->pciBusId.func == pPci->func) { retEntities[numFound - 1] = j; xf86AddDevToEntity(j, instances[i].dev); Index: hw/xfree86/common/xf86Init.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Init.c,v retrieving revision 1.34 diff -u -d -r1.34 xf86Init.c --- hw/xfree86/common/xf86Init.c 4 Apr 2006 14:17:04 -0000 1.34 +++ hw/xfree86/common/xf86Init.c 27 Apr 2006 17:26:46 -0000 @@ -120,9 +120,8 @@ #endif #ifdef XFree86LOADER -static char *baseModules[] = { +static const char * const baseModules[] = { "bitmap", - "pcidata", NULL }; #endif @@ -273,6 +272,53 @@ OsInitColors(); } + +/** + * Call the driver's correct probe function. + * + * If the driver implements the \c DriverRec::PciProbe entry-point and an + * appropriate PCI device (with matching Device section in the xorg.conf file) + * is found, it is called. If \c DriverRec::PciProbe or no devices can be + * successfully probed with it (e.g., only non-PCI devices are available), + * the driver's \c DriverRec::Probe function is called. + * + * \param drv Driver to probe + * + * \return + * If a device can be successfully probed by the driver, \c TRUE is + * returned. Otherwise, \c FALSE is returned. + */ +Bool +xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) +{ + Bool foundScreen = FALSE; + + if ( drv->PciProbe != NULL ) { + if ( xf86DoProbe ) { + assert( detect_only ); + foundScreen = check_for_matching_devices( drv ); + } + else if ( xf86DoConfigure && xf86DoConfigurePass1 ) { + assert( detect_only ); + foundScreen = add_matching_devices_to_configure_list( drv ); + } + else { + assert( ! detect_only ); + foundScreen = probe_devices_from_device_sections( drv ); + } + } + + if ( ! foundScreen && (drv->Probe != NULL) ) { + xf86Msg( X_WARNING, "Falling back to old probe method for %s\n", + drv->driverName ); + foundScreen = (*drv->Probe)( drv, (detect_only) ? PROBE_DETECT + : PROBE_DEFAULT ); + } + + return foundScreen; +} + + void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) { @@ -507,16 +553,8 @@ || NEED_IO_ENABLED(flags)) continue; } - - if (xf86DriverList[i]->Probe != NULL) - xf86DriverList[i]->Probe(xf86DriverList[i], PROBE_DEFAULT); - else { - xf86MsgVerb(X_WARNING, 0, - "Driver `%s' has no Probe function (ignoring)\n", - xf86DriverList[i]->driverName - ? xf86DriverList[i]->driverName : "noname"); - } - xf86SetPciVideo(NULL,NONE); + + xf86CallDriverProbe( xf86DriverList[i], FALSE ); } /* Index: hw/xfree86/common/xf86Priv.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86Priv.h,v retrieving revision 1.8 diff -u -d -r1.8 xf86Priv.h --- hw/xfree86/common/xf86Priv.h 7 Mar 2006 23:58:22 -0000 1.8 +++ hw/xfree86/common/xf86Priv.h 27 Apr 2006 17:26:46 -0000 @@ -37,6 +37,8 @@ #ifndef _XF86PRIV_H #define _XF86PRIV_H +#include + #include "xf86Privstr.h" #include "propertyst.h" @@ -107,7 +109,7 @@ extern Bool xf86Initialising; extern Bool xf86ProbeFailed; extern int xf86NumScreens; -extern pciVideoPtr *xf86PciVideoInfo; +extern struct pci_device ** xf86PciVideoInfo; extern xf86CurrentAccessRec xf86CurrentAccess; extern const char *xf86VisualNames[]; extern int xf86Verbose; /* verbosity level */ @@ -154,8 +156,6 @@ void xf86AddDevToEntity(int entityIndex, GDevPtr dev); extern void xf86PostPreInit(void); extern void xf86PostScreenInit(void); -extern memType getValidBIOSBase(PCITAG tag, int num); -extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag); /* xf86Config.c */ @@ -196,6 +196,7 @@ Bool xf86LoadModules(char **list, pointer *optlist); int xf86SetVerbosity(int verb); int xf86SetLogVerbosity(int verb); +Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only ); /* xf86Io.c */ Index: hw/xfree86/common/xf86pciBus.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86pciBus.c,v retrieving revision 1.19 diff -u -d -r1.19 xf86pciBus.c --- hw/xfree86/common/xf86pciBus.c 26 Apr 2006 11:31:07 -0000 1.19 +++ hw/xfree86/common/xf86pciBus.c 27 Apr 2006 17:26:46 -0000 @@ -29,8 +29,6 @@ /* * This file contains the interfaces to the bus-specific code */ -#define INCLUDE_DEPRECATED 1 - #ifdef HAVE_XORG_CONFIG_H #include #endif @@ -39,6 +37,7 @@ #include #include #include +#include #include "os.h" #include "Pci.h" #include "xf86.h" @@ -46,8 +45,6 @@ #include "xf86Resources.h" /* Bus-specific headers */ -#include "xf86PciData.h" - #include "xf86Bus.h" #define XF86_OS_PRIVS @@ -58,67 +55,56 @@ /* Bus-specific globals */ Bool pciSlotClaimed = FALSE; -pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */ -pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */ -pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */ - -/* pcidata globals */ -ScanPciSetupProcPtr xf86SetupPciIds = NULL; -ScanPciCloseProcPtr xf86ClosePciIds = NULL; -ScanPciFindByDeviceProcPtr xf86FindPciNamesByDevice = NULL; -ScanPciFindBySubsysProcPtr xf86FindPciNamesBySubsys = NULL; - -static resPtr pciAvoidRes = NULL; +static pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */ +struct pci_device ** xf86PciVideoInfo = NULL; /* PCI probe for video hw */ /* PCI buses */ static PciBusPtr xf86PciBus = NULL; /* Bus-specific probe/sorting functions */ /* PCI classes that get included in xf86PciVideoInfo */ -#define PCIINFOCLASSES(b,s) \ - (((b) == PCI_CLASS_PREHISTORIC) || \ - ((b) == PCI_CLASS_DISPLAY) || \ - ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO) || \ - ((b) == PCI_CLASS_PROCESSOR && (s) == PCI_SUBCLASS_PROCESSOR_COPROC)) +#define PCIINFOCLASSES(c) \ + ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) \ + || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_PROCESSOR << 16) | (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) ) /* * PCI classes that have messages printed always. The others are only * have a message printed when the vendor/dev IDs are recognised. */ -#define PCIALWAYSPRINTCLASSES(b,s) \ - (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \ - ((b) == PCI_CLASS_DISPLAY) || \ - ((b) == PCI_CLASS_MULTIMEDIA && (s) == PCI_SUBCLASS_MULTIMEDIA_VIDEO)) - +#define PCIALWAYSPRINTCLASSES(c) \ + ( (((c) & 0x00ffff00) \ + == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \ + || (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) \ + || ((((c) & 0x00ffff00) \ + == ((PCI_CLASS_MULTIMEDIA << 16) | (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) ) + +#define IS_VGA(c) \ + (((c) & 0x00ffff00) \ + == ((PCI_CLASS_DISPLAY << 16) | (PCI_SUBCLASS_DISPLAY_VGA << 8))) + /* * PCI classes for which potentially destructive checking of the map sizes * may be done. Any classes where this may be unsafe should be omitted * from this list. */ -#define PCINONSYSTEMCLASSES(b,s) PCIALWAYSPRINTCLASSES(b,s) +#define PCINONSYSTEMCLASSES(c) PCIALWAYSPRINTCLASSES(c) /* * PCI classes that use RAC */ -#define PCISHAREDIOCLASSES(b,s) \ - (((b) == PCI_CLASS_PREHISTORIC && (s) == PCI_SUBCLASS_PREHISTORIC_VGA) || \ - ((b) == PCI_CLASS_DISPLAY && (s) == PCI_SUBCLASS_DISPLAY_VGA)) +#define PCISHAREDIOCLASSES(c) \ + ( (((c) & 0x00ffff00) \ + == ((PCI_CLASS_PREHISTORIC << 16) | (PCI_SUBCLASS_PREHISTORIC_VGA << 8))) \ + || IS_VGA(c) ) -#define PCI_MEM32_LENGTH_MAX 0xFFFFFFFF #define B2M(tag,base) pciBusAddrToHostAddr(tag,PCI_MEM,base) #define B2I(tag,base) pciBusAddrToHostAddr(tag,PCI_IO,base) -#define B2H(tag,base,type) (((type & ResPhysMask) == ResMem) ? \ - B2M(tag, base) : B2I(tag, base)) -#define M2B(tag,base) pciHostAddrToBusAddr(tag,PCI_MEM,base) -#define I2B(tag,base) pciHostAddrToBusAddr(tag,PCI_IO,base) -#define H2B(tag,base,type) (((type & ResPhysMask) == ResMem) ? \ - M2B(tag, base) : I2B(tag, base)) -#define TAG(pvp) (pciTag(pvp->bus,pvp->device,pvp->func)) -#define SIZE(size) ((1 << size) - 1) -#define PCI_SIZE(type,tag,size) (((type & ResPhysMask) == ResMem) \ - ? pciBusAddrToHostAddr(tag,PCI_MEM_SIZE,size) \ - : pciBusAddrToHostAddr(tag,PCI_IO_SIZE,size)) + #define PCI_M_RANGE(range,tag,begin,end,type) \ { \ RANGE(range, B2M(tag, begin), B2M(tag, end), \ @@ -129,24 +115,7 @@ RANGE(range, B2I(tag, begin), B2I(tag, end), \ RANGE_TYPE(type, xf86GetPciDomain(tag))); \ } -#define PCI_X_RANGE(range,tag,begin,end,type) \ -{ if ((type & ResPhysMask) == ResMem) PCI_M_RANGE(range,tag,begin,end,type); \ - else PCI_I_RANGE(range,tag,begin,end,type); } -#define P_M_RANGE(range,tag,begin,size,type) \ - PCI_M_RANGE(range,tag,begin,(begin + SIZE(size)),type) -#define P_I_RANGE(range,tag,begin,size,type) \ - PCI_I_RANGE(range,tag,begin,(begin + SIZE(size)),type) -#define P_X_RANGE(range,tag,begin,size,type) \ -{ if ((type & ResPhysMask) == ResMem) P_M_RANGE(range,tag,begin,size,type); \ - else P_I_RANGE(range,tag,begin,size,type); } -#define PV_M_RANGE(range,pvp,i,type) \ - P_M_RANGE(range,TAG(pvp),pvp->memBase[i],pvp->size[i],type) -#define PV_B_RANGE(range,pvp,type) \ - P_M_RANGE(range,TAG(pvp),pvp->biosBase,pvp->biosSize,type) -#define PV_I_RANGE(range,pvp,i,type) \ - P_I_RANGE(range,TAG(pvp),pvp->ioBase[i],pvp->size[i],type) -static void pciConvertListToHost(int bus, int dev, int func, resPtr list); static PciBusPtr xf86GetPciBridgeInfo(void); _X_EXPORT void @@ -159,92 +128,66 @@ sprintf(buffer, "%d@%d", busnum & 0x00ff, busnum >> 8); } -static Bool -IsBaseUnassigned(CARD32 base) -{ - CARD32 mask; - - if (base & PCI_MAP_IO) - mask = ~PCI_MAP_IO_ATTR_MASK; - else - mask = ~PCI_MAP_MEMORY_ATTR_MASK; - - base &= mask; - return (!base || (base == mask)); -} - -static Bool -IsBaseUnassigned64(CARD32 base0, CARD32 base1) -{ - base0 &= ~PCI_MAP_MEMORY_ATTR_MASK; - base1 &= 0xffffffff; - - return ((!base0 && !base1) - || ((base0 == ~PCI_MAP_MEMORY_ATTR_MASK) - && (base1 == 0xffffffff))); -} - static void FindPCIVideoInfo(void) { - pciConfigPtr pcrp, *pcrpp; int i = 0, j, k; int num = 0; - pciVideoPtr info; - int DoIsolateDeviceCheck = 0; + struct pci_device * info; + struct pci_slot_match m; + struct pci_device_iterator * iter; - if (xf86IsolateDevice.bus || xf86IsolateDevice.device || xf86IsolateDevice.func) - DoIsolateDeviceCheck = 1; - pcrpp = xf86PciInfo = xf86scanpci(0); - - if (pcrpp == NULL) { + xf86PciInfo = xf86scanpci(0); + + pci_system_init(); + + if (xf86PciInfo == NULL) { xf86PciVideoInfo = NULL; return; } + xf86PciBus = xf86GetPciBridgeInfo(); - while ((pcrp = pcrpp[i])) { - const int baseclass = pcrp->pci_base_class; - const int subclass = pcrp->pci_sub_class; - - if ( PCIINFOCLASSES(baseclass, subclass) && - (!DoIsolateDeviceCheck || - (xf86IsolateDevice.bus == pcrp->busnum && - xf86IsolateDevice.device == pcrp->devnum && - xf86IsolateDevice.func == pcrp->funcnum)) ) { + if ( (xf86IsolateDevice.bus != 0) + || (xf86IsolateDevice.device != 0) + || (xf86IsolateDevice.func != 0) ) { + m.domain = PCI_DOM_FROM_BUS( xf86IsolateDevice.bus ); + m.bus = PCI_BUS_NO_DOMAIN( xf86IsolateDevice.bus ); + m.dev = xf86IsolateDevice.device; + m.func = xf86IsolateDevice.func; + } + else { + m.domain = PCI_MATCH_ANY; + m.bus = PCI_MATCH_ANY; + m.dev = PCI_MATCH_ANY; + m.func = PCI_MATCH_ANY; + } + + iter = pci_slot_match_iterator_create( & m ); + + while ( (info = pci_device_next( iter )) != NULL ) { + if ( PCIINFOCLASSES( info->device_class ) ) { num++; - xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo, - sizeof(pciVideoPtr) * (num + 1)); + xf86PciVideoInfo = xnfrealloc( xf86PciVideoInfo, + (sizeof( struct pci_device * ) + * (num + 1)) ); xf86PciVideoInfo[num] = NULL; - info = xf86PciVideoInfo[num - 1] = xnfalloc(sizeof(pciVideoRec)); - info->validSize = FALSE; - info->vendor = pcrp->pci_vendor; - info->chipType = pcrp->pci_device; - info->chipRev = pcrp->pci_rev_id; - info->subsysVendor = pcrp->pci_subsys_vendor; - info->subsysCard = pcrp->pci_subsys_card; - info->bus = pcrp->busnum; - info->device = pcrp->devnum; - info->func = pcrp->funcnum; - info->class = baseclass; - info->subclass = pcrp->pci_sub_class; - info->interface = pcrp->pci_prog_if; - info->biosBase = PCIGETROM(pcrp->pci_baserom); - info->biosSize = pciGetBaseSize(pcrp->tag, 6, TRUE, NULL); - info->thisCard = pcrp; - info->validate = FALSE; -#ifdef INCLUDE_XF86_NO_DOMAIN - if ((PCISHAREDIOCLASSES(baseclass, subclass)) - && (pcrp->pci_command & PCI_CMD_IO_ENABLE) && - (pcrp->pci_prog_if == 0)) { + xf86PciVideoInfo[num - 1] = info; + pci_device_probe( info ); + info->user_data = 0; + +#if 0 && defined(INCLUDE_XF86_NO_DOMAIN) + if ((PCISHAREDIOCLASSES( info->device_class )) + && (pcrp->pci_command & PCI_CMD_IO_ENABLE) + && (pcrp->pci_prog_if == 0)) { /* * Attempt to ensure that VGA is actually routed to this * adapter on entry. This needs to be fixed when we finally * grok host bridges (and multiple bus trees). */ - j = info->bus; + j = pcrp->busnum; while (TRUE) { PciBusPtr pBus = xf86PciBus; while (pBus && j != pBus->secondary) @@ -269,102 +212,25 @@ } } #endif - - for (j = 0; j < 6; j++) { - info->memBase[j] = 0; - info->ioBase[j] = 0; - if (PCINONSYSTEMCLASSES(baseclass, subclass)) { - info->size[j] = - pciGetBaseSize(pcrp->tag, j, TRUE, &info->validSize); - pcrp->minBasesize = info->validSize; - } else { - info->size[j] = pcrp->basesize[j]; - info->validSize = pcrp->minBasesize; - } - info->type[j] = 0; - } - - if (PCINONSYSTEMCLASSES(baseclass, subclass)) { - /* - * Check of a PCI base is unassigned. If so - * attempt to fix it. Validation will determine - * if the value was correct later on. - */ - CARD32 *base = &pcrp->pci_base0; - - for (j = 0; j < 6; j++) { - if (!PCI_MAP_IS64BITMEM(base[j])) { - if (info->size[j] && IsBaseUnassigned(base[j])) - base[j] = pciCheckForBrokenBase(pcrp->tag, j); - } else { - if (j == 5) /* bail out */ - break; - if (info->size[j] - && IsBaseUnassigned64(base[j],base[j+1])) { - base[j] = pciCheckForBrokenBase(pcrp->tag, j); - j++; - base[j] = pciCheckForBrokenBase(pcrp->tag, j); - } - } - } - } - - /* - * 64-bit base addresses are checked for and avoided on 32-bit - * platforms. - */ - for (j = 0; j < 6; ++j) { - CARD32 bar = (&pcrp->pci_base0)[j]; - - if (bar != 0) { - if (bar & PCI_MAP_IO) { - info->ioBase[j] = (memType)PCIGETIO(bar); - info->type[j] = bar & PCI_MAP_IO_ATTR_MASK; - } else { - info->type[j] = bar & PCI_MAP_MEMORY_ATTR_MASK; - info->memBase[j] = (memType)PCIGETMEMORY(bar); - if (PCI_MAP_IS64BITMEM(bar)) { - if (j == 5) { - xf86MsgVerb(X_WARNING, 0, - "****BAR5 specified as 64-bit wide, " - "which is not possible. " - "Ignoring BAR5.****\n"); - info->memBase[j] = 0; - } else { - CARD32 bar_hi = PCIGETMEMORY64HIGH((&pcrp->pci_base0)[j]); -#if defined(LONG64) || defined(WORD64) - /* 64 bit architecture */ - info->memBase[j] |= - (memType)bar_hi << 32; -#else - if (bar_hi != 0) - info->memBase[j] = 0; -#endif - ++j; /* Step over the next BAR */ - } - } - } - } - } } - i++; } + /* If we haven't found a primary device try a different heuristic */ if (primaryBus.type == BUS_NONE && num) { for (i = 0; i < num; i++) { + uint16_t command; + info = xf86PciVideoInfo[i]; - pcrp = info->thisCard; - - if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) && - (num == 1 || - ((info->class == PCI_CLASS_DISPLAY) && - (info->subclass == PCI_SUBCLASS_DISPLAY_VGA)))) { + pci_device_cfg_read_u16( info, & command, 4 ); + + if ( (command & PCI_CMD_MEM_ENABLE) + && ((num == 1) || IS_VGA( info->device_class )) ) { if (primaryBus.type == BUS_NONE) { primaryBus.type = BUS_PCI; - primaryBus.id.pci.bus = pcrp->busnum; - primaryBus.id.pci.device = pcrp->devnum; - primaryBus.id.pci.func = pcrp->funcnum; + primaryBus.id.pci.bus = PCI_MAKE_BUS( info->domain, info->bus ); + primaryBus.id.pci.device = info->dev; + primaryBus.id.pci.func = info->func; } else { xf86Msg(X_NOTICE, "More than one possible primary device found\n"); @@ -378,141 +244,71 @@ for (k = 0; k < num; k++) { const char *vendorname = NULL, *chipname = NULL; const char *prim = " "; - char busnum[8]; Bool memdone = FALSE, iodone = FALSE; - i = 0; + info = xf86PciVideoInfo[k]; - xf86FormatPciBusNumber(info->bus, busnum); - xf86FindPciNamesByDevice(info->vendor, info->chipType, - NOVENDOR, NOSUBSYS, - &vendorname, &chipname, NULL, NULL); + + vendorname = pci_device_get_vendor_name( info ); + chipname = pci_device_get_device_name( info ); + if ((!vendorname || !chipname) && - !PCIALWAYSPRINTCLASSES(info->class, info->subclass)) + !PCIALWAYSPRINTCLASSES( info->device_class )) continue; + if (xf86IsPrimaryPci(info)) prim = "*"; - xf86Msg(X_PROBED, "PCI:%s(%s:%d:%d) ", prim, busnum, info->device, - info->func); + xf86Msg( X_PROBED, "PCI:%s(%u@%u:%u:%u) ", prim, info->domain, + info->bus, info->dev, info->func ); + if (vendorname) xf86ErrorF("%s ", vendorname); else - xf86ErrorF("unknown vendor (0x%04x) ", info->vendor); + xf86ErrorF("unknown vendor (0x%04x) ", info->vendor_id); + if (chipname) xf86ErrorF("%s ", chipname); else - xf86ErrorF("unknown chipset (0x%04x) ", info->chipType); - xf86ErrorF("rev %d", info->chipRev); + xf86ErrorF("unknown chipset (0x%04x) ", info->device_id); + + xf86ErrorF("rev %d", info->revision); + for (i = 0; i < 6; i++) { - if (info->memBase[i] && - (info->memBase[i] < (memType)(-1 << info->size[i]))) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && ! r->is_IO ) { if (!memdone) { xf86ErrorF(", Mem @ "); memdone = TRUE; } else xf86ErrorF(", "); - xf86ErrorF("0x%08lx/%d", info->memBase[i], info->size[i]); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); } } + for (i = 0; i < 6; i++) { - if (info->ioBase[i] && - (info->ioBase[i] < (memType)(-1 << info->size[i]))) { + struct pci_mem_region * r = & info->regions[i]; + + if ( r->size && r->is_IO ) { if (!iodone) { xf86ErrorF(", I/O @ "); iodone = TRUE; } else xf86ErrorF(", "); - xf86ErrorF("0x%04lx/%d", info->ioBase[i], info->size[i]); + xf86ErrorF("0x%08lx/%ld", r->base_addr, r->size); } } - if (info->biosBase && - (info->biosBase < (memType)(-1 << info->biosSize))) - xf86ErrorF(", BIOS @ 0x%08lx/%d", info->biosBase, info->biosSize); - xf86ErrorF("\n"); - } -} -/* - * fixPciSizeInfo() -- fix pci size info by testing it destructively - * (if not already done), fix pciVideoInfo and entry in the resource - * list. - */ -/* - * Note: once we have OS support to read the sizes GetBaseSize() will - * have to be wrapped by the OS layer. fixPciSizeInfo() should also - * be wrapped by the OS layer to do nothing if the size is always - * returned correctly by GetBaseSize(). It should however set validate - * in pciVideoRec if validation is required. ValidatePci() also needs - * to be wrapped by the OS layer. This may do nothing if the OS has - * already taken care of validation. fixPciResource() may be moved to - * OS layer with minimal changes. Once the wrapping layer is in place - * the common level and drivers should not reference these functions - * directly but thru the OS layer. - */ - -static void -fixPciSizeInfo(int entityIndex) -{ - pciVideoPtr pvp; - resPtr pAcc; - PCITAG tag; - int j; - - if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return; - if (pvp->validSize) return; - - tag = pciTag(pvp->bus,pvp->device,pvp->func); - - for (j = 0; j < 6; j++) { - pAcc = Acc; - if (pvp->memBase[j]) - while (pAcc) { - if (((pAcc->res_type & (ResPhysMask | ResBlock)) - == (ResMem | ResBlock)) - && (pAcc->block_begin == B2M(TAG(pvp),pvp->memBase[j])) - && (pAcc->block_end == B2M(TAG(pvp),pvp->memBase[j] - + SIZE(pvp->size[j])))) break; - pAcc = pAcc->next; - } - else if (pvp->ioBase[j]) - while (pAcc) { - if (((pAcc->res_type & (ResPhysMask | ResBlock)) == - (ResIo | ResBlock)) - && (pAcc->block_begin == B2I(TAG(pvp),pvp->ioBase[j])) - && (pAcc->block_end == B2I(TAG(pvp),pvp->ioBase[j] - + SIZE(pvp->size[j])))) break; - pAcc = pAcc->next; - } - else continue; - pvp->size[j] = pciGetBaseSize(tag, j, TRUE, &pvp->validSize); - if (pAcc) { - pAcc->block_end = pvp->memBase[j] ? - B2M(TAG(pvp),pvp->memBase[j] + SIZE(pvp->size[j])) - : B2I(TAG(pvp),pvp->ioBase[j] + SIZE(pvp->size[j])); - pAcc->res_type &= ~ResEstimated; - pAcc->res_type |= ResBios; - } - } - if (pvp->biosBase) { - pAcc = Acc; - while (pAcc) { - if (((pAcc->res_type & (ResPhysMask | ResBlock)) == - (ResMem | ResBlock)) - && (pAcc->block_begin == B2M(TAG(pvp),pvp->biosBase)) - && (pAcc->block_end == B2M(TAG(pvp),pvp->biosBase - + SIZE(pvp->biosSize)))) break; - pAcc = pAcc->next; - } - pvp->biosSize = pciGetBaseSize(tag, 6, TRUE, &pvp->validSize); - if (pAcc) { - pAcc->block_end = B2M(TAG(pvp),pvp->biosBase+SIZE(pvp->biosSize)); - pAcc->res_type &= ~ResEstimated; - pAcc->res_type |= ResBios; + if ( info->rom_size ) { + xf86ErrorF(", BIOS @ 0x\?\?\?\?\?\?\?\?/%ld", info->rom_size); } + + xf86ErrorF("\n"); } } + /* * IO enable/disable related routines for PCI */ @@ -525,7 +321,7 @@ ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg); #endif pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE; - pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl); + pci_device_cfg_write_u32( pArg->dev, & pArg->ctrl, PCI_CMD_STAT_REG ); } static void @@ -535,7 +331,7 @@ ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg); #endif pArg->ctrl &= ~SETBITS; - pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl); + pci_device_cfg_write_u32( pArg->dev, & pArg->ctrl, PCI_CMD_STAT_REG ); } #undef SETBITS @@ -547,7 +343,7 @@ ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg); #endif pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE; - pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl); + pci_device_cfg_write_u32( pArg->dev, & pArg->ctrl, PCI_CMD_STAT_REG ); } static void @@ -557,7 +353,7 @@ ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg); #endif pArg->ctrl &= ~SETBITS; - pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl); + pci_device_cfg_write_u32( pArg->dev, & pArg->ctrl, PCI_CMD_STAT_REG ); } #undef SETBITS @@ -569,7 +365,7 @@ ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg); #endif pArg->ctrl |= SETBITS | PCI_CMD_MASTER_ENABLE; - pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl); + pci_device_cfg_write_u32( pArg->dev, & pArg->ctrl, PCI_CMD_STAT_REG ); } static void @@ -579,7 +375,7 @@ ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg); #endif pArg->ctrl &= ~SETBITS; - pciWriteLong(pArg->tag, PCI_CMD_STAT_REG, pArg->ctrl); + pci_device_cfg_write_u32( pArg->dev, & pArg->ctrl, PCI_CMD_STAT_REG ); } #undef SETBITS #undef pArg @@ -590,17 +386,17 @@ static void pciBusAccessEnable(BusAccPtr ptr) { - PCITAG tag = ptr->busdep.pci.acc; - CARD16 ctrl; + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t ctrl; #ifdef DEBUG ErrorF("pciBusAccessEnable: bus=%d\n", ptr->busdep.pci.bus); #endif - ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG); + pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); if ((ctrl & MASKBITS) != PCI_PCI_BRIDGE_VGA_EN) { ctrl = (ctrl | PCI_PCI_BRIDGE_VGA_EN) & ~(PCI_PCI_BRIDGE_MASTER_ABORT_EN | PCI_PCI_BRIDGE_SECONDARY_RESET); - pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl); + pci_device_cfg_write_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); } } @@ -608,16 +404,16 @@ static void pciBusAccessDisable(BusAccPtr ptr) { - PCITAG tag = ptr->busdep.pci.acc; - CARD16 ctrl; + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t ctrl; #ifdef DEBUG ErrorF("pciBusAccessDisable: bus=%d\n", ptr->busdep.pci.bus); #endif - ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG); + pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); if (ctrl & MASKBITS) { ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET); - pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl); + pci_device_cfg_write_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); } } #undef MASKBITS @@ -679,44 +475,55 @@ /* move to OS layer */ static void -savePciState(PCITAG tag, pciSavePtr ptr) +savePciState( struct pci_device * dev, pciSavePtr ptr ) { int i; - - ptr->command = pciReadLong(tag, PCI_CMD_STAT_REG); - for (i=0; i < 6; i++) - ptr->base[i] = pciReadLong(tag, PCI_CMD_BASE_REG + i*4); - ptr->biosBase = pciReadLong(tag, PCI_CMD_BIOS_REG); + + pci_device_cfg_read_u32( dev, & ptr->command, PCI_CMD_STAT_REG ); + + for ( i = 0; i < 6; i++ ) { + pci_device_cfg_read_u32( dev, & ptr->base[i], + PCI_CMD_BASE_REG + (i * 4) ); + } + + pci_device_cfg_read_u32( dev, & ptr->biosBase, PCI_CMD_BIOS_REG ); } /* move to OS layer */ static void -restorePciState(PCITAG tag, pciSavePtr ptr) +restorePciState( struct pci_device * dev, pciSavePtr ptr) { int i; /* disable card before setting anything */ - pciSetBitsLong(tag, PCI_CMD_STAT_REG, - PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE , 0); - pciWriteLong(tag,PCI_CMD_BIOS_REG, ptr->biosBase); - for (i=0; i<6; i++) - pciWriteLong(tag, PCI_CMD_BASE_REG + i*4, ptr->base[i]); - pciWriteLong(tag, PCI_CMD_STAT_REG, ptr->command); + pci_device_cfg_write_bits( dev, PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE, 0, + PCI_CMD_STAT_REG ); + + pci_device_cfg_write_u32( dev, & ptr->biosBase, PCI_CMD_BIOS_REG ); + + for ( i = 0; i < 6; i++ ) { + pci_device_cfg_write_u32( dev, & ptr->base[i], + PCI_CMD_BASE_REG + (i * 4) ); + } + + pci_device_cfg_write_u32( dev, & ptr->command, PCI_CMD_STAT_REG ); } /* move to OS layer */ static void savePciBusState(BusAccPtr ptr) { - PCITAG tag = ptr->busdep.pci.acc; + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t temp; + + pci_device_cfg_read_u16( dev, & temp, PCI_PCI_BRIDGE_CONTROL_REG ); + ptr->busdep.pci.save.control = temp & ~PCI_PCI_BRIDGE_SECONDARY_RESET; - ptr->busdep.pci.save.control = - pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG) & - ~PCI_PCI_BRIDGE_SECONDARY_RESET; /* Allow master aborts to complete normally on non-root buses */ - if (ptr->busdep.pci.save.control & PCI_PCI_BRIDGE_MASTER_ABORT_EN) - pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, - ptr->busdep.pci.save.control & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN); + if ( ptr->busdep.pci.save.control & PCI_PCI_BRIDGE_MASTER_ABORT_EN ) { + temp = ptr->busdep.pci.save.control & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN; + pci_device_cfg_read_u16( dev, & temp, PCI_PCI_BRIDGE_CONTROL_REG ); + } } /* move to OS layer */ @@ -724,15 +531,16 @@ static void restorePciBusState(BusAccPtr ptr) { - PCITAG tag = ptr->busdep.pci.acc; - CARD16 ctrl; + struct pci_device * const dev = ptr->busdep.pci.dev; + uint16_t ctrl; /* Only restore the bits we've changed (and don't cause resets) */ - ctrl = pciReadWord(tag, PCI_PCI_BRIDGE_CONTROL_REG); + pci_device_cfg_read_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); + if ((ctrl ^ ptr->busdep.pci.save.control) & MASKBITS) { ctrl &= ~(MASKBITS | PCI_PCI_BRIDGE_SECONDARY_RESET); ctrl |= ptr->busdep.pci.save.control & MASKBITS; - pciWriteWord(tag, PCI_PCI_BRIDGE_CONTROL_REG, ctrl); + pci_device_cfg_write_u16( dev, & ctrl, PCI_PCI_BRIDGE_CONTROL_REG ); } } #undef MASKBITS @@ -763,869 +571,12 @@ static void -disablePciBios(PCITAG tag) -{ - pciSetBitsLong(tag, PCI_CMD_BIOS_REG, PCI_CMD_BIOS_ENABLE, 0); -} - -/* ????? */ -static void -correctPciSize(memType base, memType oldsize, memType newsize, - unsigned long type) -{ - pciConfigPtr pcrp, *pcrpp; - pciVideoPtr pvp, *pvpp; - CARD32 *basep; - int i; - int old_bits = 0, new_bits = 0; - - if (oldsize + 1) while (oldsize & 1) { - old_bits ++; - oldsize >>= 1; - } - if (newsize + 1) while (newsize & 1) { - new_bits ++; - newsize >>= 1; - } - - for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) { - - /* Only process devices with type 0 headers */ - if ((pcrp->pci_header_type & 0x7f) != 0) - continue; - - basep = &pcrp->pci_base0; - for (i = 0; i < 6; i++) { - if (basep[i] && (pcrp->basesize[i] == old_bits)) { - if ((((type & ResPhysMask) == ResIo) && - PCI_MAP_IS_IO(basep[i]) && - B2I(pcrp->tag,PCIGETIO(basep[i]) == base)) || - (((type & ResPhysMask) == ResMem) && - PCI_MAP_IS_MEM(basep[i]) && - (((!PCI_MAP_IS64BITMEM(basep[i])) && - (B2M(pcrp->tag,PCIGETMEMORY(basep[i])) == base)) -#if defined(LONG64) || defined(WORD64) - || - (B2M(pcrp->tag,PCIGETMEMORY64(basep[i])) == base) -#else - || - (!basep[i+1] - && (B2M(pcrp->tag,PCIGETMEMORY(basep[i])) == base)) -#endif - ))) { - pcrp->basesize[i] = new_bits; - break; /* to next device */ - } - } - if (PCI_MAP_IS64BITMEM(basep[i])) i++; - } - } - - if (xf86PciVideoInfo) { - for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) { - - for (i = 0; i < 6; i++) { - if (pvp->size[i] == old_bits) { - if ((((type & ResPhysMask) == ResIo) && pvp->ioBase[i] - && (B2I(TAG(pvp),pvp->ioBase[i]) == base)) || - (((type & ResPhysMask) == ResMem) && pvp->memBase[i] - && (B2M(TAG(pvp),pvp->memBase[i]) == base))) { - pvp->size[i] = new_bits; - break; /* to next device */ - } - } - } - } - } -} - -/* ????? */ -static void -removeOverlapsWithBridges(int busIndex, resPtr target) -{ - PciBusPtr pbp; - resPtr tmp,bridgeRes = NULL; - resRange range; - - if (!target) - return; - - if (!ResCanOverlap(&target->val)) - return; - - range = target->val; - - for (pbp=xf86PciBus; pbp; pbp = pbp->next) { - if (pbp->primary == busIndex) { - tmp = xf86DupResList(pbp->preferred_io); - bridgeRes = xf86JoinResLists(tmp,bridgeRes); - tmp = xf86DupResList(pbp->preferred_mem); - bridgeRes = xf86JoinResLists(tmp,bridgeRes); - tmp = xf86DupResList(pbp->preferred_pmem); - bridgeRes = xf86JoinResLists(tmp,bridgeRes); - } - } - - RemoveOverlaps(target, bridgeRes, TRUE, TRUE); - if (range.rEnd > target->block_end) { - correctPciSize(range.rBegin, range.rEnd - range.rBegin, - target->block_end - target->block_begin, - target->res_type); - xf86MsgVerb(X_INFO, 3, - "PCI %s resource overlap reduced 0x%08lx from 0x%08lx to 0x%08lx\n", - ((target->res_type & ResPhysMask) == ResMem) ? "Memory" : "I/O", - range.rBegin, range.rEnd, target->block_end); - } - xf86FreeResList(bridgeRes); -} - -/* ????? */ -static void -xf86GetPciRes(resPtr *activeRes, resPtr *inactiveRes) -{ - pciConfigPtr pcrp, *pcrpp; - pciVideoPtr pvp, *pvpp; - CARD32 *basep; - int i; - resPtr pRes, tmp; - resRange range; - long resMisc; - - if (activeRes) - *activeRes = NULL; - if (inactiveRes) - *inactiveRes = NULL; - - if (!activeRes || !inactiveRes || !xf86PciInfo) - return; - - if (xf86PciVideoInfo) - for (pvpp = xf86PciVideoInfo, pvp = *pvpp; pvp; pvp = *(++pvpp)) { - resPtr *res; - - if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass)) - resMisc = ResBios; - else - resMisc = 0; - - if (((pciConfigPtr)pvp->thisCard)->pci_command - & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE)) - res = activeRes; - else - res = inactiveRes; - - if (!pvp->validSize) - resMisc |= ResEstimated; - - for (i = 0; i < 6; i++) { - if (pvp->ioBase[i] && - (pvp->ioBase[i] < (memType)(-1 << pvp->size[i]))) { - PV_I_RANGE(range,pvp,i,ResExcIoBlock | resMisc); - tmp = xf86AddResToList(NULL, &range, -1); - removeOverlapsWithBridges(pvp->bus,tmp); - *res = xf86JoinResLists(tmp,*res); - } else if (pvp->memBase[i] && - (pvp->memBase[i] < (memType)(-1 << pvp->size[i]))) { - PV_M_RANGE(range, pvp,i, ResExcMemBlock | resMisc); - tmp = xf86AddResToList(NULL, &range, -1); - removeOverlapsWithBridges(pvp->bus,tmp); - *res = xf86JoinResLists(tmp,*res); - } - } - /* FIXME!!!: Don't use BIOS resources for overlap - * checking but reserve them! - */ - if (pvp->biosBase && - (pvp->biosBase < (memType)(-1 << pvp->biosSize))) { - PV_B_RANGE(range, pvp, ResExcMemBlock | resMisc); - tmp = xf86AddResToList(NULL, &range, -1); - removeOverlapsWithBridges(pvp->bus,tmp); - *res = xf86JoinResLists(tmp,*res); - } - } - - for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) { - resPtr *res; - const CARD8 baseclass = pcrp->pci_base_class; - const CARD8 subclass = pcrp->pci_sub_class; - - - if (PCIINFOCLASSES(baseclass, subclass)) - continue; - - /* Only process devices with type 0 headers */ - if ((pcrp->pci_header_type & 0x7f) != 0) - continue; - - if (!pcrp->minBasesize) - resMisc = ResEstimated; - else - resMisc = 0; - - /* - * Allow resources allocated to host bridges to overlap. Perhaps, this - * needs to be specific to AGP-capable chipsets. AGP "memory" - * sometimes gets allocated within the range routed to the AGP bus. - */ - if ((baseclass == PCI_CLASS_BRIDGE) && - (subclass == PCI_SUBCLASS_BRIDGE_HOST)) - resMisc |= ResOverlap; - - basep = &pcrp->pci_base0; - for (i = 0; i < 6; i++) { - if (basep[i]) { - if (PCI_MAP_IS_IO(basep[i])) { - if (pcrp->pci_command & PCI_CMD_IO_ENABLE) - res = activeRes; - else - res = inactiveRes; - P_I_RANGE(range, pcrp->tag, PCIGETIO(basep[i]), - pcrp->basesize[i], ResExcIoBlock | resMisc) - } else if (!PCI_MAP_IS64BITMEM(basep[i])) { - if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) - res = activeRes; - else - res = inactiveRes; - P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i]), - pcrp->basesize[i], ResExcMemBlock | resMisc) - } else { - i++; -#if defined(LONG64) || defined(WORD64) - P_M_RANGE(range,pcrp->tag,PCIGETMEMORY64(basep[i - 1]), - pcrp->basesize[i - 1], ResExcMemBlock | resMisc) -#else - if (basep[i]) - continue; - P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i - 1]), - pcrp->basesize[i - 1], ResExcMemBlock | resMisc) -#endif - if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) - res = activeRes; - else - res = inactiveRes; - } - if (range.rBegin) { /* catch cases where PCI base is unset */ - tmp = xf86AddResToList(NULL, &range, -1); - removeOverlapsWithBridges(pcrp->busnum,tmp); - *res = xf86JoinResLists(tmp,*res); - } - } - } - - /* Ignore disabled non-video ROMs */ - if ((pcrp->pci_command & PCI_CMD_MEM_ENABLE) && - (pcrp->pci_baserom & PCI_MAP_ROM_DECODE_ENABLE)) { - P_M_RANGE(range,pcrp->tag,PCIGETROM(pcrp->pci_baserom), - pcrp->basesize[6], ResExcMemBlock | resMisc); - if (range.rBegin) { - tmp = xf86AddResToList(NULL, &range, -1); - removeOverlapsWithBridges(pcrp->busnum, tmp); - *activeRes = xf86JoinResLists(tmp, *activeRes); - } - } - } - - if (*activeRes) { - xf86MsgVerb(X_INFO, 3, "Active PCI resource ranges:\n"); - xf86PrintResList(3, *activeRes); - } - if (*inactiveRes) { - xf86MsgVerb(X_INFO, 3, "Inactive PCI resource ranges:\n"); - xf86PrintResList(3, *inactiveRes); - } - - /* - * Adjust ranges based on the assumption that there are no real - * overlaps in the PCI base allocations. This assumption should be - * reasonable in most cases. It may be possible to refine the - * approximated PCI base sizes by considering bus mapping information - * from PCI-PCI bridges. - */ - - if (*activeRes) { - /* Check for overlaps */ - for (pRes = *activeRes; pRes; pRes = pRes->next) { - if (ResCanOverlap(&pRes->val)) { - range = pRes->val; - - RemoveOverlaps(pRes, *activeRes, TRUE, TRUE); - RemoveOverlaps(pRes, *inactiveRes, TRUE, - (xf86Info.estimateSizesAggressively > 0)); - - if (range.rEnd > pRes->block_end) { - correctPciSize(range.rBegin, range.rEnd - range.rBegin, - pRes->block_end - pRes->block_begin, - pRes->res_type); - xf86MsgVerb(X_INFO, 3, - "PCI %s resource overlap reduced 0x%08lx" - " from 0x%08lx to 0x%08lx\n", - ((pRes->res_type & ResPhysMask) == ResMem) ? - "Memory" : "I/O", - range.rBegin, range.rEnd, pRes->block_end); - } - } - } - xf86MsgVerb(X_INFO, 3, - "Active PCI resource ranges after removing overlaps:\n"); - xf86PrintResList(3, *activeRes); - } - - if (*inactiveRes) { - /* Check for overlaps */ - for (pRes = *inactiveRes; pRes; pRes = pRes->next) { - if (ResCanOverlap(&pRes->val)) { - range = pRes->val; - - RemoveOverlaps(pRes, *activeRes, TRUE, - (xf86Info.estimateSizesAggressively > 1)); - RemoveOverlaps(pRes, *inactiveRes, TRUE, - (xf86Info.estimateSizesAggressively > 1)); - - if (range.rEnd > pRes->block_end) { - correctPciSize(range.rBegin, range.rEnd - range.rBegin, - pRes->block_end - pRes->block_begin, - pRes->res_type); - xf86MsgVerb(X_INFO, 3, - "PCI %s resource overlap reduced 0x%08lx" - " from 0x%08lx to 0x%08lx\n", - ((pRes->res_type & ResPhysMask) == ResMem) ? - "Memory" : "I/O", - range.rBegin, range.rEnd, pRes->block_end); - } - - } - } - xf86MsgVerb(X_INFO, 3, - "Inactive PCI resource ranges after removing overlaps:\n"); - xf86PrintResList(3, *inactiveRes); - } -} - -resPtr -ResourceBrokerInitPci(resPtr *osRes) -{ - resPtr activeRes, inactiveRes; - resPtr tmp; - - /* Get bus-specific system resources (PCI) */ - xf86GetPciRes(&activeRes, &inactiveRes); - - /* - * Adjust OS-reported resource ranges based on the assumption that there - * are no overlaps with the PCI base allocations. This should be a good - * assumption because writes to PCI address space won't be routed directly - * to host memory. - */ - - for (tmp = *osRes; tmp; tmp = tmp->next) - RemoveOverlaps(tmp, activeRes, FALSE, TRUE); - - xf86MsgVerb(X_INFO, 3, "OS-reported resource ranges after removing" - " overlaps with PCI:\n"); - xf86PrintResList(3, *osRes); - - pciAvoidRes = xf86AddRangesToList(pciAvoidRes,PciAvoid,-1); - for (tmp = pciAvoidRes; tmp; tmp = tmp->next) - RemoveOverlaps(tmp, activeRes, FALSE, TRUE); - tmp = xf86DupResList(*osRes); - pciAvoidRes = xf86JoinResLists(pciAvoidRes,tmp); - - return (xf86JoinResLists(activeRes,inactiveRes)); -} - - -/* - * PCI Resource modification - */ -static Bool -fixPciResource(int prt, memType alignment, pciVideoPtr pvp, unsigned long type) -{ - int res_n; - memType *p_base; - int *p_size; - unsigned char p_type; - resPtr AccTmp = NULL; - resPtr orgAcc = NULL; - resPtr *pAcc = &AccTmp; - resPtr avoid = NULL; - resRange range; - resPtr resSize = NULL; - resPtr w_tmp, w = NULL, w_2nd = NULL; - PCITAG tag; - PciBusPtr pbp = xf86PciBus; - pciConfigPtr pcp; - resPtr tmp; - - if (!pvp) return FALSE; - tag = pciTag(pvp->bus,pvp->device,pvp->func); - pcp = pvp->thisCard; - - type &= ResAccMask; - if (!type) type = ResShared; - if (prt < 6) { - if (pvp->memBase[prt]) { - type |= ResMem; - res_n = prt; - p_base = &(pvp->memBase[res_n]); - p_size = &(pvp->size[res_n]); - p_type = pvp->type[res_n]; - if (!PCI_MAP_IS64BITMEM(pvp->type[res_n])) { - PCI_M_RANGE(range,tag,0,0xffffffff,ResExcMemBlock); - resSize = xf86AddResToList(resSize,&range,-1); - } - } else if (pvp->ioBase[prt]){ - type |= ResIo; - res_n = prt; - p_base = &(pvp->ioBase[res_n]); - p_size = &(pvp->size[res_n]); - p_type = pvp->type[res_n]; - PCI_I_RANGE(range, tag, 0, 0xffffffff, ResExcIoBlock); - resSize = xf86AddResToList(resSize, &range, -1); - } else return FALSE; - } else if (prt == 6) { - type |= ResMem; - res_n = 0xff; /* special flag for bios rom */ - p_base = &(pvp->biosBase); - p_size = &(pvp->biosSize); - /* XXX This should also include the PCI_MAP_MEMORY_TYPE_MASK part */ - p_type = 0; - PCI_M_RANGE(range,tag,0,0xffffffff,ResExcMemBlock); - resSize = xf86AddResToList(resSize,&range,-1); - } else return FALSE; - - if (! *p_base) return FALSE; - - type |= (range.type & ResDomain) | ResBlock; - - /* setup avoid: PciAvoid is bus range: convert later */ - avoid = xf86DupResList(pciAvoidRes); - - while (pbp) { - if (pbp->secondary == pvp->bus) { - if ((type & ResPhysMask) == ResMem) { - if (((p_type & PCI_MAP_MEMORY_CACHABLE) -#if 0 /*EE*/ - || (res_n == 0xff)/* bios should also be prefetchable */ -#endif - )) { - if (pbp->preferred_pmem) - w = xf86FindIntersectOfLists(pbp->preferred_pmem, - ResRange); - else if (pbp->pmem) - w = xf86FindIntersectOfLists(pbp->pmem,ResRange); - - if (pbp->preferred_mem) - w_2nd = xf86FindIntersectOfLists(pbp->preferred_mem, - ResRange); - else if (pbp->mem) - w_2nd = xf86FindIntersectOfLists(pbp->mem, - ResRange); - } else { - if (pbp->preferred_mem) - w = xf86FindIntersectOfLists(pbp->preferred_mem, - ResRange); - else if (pbp->mem) - w = xf86FindIntersectOfLists(pbp->mem,ResRange); - } - } else { - if (pbp->preferred_io) - w = xf86FindIntersectOfLists(pbp->preferred_io,ResRange); - if (pbp->io) - w = xf86FindIntersectOfLists(pbp->io,ResRange); - } - } else if (pbp->primary == pvp->bus) { - if ((type & ResPhysMask) == ResMem) { - tmp = xf86DupResList(pbp->preferred_pmem); - avoid = xf86JoinResLists(avoid, tmp); - tmp = xf86DupResList(pbp->preferred_mem); - avoid = xf86JoinResLists(avoid, tmp); - } else { - tmp = xf86DupResList(pbp->preferred_io); - avoid = xf86JoinResLists(avoid, tmp); - } - } - pbp = pbp->next; - } - - /* convert bus based entries in avoid list to host base */ - pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid); - - if (!w) - w = xf86DupResList(ResRange); - xf86MsgVerb(X_INFO, 3, "window:\n"); - xf86PrintResList(3, w); - xf86MsgVerb(X_INFO, 3, "resSize:\n"); - xf86PrintResList(3, resSize); - - if (resSize) { - w_tmp = w; - w = xf86FindIntersectOfLists(w,resSize); - xf86FreeResList(w_tmp); - if (w_2nd) { - w_tmp = w_2nd; - w_2nd = xf86FindIntersectOfLists(w_2nd,resSize); - xf86FreeResList(w_tmp); - } - xf86FreeResList(resSize); - } - xf86MsgVerb(X_INFO, 3, "window fixed:\n"); - xf86PrintResList(3, w); - - if (!alignment) - alignment = (1 << (*p_size)) - 1; - - /* Access list holds bios resources -- remove this one */ -#ifdef NOTYET - AccTmp = xf86DupResList(Acc); - while ((*pAcc)) { - if ((((*pAcc)->res_type & (type & ~ResAccMask)) - == (type & ~ResAccMask)) - && ((*pAcc)->block_begin == (B2H(tag,(*p_base),type))) - && ((*pAcc)->block_end == (B2H(tag, - (*p_base)+SIZE(*p_size),type)))) { - resPtr acc_tmp = (*pAcc)->next; - xfree((*pAcc)); - (*pAcc) = acc_tmp; - break; - } else - pAcc = &((*pAcc)->next); - } - /* check if we really need to fix anything */ - P_X_RANGE(range,tag,(*p_base),(*p_base) + SIZE((*p_size)),type); - if (!ChkConflict(&range,avoid,SETUP) - && !ChkConflict(&range,AccTmp,SETUP) - && ((B2H(tag,(*p_base),type) & PCI_SIZE(type,tag,alignment) - == range->block_begin) - && ((xf86IsSubsetOf(range,w) - || (w_2nd && xf86IsSubsetOf(range,w_2n))))) { -#ifdef DEBUG - ErrorF("nothing to fix\n"); -#endif - xf86FreeResList(AccTmp); - xf86FreeResList(w); - xf86FreeResList(w_2nd); - xf86FreeResList(avoid); - return TRUE; - } -#ifdef DEBUG - ErrorF("removing old resource\n"); -#endif - orgAcc = Acc; - Acc = AccTmp; -#else - orgAcc = xf86DupResList(Acc); - pAcc = &Acc; - while (*pAcc) { - if ((((*pAcc)->res_type & (ResTypeMask|ResExtMask)) == - (type & ~ResAccMask)) - && ((*pAcc)->block_begin == B2H(tag,(*p_base),type)) - && ((*pAcc)->block_end == B2H(tag,(*p_base) + SIZE(*p_size), - type))) { -#ifdef DEBUG - ErrorF("removing old resource\n"); -#endif - tmp = *pAcc; - *pAcc = (*pAcc)->next; - tmp->next = NULL; - xf86FreeResList(tmp); - break; - } else - pAcc = &((*pAcc)->next); - } -#endif - -#ifdef DEBUG - ErrorF("base: 0x%lx alignment: 0x%lx host alignment: 0x%lx size[bit]: 0x%x\n", - (*p_base),alignment,PCI_SIZE(type,tag,alignment),(*p_size)); - xf86MsgVerb(X_INFO, 3, "window:\n"); - xf86PrintResList(3, w); - if (w_2nd) - xf86MsgVerb(X_INFO, 3, "2nd window:\n"); - xf86PrintResList(3, w_2nd); - xf86ErrorFVerb(3,"avoid:\n"); - xf86PrintResList(3,avoid); -#endif - w_tmp = w; - while (w) { - if ((type & ResTypeMask) == (w->res_type & ResTypeMask)) { -#ifdef DEBUG - ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w->block_begin, - w->block_end); -#endif - range = xf86GetBlock(type,PCI_SIZE(type,tag,alignment + 1), - w->block_begin, w->block_end, - PCI_SIZE(type,tag,alignment),avoid); - if (range.type != ResEnd) - break; - } - w = w->next; - } - xf86FreeResList(w_tmp); - /* if unsuccessful and memory prefetchable try non-prefetchable */ - if (range.type == ResEnd && w_2nd) { - w_tmp = w_2nd; - while (w_2nd) { - if ((type & ResTypeMask) == (w_2nd->res_type & ResTypeMask)) { -#ifdef DEBUG - ErrorF("block_begin: 0x%lx block_end: 0x%lx\n",w_2nd->block_begin, - w_2nd->block_end); -#endif - range = xf86GetBlock(type,PCI_SIZE(type,tag,alignment + 1), - w_2nd->block_begin, w_2nd->block_end, - PCI_SIZE(type,tag,alignment),avoid); - if (range.type != ResEnd) - break; - } - w_2nd = w_2nd->next; - } - xf86FreeResList(w_tmp); - } - xf86FreeResList(avoid); - - if (range.type == ResEnd) { - xf86MsgVerb(X_ERROR,3,"Cannot find a replacement memory range\n"); - xf86FreeResList(Acc); - Acc = orgAcc; - return FALSE; - } - xf86FreeResList(orgAcc); -#ifdef DEBUG - ErrorF("begin: 0x%lx, end: 0x%lx\n",range.a,range.b); -#endif - - (*p_size) = 0; - while (alignment >> (*p_size)) - (*p_size)++; - (*p_base) = H2B(tag,range.rBegin,type); -#ifdef DEBUG - ErrorF("New PCI res %i base: 0x%lx, size: 0x%lx, type %s\n", - res_n,(*p_base),(1 << (*p_size)), - ((type & ResPhysMask) == ResMem) ? "Mem" : "Io"); -#endif - if (res_n != 0xff) { - if ((type & ResPhysMask) == ResMem) - pvp->memBase[prt] = range.rBegin; - else - pvp->ioBase[prt] = range.rBegin; - ((CARD32 *)(&(pcp->pci_base0)))[res_n] = - (CARD32)(*p_base) | (CARD32)(p_type); - pciWriteLong(tag, PCI_CMD_BASE_REG + res_n * sizeof(CARD32), - ((CARD32 *)(&(pcp->pci_base0)))[res_n]); - if (PCI_MAP_IS64BITMEM(p_type)) { -#if defined(LONG64) || defined(WORD64) - ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] = - (CARD32)(*p_base >> 32); - pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32), - ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1]); -#else - ((CARD32 *)(&(pcp->pci_base0)))[res_n + 1] = 0; - pciWriteLong(tag, PCI_CMD_BASE_REG + (res_n + 1) * sizeof(CARD32), - 0); -#endif - } - } else { - pvp->biosBase = range.rBegin; - pcp->pci_baserom = (pciReadLong(tag,PCI_CMD_BIOS_REG) & 0x01) | - (CARD32)(*p_base); - pciWriteLong(tag, PCI_CMD_BIOS_REG, pcp->pci_baserom); - } - /* @@@ fake BIOS allocated resource */ - range.type |= ResBios; - Acc = xf86AddResToList(Acc, &range,-1); - - return TRUE; - -} - -_X_EXPORT Bool -xf86FixPciResource(int entityIndex, int prt, memType alignment, - unsigned long type) -{ - pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex); - return fixPciResource(prt, alignment, pvp, type); -} - -_X_EXPORT resPtr -xf86ReallocatePciResources(int entityIndex, resPtr pRes) +disablePciBios( struct pci_device * dev ) { - pciVideoPtr pvp = xf86GetPciInfoForEntity(entityIndex); - resPtr pBad = NULL,pResTmp; - unsigned int prt = 0; - int i; - - if (!pvp) return pRes; - - while (pRes) { - switch (pRes->res_type & ResPhysMask) { - case ResMem: - if (pRes->block_begin == B2M(TAG(pvp),pvp->biosBase) && - pRes->block_end == B2M(TAG(pvp),pvp->biosBase - + SIZE(pvp->biosSize))) - prt = 6; - else for (i = 0 ; i < 6; i++) - if ((pRes->block_begin == B2M(TAG(pvp),pvp->memBase[i])) - && (pRes->block_end == B2M(TAG(pvp),pvp->memBase[i] - + SIZE(pvp->size[i])))) { - prt = i; - break; - } - break; - case ResIo: - for (i = 0 ; i < 6; i++) - if (pRes->block_begin == B2I(TAG(pvp),pvp->ioBase[i]) - && pRes->block_end == B2I(TAG(pvp),pvp->ioBase[i] - + SIZE(pvp->size[i]))) { - prt = i; - break; - } - break; - } - - if (!prt) return pRes; - - pResTmp = pRes->next; - if (! fixPciResource(prt, 0, pvp, pRes->res_type)) { - pRes->next = pBad; - pBad = pRes; - } else - xfree(pRes); - - pRes = pResTmp; - } - return pBad; + pci_device_cfg_write_bits( dev, PCI_CMD_BIOS_ENABLE, 0, + PCI_CMD_BIOS_REG ); } -/* - * BIOS releated - */ -memType -getValidBIOSBase(PCITAG tag, int num) -{ - pciVideoPtr pvp = NULL; - PciBusPtr pbp; - resPtr m = NULL; - resPtr tmp, avoid, mem = NULL; - resRange range; - memType ret; - int n = 0; - int i; - CARD32 biosSize, alignment; - - if (!xf86PciVideoInfo) return 0; - - while ((pvp = xf86PciVideoInfo[n++])) { - if (pciTag(pvp->bus,pvp->device,pvp->func) == tag) - break; - } - if (!pvp) return 0; - - biosSize = pvp->biosSize; - alignment = (1 << biosSize) - 1; - if (biosSize > 24) - biosSize = 24; - - switch ((romBaseSource)num) { - case ROM_BASE_PRESET: - return 0; /* This should not happen */ - case ROM_BASE_BIOS: - /* In some cases the BIOS base register contains the size mask */ - if ((memType)(-1 << biosSize) == PCIGETROM(pvp->biosBase)) - return 0; - /* Make sure we don't conflict with our own mem resources */ - for (i = 0; i < 6; i++) { - if (!pvp->memBase[i]) - continue; - P_M_RANGE(range,TAG(pvp),pvp->memBase[i],pvp->size[i], - ResExcMemBlock); - mem = xf86AddResToList(mem,&range,-1); - } - P_M_RANGE(range, TAG(pvp),pvp->biosBase,biosSize,ResExcMemBlock); - ret = pvp->biosBase; - break; - case ROM_BASE_MEM0: - case ROM_BASE_MEM1: - case ROM_BASE_MEM2: - case ROM_BASE_MEM3: - case ROM_BASE_MEM4: - case ROM_BASE_MEM5: - if (!pvp->memBase[num] || (pvp->size[num] < biosSize)) - return 0; - P_M_RANGE(range, TAG(pvp),pvp->memBase[num],biosSize, - ResExcMemBlock); - ret = pvp->memBase[num]; - break; - case ROM_BASE_FIND: - ret = 0; - break; - default: - return 0; /* This should not happen */ - } - - /* Now find the ranges for validation */ - avoid = xf86DupResList(pciAvoidRes); - pbp = xf86PciBus; - while (pbp) { - if (pbp->secondary == pvp->bus) { - if (pbp->preferred_pmem) - tmp = xf86DupResList(pbp->preferred_pmem); - else - tmp = xf86DupResList(pbp->pmem); - m = xf86JoinResLists(m,tmp); - if (pbp->preferred_mem) - tmp = xf86DupResList(pbp->preferred_mem); - else - tmp = xf86DupResList(pbp->mem); - m = xf86JoinResLists(m,tmp); - tmp = m; - while (tmp) { - tmp->block_end = min(tmp->block_end,PCI_MEM32_LENGTH_MAX); - tmp = tmp->next; - } - } else if ((pbp->primary == pvp->bus) && - (pbp->secondary >= 0) && - (pbp->primary != pbp->secondary)) { - tmp = xf86DupResList(pbp->preferred_pmem); - avoid = xf86JoinResLists(avoid, tmp); - tmp = xf86DupResList(pbp->pmem); - avoid = xf86JoinResLists(avoid, tmp); - tmp = xf86DupResList(pbp->preferred_mem); - avoid = xf86JoinResLists(avoid, tmp); - tmp = xf86DupResList(pbp->mem); - avoid = xf86JoinResLists(avoid, tmp); - } - pbp = pbp->next; - } - pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid); - if (mem) - pciConvertListToHost(pvp->bus,pvp->device,pvp->func, mem); - - if (!ret) { - /* Return a possible window */ - while (m) { - range = xf86GetBlock(RANGE_TYPE(ResExcMemBlock, xf86GetPciDomain(tag)), - PCI_SIZE(ResMem, TAG(pvp), 1 << biosSize), - m->block_begin, m->block_end, - PCI_SIZE(ResMem, TAG(pvp), alignment), - avoid); - if (range.type != ResEnd) { - ret = M2B(TAG(pvp), range.rBase); - break; - } - m = m->next; - } - } else { -#if !defined(__ia64__) /* on ia64, trust the kernel, don't look for overlaps */ - if (!xf86IsSubsetOf(range, m) || - ChkConflict(&range, avoid, SETUP) - || (mem && ChkConflict(&range, mem, SETUP))) - ret = 0; -#endif - } - - xf86FreeResList(avoid); - xf86FreeResList(m); - return ret; -} /* * xf86Bus.c interface @@ -1634,26 +585,6 @@ void xf86PciProbe(void) { - /* - * Initialise the pcidata entry points. - */ -#ifdef XFree86LOADER - xf86SetupPciIds = (ScanPciSetupProcPtr)LoaderSymbol("ScanPciSetupPciIds"); - xf86ClosePciIds = (ScanPciCloseProcPtr)LoaderSymbol("ScanPciClosePciIds"); - xf86FindPciNamesByDevice = - (ScanPciFindByDeviceProcPtr)LoaderSymbol("ScanPciFindPciNamesByDevice"); - xf86FindPciNamesBySubsys = - (ScanPciFindBySubsysProcPtr)LoaderSymbol("ScanPciFindPciNamesBySubsys"); -#else - xf86SetupPciIds = ScanPciSetupPciIds; - xf86ClosePciIds = ScanPciClosePciIds; - xf86FindPciNamesByDevice = ScanPciFindPciNamesByDevice; - xf86FindPciNamesBySubsys = ScanPciFindPciNamesBySubsys; -#endif - - if (!xf86SetupPciIds()) - FatalError("xf86SetupPciIds() failed\n"); - FindPCIVideoInfo(); } @@ -1713,8 +644,14 @@ /* Add each bridge */ for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *(++pcrpp)) { + struct pci_device * const dev = + pci_device_find_by_slot( PCI_DOM_FROM_BUS( pcrp->busnum ), + PCI_BUS_NO_DOMAIN( pcrp->busnum ), + pcrp->devnum, pcrp->funcnum ); + if (pcrp->busnum > MaxBus) MaxBus = pcrp->busnum; + if ( pcrp->pci_base_class == PCI_CLASS_BRIDGE ) { const int sub_class = pcrp->pci_sub_class; @@ -1765,6 +702,7 @@ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec)); pnPciBus = &PciBus->next; + PciBus->dev = dev; PciBus->primary = primary; PciBus->secondary = secondary; PciBus->subordinate = subordinate; @@ -1778,7 +716,7 @@ /* The Intel bridges don't report as transparent but guess what they are - from Linux kernel - airlied */ if ((pcrp->pci_vendor == PCI_VENDOR_INTEL) && - ((pcrp->pci_device & 0xff00) == 0x2400)) { + ((pcrp->_pci_device & 0xff00) == 0x2400)) { xf86MsgVerb(X_INFO, 3, "Intel Bridge workaround enabled\n"); PciBus->interface = PCI_IF_BRIDGE_PCI_SUBTRACTIVE; } else { @@ -1914,6 +852,7 @@ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec)); pnPciBus = &PciBus->next; + PciBus->dev = dev; PciBus->primary = primary; PciBus->secondary = secondary; PciBus->subordinate = subordinate; @@ -2043,6 +982,7 @@ case PCI_SUBCLASS_BRIDGE_MC: *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec)); pnPciBus = &PciBus->next; + PciBus->dev = dev; PciBus->primary = pcrp->busnum; PciBus->secondary = PciBus->subordinate = -1; PciBus->brbus = pcrp->busnum; @@ -2077,7 +1017,7 @@ *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec)); pnPciBus = &PciBus->next; - + PciBus->dev = dev; PciBus->primary = PciBus->secondary = secondary; PciBus->subordinate = pciNumBuses - 1; @@ -2135,16 +1075,20 @@ * Find the 'smallest' free HOST-PCI bridge, where 'small' is in * the order of pciTag(). */ - PCITAG minTag = 0xFFFFFFFF, tag; + PCITAG minTag = 0xFFFFFFFF; PciBusPtr PciBusFound = NULL; - for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) + + for (PciBus = PciBusBase; PciBus; PciBus = PciBus->next) { + const PCITAG tag = pciTag( PciBus->brbus, PciBus->brdev, + PciBus->brfunc ); if ((PciBus->subclass == PCI_SUBCLASS_BRIDGE_HOST) && (PciBus->secondary == -1) && - ((tag = pciTag(PciBus->brbus,PciBus->brdev,PciBus->brfunc)) - < minTag) ) { + (tag < minTag) ) { minTag = tag; PciBusFound = PciBus; } + } + if (PciBusFound) PciBusFound->secondary = i; else { /* if nothing found it may not be visible: create new */ @@ -2158,6 +1102,11 @@ } *pnPciBus = PciBus = xnfcalloc(1, sizeof(PciBusRec)); pnPciBus = &PciBus->next; + + PciBus->dev = pci_device_find_by_slot( PCI_DOM_FROM_BUS( pcrp->busnum ), + PCI_BUS_NO_DOMAIN( pcrp->busnum ), + pcrp->devnum, + pcrp->funcnum ); PciBus->primary = PciBus->secondary = i; PciBus->subclass = PCI_SUBCLASS_BRIDGE_HOST; PciBus->brcontrol = PCI_PCI_BRIDGE_VGA_EN; @@ -2261,352 +1210,41 @@ } void -ValidatePci(void) -{ - pciVideoPtr pvp, pvp1; - PciBusPtr pbp; - pciConfigPtr pcrp, *pcrpp; - CARD32 *basep; - resPtr Sys; - resRange range; - int n = 0, m, i; - - if (!xf86PciVideoInfo) return; - - /* - * Mark all pciInfoRecs that need to be validated. These are - * the ones which have been assigned to a screen. - */ - Sys = xf86DupResList(osRes); - /* Only validate graphics devices in use */ - for (i=0; inumEntities; m++) - if ((pvp = xf86GetPciInfoForEntity(xf86Screens[i]->entityList[m]))) - pvp->validate = TRUE; - } - - /* - * Collect all background PCI resources we need to validate against. - * These are all resources which don't belong to PCINONSYSTEMCLASSES - * and which have not been assigned to an entity. - */ - /* First get the PCIINFOCLASSES */ - m = 0; - while ((pvp = xf86PciVideoInfo[m++])) { - /* is it a PCINONSYSTEMCLASS? */ - if (PCINONSYSTEMCLASSES(pvp->class, pvp->subclass)) - continue; - /* has it an Entity assigned to it? */ - for (i=0; ibusType != BUS_PCI) - continue; - if (p->pciBusId.bus == pvp->bus - && p->pciBusId.device == pvp->device - && p->pciBusId.func == pvp->func) - break; - } - if (i != xf86NumEntities) /* found an Entity for this one */ - continue; - - for (i = 0; i<6; i++) { - if (pvp->ioBase[i]) { - PV_I_RANGE(range,pvp,i,ResExcIoBlock); - Sys = xf86AddResToList(Sys,&range,-1); - } else if (pvp->memBase[i]) { - PV_M_RANGE(range,pvp,i,ResExcMemBlock); - Sys = xf86AddResToList(Sys,&range,-1); - } - } - } - for (pcrpp = xf86PciInfo, pcrp = *pcrpp; pcrp; pcrp = *++(pcrpp)) { - - /* These were handled above */ - if (PCIINFOCLASSES(pcrp->pci_base_class, pcrp->pci_sub_class)) - continue; - - if ((pcrp->pci_header_type & 0x7f) || - !(pcrp->pci_command & (PCI_CMD_IO_ENABLE | PCI_CMD_MEM_ENABLE))) - continue; - - basep = &pcrp->pci_base0; - for (i = 0; i < 6; i++) { - if (basep[i]) { - if (PCI_MAP_IS_IO(basep[i])) { - if (!(pcrp->pci_command & PCI_CMD_IO_ENABLE)) - continue; - P_I_RANGE(range, pcrp->tag, PCIGETIO(basep[i]), - pcrp->basesize[i], ResExcIoBlock) - } else if (!PCI_MAP_IS64BITMEM(basep[i])) { - if (!(pcrp->pci_command & PCI_CMD_MEM_ENABLE)) - continue; - P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i]), - pcrp->basesize[i], ResExcMemBlock) - } else { - i++; - if (!(pcrp->pci_command & PCI_CMD_MEM_ENABLE)) - continue; -#if defined(LONG64) || defined(WORD64) - P_M_RANGE(range, pcrp->tag, PCIGETMEMORY64(basep[i-1]), - pcrp->basesize[i-1], ResExcMemBlock) -#else - if (basep[i]) - continue; - P_M_RANGE(range, pcrp->tag, PCIGETMEMORY(basep[i-1]), - pcrp->basesize[i-1], ResExcMemBlock) -#endif - } - Sys = xf86AddResToList(Sys, &range, -1); - } - } - if ((pcrp->pci_baserom) && - (pcrp->pci_command & PCI_CMD_MEM_ENABLE) && - (pcrp->pci_baserom & PCI_MAP_ROM_DECODE_ENABLE)) { - P_M_RANGE(range,pcrp->tag,PCIGETROM(pcrp->pci_baserom), - pcrp->basesize[6],ResExcMemBlock); - Sys = xf86AddResToList(Sys, &range, -1); - } - } -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3,"Sys:\n"); - xf86PrintResList(3,Sys); -#endif - - /* - * The order the video devices are listed in is - * just right: the lower buses come first. - * This way we attempt to fix a conflict of - * a lower bus device with a higher bus device - * where we have more room to find different - * resources. - */ - while ((pvp = xf86PciVideoInfo[n++])) { - resPtr res_mp = NULL, res_m_io = NULL; - resPtr NonSys; - resPtr tmp, avoid = NULL; - - if (!pvp->validate) continue; - NonSys = xf86DupResList(Sys); - m = n; - while ((pvp1 = xf86PciVideoInfo[m++])) { - if (!pvp1->validate) continue; - for (i = 0; i<6; i++) { - if (pvp1->ioBase[i]) { - PV_I_RANGE(range,pvp1,i,ResExcIoBlock); - NonSys = xf86AddResToList(NonSys,&range,-1); - } else if (pvp1->memBase[i]) { - PV_M_RANGE(range,pvp1,i,ResExcMemBlock); - NonSys = xf86AddResToList(NonSys,&range,-1); - } - } - } -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3,"NonSys:\n"); - xf86PrintResList(3,NonSys); -#endif - pbp = xf86PciBus; - while (pbp) { - if (pbp->secondary == pvp->bus) { - if (pbp->preferred_pmem) { - /* keep prefetchable separate */ - res_mp = - xf86FindIntersectOfLists(pbp->preferred_pmem, ResRange); - } - if (pbp->pmem) { - res_mp = xf86FindIntersectOfLists(pbp->pmem, ResRange); - } - if (pbp->preferred_mem) { - res_m_io = - xf86FindIntersectOfLists(pbp->preferred_mem, ResRange); - } - if (pbp->mem) { - res_m_io = xf86FindIntersectOfLists(pbp->mem, ResRange); - } - if (pbp->preferred_io) { - res_m_io = xf86JoinResLists(res_m_io, - xf86FindIntersectOfLists(pbp->preferred_io, ResRange)); - } - if (pbp->io) { - res_m_io = xf86JoinResLists(res_m_io, - xf86FindIntersectOfLists(pbp->preferred_io, ResRange)); - } - } else if ((pbp->primary == pvp->bus) && - (pbp->secondary >= 0) && - (pbp->primary != pbp->secondary)) { - tmp = xf86DupResList(pbp->preferred_pmem); - avoid = xf86JoinResLists(avoid, tmp); - tmp = xf86DupResList(pbp->preferred_mem); - avoid = xf86JoinResLists(avoid, tmp); - tmp = xf86DupResList(pbp->preferred_io); - avoid = xf86JoinResLists(avoid, tmp); - } - pbp = pbp->next; - } - if (res_m_io == NULL) - res_m_io = xf86DupResList(ResRange); - - pciConvertListToHost(pvp->bus,pvp->device,pvp->func, avoid); - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3,"avoid:\n"); - xf86PrintResList(3,avoid); - xf86MsgVerb(X_INFO, 3,"prefetchable Memory:\n"); - xf86PrintResList(3,res_mp); - xf86MsgVerb(X_INFO, 3,"MEM/IO:\n"); - xf86PrintResList(3,res_m_io); -#endif - for (i = 0; i < 6; i++) { - int j; - resPtr own = NULL; - for (j = i+1; j < 6; j++) { - if (pvp->ioBase[j]) { - PV_I_RANGE(range,pvp,j,ResExcIoBlock); - own = xf86AddResToList(own,&range,-1); - } else if (pvp->memBase[j]) { - PV_M_RANGE(range,pvp,j,ResExcMemBlock); - own = xf86AddResToList(own,&range,-1); - } - } -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "own:\n"); - xf86PrintResList(3, own); -#endif - if (pvp->ioBase[i]) { - PV_I_RANGE(range,pvp,i,ResExcIoBlock); - if (xf86IsSubsetOf(range,res_m_io) - && ! ChkConflict(&range,own,SETUP) - && ! ChkConflict(&range,avoid,SETUP) - && ! ChkConflict(&range,NonSys,SETUP)) { - xf86FreeResList(own); - continue; - } - xf86MsgVerb(X_WARNING, 0, - "****INVALID IO ALLOCATION**** b: 0x%lx e: 0x%lx " - "correcting\a\n", range.rBegin,range.rEnd); -#ifdef DEBUG - sleep(2); -#endif - fixPciResource(i, 0, pvp, range.type); - } else if (pvp->memBase[i]) { - PV_M_RANGE(range,pvp,i,ResExcMemBlock); - if (pvp->type[i] & PCI_MAP_MEMORY_CACHABLE) { - if (xf86IsSubsetOf(range,res_mp) - && ! ChkConflict(&range,own,SETUP) - && ! ChkConflict(&range,avoid,SETUP) - && ! ChkConflict(&range,NonSys,SETUP)) { - xf86FreeResList(own); - continue; - } - } - if (xf86IsSubsetOf(range,res_m_io) - && ! ChkConflict(&range,own,SETUP) - && ! ChkConflict(&range,avoid,SETUP) - && ! ChkConflict(&range,NonSys,SETUP)) { - xf86FreeResList(own); - continue; - } - xf86MsgVerb(X_WARNING, 0, - "****INVALID MEM ALLOCATION**** b: 0x%lx e: 0x%lx " - "correcting\a\n", range.rBegin,range.rEnd); - if (ChkConflict(&range,own,SETUP)) { - xf86MsgVerb(X_INFO,3,"own\n"); - xf86PrintResList(3,own); - } - if (ChkConflict(&range,avoid,SETUP)) { - xf86MsgVerb(X_INFO,3,"avoid\n"); - xf86PrintResList(3,avoid); - } - if (ChkConflict(&range,NonSys,SETUP)) { - xf86MsgVerb(X_INFO,3,"NonSys\n"); - xf86PrintResList(3,NonSys); - } - -#ifdef DEBUG - sleep(2); -#endif - fixPciResource(i, 0, pvp, range.type); - } - xf86FreeResList(own); - } - xf86FreeResList(avoid); - xf86FreeResList(NonSys); - xf86FreeResList(res_mp); - xf86FreeResList(res_m_io); - } - xf86FreeResList(Sys); -} - -resList -GetImplicitPciResources(int entityIndex) -{ - pciVideoPtr pvp; - int i; - resList list = NULL; - int num = 0; - - if (! (pvp = xf86GetPciInfoForEntity(entityIndex))) return NULL; - - for (i = 0; i < 6; i++) { - if (pvp->ioBase[i]) { - list = xnfrealloc(list,sizeof(resRange) * (++num)); - PV_I_RANGE(list[num - 1],pvp,i,ResShrIoBlock | ResBios); - } else if (pvp->memBase[i]) { - list = xnfrealloc(list,sizeof(resRange) * (++num)); - PV_M_RANGE(list[num - 1],pvp,i,ResShrMemBlock | ResBios); - } - } -#if 0 - if (pvp->biosBase) { - list = xnfrealloc(list,sizeof(resRange) * (++num)); - PV_B_RANGE(list[num - 1],pvp,ResShrMemBlock | ResBios); - } -#endif - list = xnfrealloc(list,sizeof(resRange) * (++num)); - list[num - 1].type = ResEnd; - - return list; -} - -void initPciState(void) { - int i = 0; - int j = 0; - pciVideoPtr pvp; + unsigned i; pciAccPtr pcaccp; - if (xf86PciAccInfo != NULL) - return; - - if (xf86PciVideoInfo == NULL) + if ( xf86PciVideoInfo == NULL ) { return; + } - while ((pvp = xf86PciVideoInfo[i]) != NULL) { - i++; - j++; - xf86PciAccInfo = xnfrealloc(xf86PciAccInfo, - sizeof(pciAccPtr) * (j + 1)); - xf86PciAccInfo[j] = NULL; - pcaccp = xf86PciAccInfo[j - 1] = xnfalloc(sizeof(pciAccRec)); - pcaccp->busnum = pvp->bus; - pcaccp->devnum = pvp->device; - pcaccp->funcnum = pvp->func; - pcaccp->arg.tag = pciTag(pvp->bus, pvp->device, pvp->func); - pcaccp->ioAccess.AccessDisable = pciIoAccessDisable; - pcaccp->ioAccess.AccessEnable = pciIoAccessEnable; - pcaccp->ioAccess.arg = &pcaccp->arg; + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + struct pci_device * const pvp = xf86PciVideoInfo[i]; + + if ( pvp->user_data == 0 ) { + pcaccp = xnfalloc( sizeof( pciAccRec ) ); + pvp->user_data = (intptr_t) pcaccp; + + pcaccp->busnum = PCI_MAKE_BUS( pvp->domain, pvp->bus ); + pcaccp->devnum = pvp->dev; + pcaccp->funcnum = pvp->func; + pcaccp->arg.dev = pvp; + pcaccp->ioAccess.AccessDisable = pciIoAccessDisable; + pcaccp->ioAccess.AccessEnable = pciIoAccessEnable; + pcaccp->ioAccess.arg = &pcaccp->arg; pcaccp->io_memAccess.AccessDisable = pciIo_MemAccessDisable; pcaccp->io_memAccess.AccessEnable = pciIo_MemAccessEnable; pcaccp->io_memAccess.arg = &pcaccp->arg; pcaccp->memAccess.AccessDisable = pciMemAccessDisable; pcaccp->memAccess.AccessEnable = pciMemAccessEnable; pcaccp->memAccess.arg = &pcaccp->arg; - if (PCISHAREDIOCLASSES(pvp->class, pvp->subclass)) - pcaccp->ctrl = TRUE; - else - pcaccp->ctrl = FALSE; - savePciState(pcaccp->arg.tag, &pcaccp->save); + + pcaccp->ctrl = PCISHAREDIOCLASSES( pvp->device_class ); + + savePciState( pvp, &pcaccp->save); pcaccp->arg.ctrl = pcaccp->save.command; + } } } @@ -2642,7 +1280,7 @@ pbap->busdep.pci.bus = pbp->secondary; pbap->busdep.pci.primary_bus = pbp->primary; pbap->busdep_type = BUS_PCI; - pbap->busdep.pci.acc = PCITAG_SPECIAL; + pbap->busdep.pci.dev = NULL; if ((pbp->secondary >= 0) && (pbp->secondary < pciNumBuses) && (pBusInfo = pciBusInfo[pbp->secondary]) && @@ -2667,7 +1305,10 @@ pbap->set_f = pciSetBusAccess; pbap->enable_f = pciBusAccessEnable; pbap->disable_f = pciBusAccessDisable; - pbap->busdep.pci.acc = pciTag(pbp->brbus,pbp->brdev,pbp->brfunc); + pbap->busdep.pci.dev = pci_device_find_by_slot( PCI_DOM_FROM_BUS( pbp->brbus ), + PCI_BUS_NO_DOMAIN( pbp->brbus ), + pbp->brdev, + pbp->brfunc ); savePciBusState(pbap); break; case PCI_SUBCLASS_BRIDGE_ISA: @@ -2708,19 +1349,19 @@ void PciStateEnter(void) { - pciAccPtr paccp; - int i = 0; - - if (xf86PciAccInfo == NULL) + unsigned i; + + if (xf86PciVideoInfo == NULL) return; - while ((paccp = xf86PciAccInfo[i]) != NULL) { - i++; - if (!paccp->ctrl) - continue; - savePciState(paccp->arg.tag, &paccp->save); - restorePciState(paccp->arg.tag, &paccp->restore); - paccp->arg.ctrl = paccp->restore.command; + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data; + + if ( (paccp != NULL) && paccp->ctrl ) { + savePciState(paccp->arg.dev, &paccp->save); + restorePciState(paccp->arg.dev, &paccp->restore); + paccp->arg.ctrl = paccp->restore.command; + } } } @@ -2739,18 +1380,18 @@ void PciStateLeave(void) { - pciAccPtr paccp; - int i = 0; + unsigned i; - if (xf86PciAccInfo == NULL) + if (xf86PciVideoInfo == NULL) return; - while ((paccp = xf86PciAccInfo[i]) != NULL) { - i++; - if (!paccp->ctrl) - continue; - savePciState(paccp->arg.tag, &paccp->restore); - restorePciState(paccp->arg.tag, &paccp->save); + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data; + + if ( (paccp != NULL) && paccp->ctrl ) { + savePciState(paccp->arg.dev, &paccp->restore); + restorePciState(paccp->arg.dev, &paccp->save); + } } } @@ -2769,16 +1410,17 @@ void DisablePciAccess(void) { - int i = 0; - pciAccPtr paccp; - if (xf86PciAccInfo == NULL) + unsigned i; + + if (xf86PciVideoInfo == NULL) return; - while ((paccp = xf86PciAccInfo[i]) != NULL) { - i++; - if (!paccp->ctrl) /* disable devices that are under control initially*/ - continue; - pciIo_MemAccessDisable(paccp->io_memAccess.arg); + for ( i = 0 ; xf86PciVideoInfo[i] != NULL ; i++ ) { + pciAccPtr paccp = (pciAccPtr) xf86PciVideoInfo[i]->user_data; + + if ( (paccp != NULL) && paccp->ctrl ) { + pciIo_MemAccessDisable(paccp->io_memAccess.arg); + } } } @@ -2797,87 +1439,62 @@ } /* - * Public functions - */ - -_X_EXPORT Bool -xf86IsPciDevPresent(int bus, int dev, int func) -{ - int i = 0; - pciConfigPtr pcp; - - while ((pcp = xf86PciInfo[i]) != NULL) { - if ((pcp->busnum == bus) - && (pcp->devnum == dev) - && (pcp->funcnum == func)) - return TRUE; - i++; - } - return FALSE; -} - -/* * If the slot requested is already in use, return -1. * Otherwise, claim the slot for the screen requesting it. */ _X_EXPORT int -xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp, +xf86ClaimPciSlot( struct pci_device * d, DriverPtr drvp, int chipset, GDevPtr dev, Bool active) { EntityPtr p = NULL; - pciAccPtr *ppaccp = xf86PciAccInfo; + pciAccPtr paccp = (pciAccPtr) d->user_data; BusAccPtr pbap = xf86BusAccInfo; - + const unsigned busnum = PCI_MAKE_BUS( d->domain, d->bus ); int num; - - if (xf86CheckPciSlot(bus, device, func)) { + + + if (xf86CheckPciSlot( d ) ) { num = xf86AllocateEntity(); p = xf86Entities[num]; p->driver = drvp; p->chipset = chipset; p->busType = BUS_PCI; - p->pciBusId.bus = bus; - p->pciBusId.device = device; - p->pciBusId.func = func; + p->pciBusId.bus = busnum; + p->pciBusId.device = d->dev; + p->pciBusId.func = d->func; p->active = active; p->inUse = FALSE; if (dev) xf86AddDevToEntity(num, dev); /* Here we initialize the access structure */ p->access = xnfcalloc(1,sizeof(EntityAccessRec)); - while (ppaccp && *ppaccp) { - if ((*ppaccp)->busnum == bus - && (*ppaccp)->devnum == device - && (*ppaccp)->funcnum == func) { - p->access->fallback = &(*ppaccp)->io_memAccess; - p->access->pAccess = &(*ppaccp)->io_memAccess; - (*ppaccp)->ctrl = TRUE; /* mark control if not already */ - break; - } - ppaccp++; + if ( paccp != NULL ) { + p->access->fallback = & paccp->io_memAccess; + p->access->pAccess = & paccp->io_memAccess; + paccp->ctrl = TRUE; /* mark control if not already */ } - if (!ppaccp || !*ppaccp) { + else { p->access->fallback = &AccessNULL; p->access->pAccess = &AccessNULL; } p->busAcc = NULL; while (pbap) { - if (pbap->type == BUS_PCI && pbap->busdep.pci.bus == bus) + if (pbap->type == BUS_PCI && pbap->busdep.pci.bus == busnum) p->busAcc = pbap; pbap = pbap->next; } - fixPciSizeInfo(num); /* in case bios is enabled disable it */ - disablePciBios(pciTag(bus,device,func)); + disablePciBios( d ); pciSlotClaimed = TRUE; if (active) { /* Map in this domain's I/O space */ p->domainIO = xf86MapDomainIO(-1, VIDMEM_MMIO, - pciTag(bus, device, func), 0, 1); + pciTag( busnum, d->dev, d->func ), + 0, 1); } return num; @@ -2886,138 +1503,6 @@ } /* - * Get xf86PciVideoInfo for a driver. - */ -_X_EXPORT pciVideoPtr * -xf86GetPciVideoInfo(void) -{ - return xf86PciVideoInfo; -} - -/* --- Used by ATI driver, but also more generally useful */ - -/* - * Get the full xf86scanpci data. - */ -_X_EXPORT pciConfigPtr * -xf86GetPciConfigInfo(void) -{ - return xf86PciInfo; -} - -/* - * Enable a device and route VGA to it. This is intended for a driver's - * Probe(), before creating EntityRec's. Only one device can be thus enabled - * at any one time, and should be disabled when the driver is done with it. - * - * The following special calls are also available: - * - * pvp == NULL && rt == NONE disable previously enabled device - * pvp != NULL && rt == NONE ensure device is disabled - * pvp == NULL && rt != NONE disable >all< subsequent calls to this function - * (done from xf86PostProbe()) - * The last combination has been removed! To do this cleanly we have - * to implement stages and need to test at each stage dependent function - * if it is allowed to execute. - * - * The device represented by pvp may not have been previously claimed. - */ -_X_EXPORT void -xf86SetPciVideo(pciVideoPtr pvp, resType rt) -{ - static BusAccPtr pbap = NULL; - static xf86AccessPtr pAcc = NULL; - static Bool DoneProbes = FALSE; - pciAccPtr pcaccp; - int i; - - if (DoneProbes) - return; - - /* Disable previous access */ - if (pAcc) { - if (pAcc->AccessDisable) - (*pAcc->AccessDisable)(pAcc->arg); - pAcc = NULL; - } - if (pbap) { - while (pbap->primary) { - if (pbap->disable_f) - (*pbap->disable_f)(pbap); - pbap->primary->current = NULL; - pbap = pbap->primary; - } - pbap = NULL; - } - - /* Check for xf86PostProbe's magic combo */ - if (!pvp) { - if (rt != NONE) - DoneProbes = TRUE; - return; - } - - /* Validate device */ - if (!xf86PciVideoInfo || !xf86PciAccInfo || !xf86BusAccInfo) - return; - - for (i = 0; pvp != xf86PciVideoInfo[i]; i++) - if (!xf86PciVideoInfo[i]) - return; - - /* Ignore request for claimed adapters */ - if (!xf86CheckPciSlot(pvp->bus, pvp->device, pvp->func)) - return; - - /* Find pciAccRec structure */ - for (i = 0; ; i++) { - if (!(pcaccp = xf86PciAccInfo[i])) - return; - if ((pvp->bus == pcaccp->busnum) && - (pvp->device == pcaccp->devnum) && - (pvp->func == pcaccp->funcnum)) - break; - } - - if (rt == NONE) { - /* This is a call to ensure the adapter is disabled */ - if (pcaccp->io_memAccess.AccessDisable) - (*pcaccp->io_memAccess.AccessDisable)(pcaccp->io_memAccess.arg); - return; - } - - /* Find BusAccRec structure */ - for (pbap = xf86BusAccInfo; ; pbap = pbap->next) { - if (!pbap) - return; - if (pvp->bus == pbap->busdep.pci.bus) - break; - } - - /* Route VGA */ - if (pbap->set_f) - (*pbap->set_f)(pbap); - - /* Enable device */ - switch (rt) { - case IO: - pAcc = &pcaccp->ioAccess; - break; - case MEM_IO: - pAcc = &pcaccp->io_memAccess; - break; - case MEM: - pAcc = &pcaccp->memAccess; - break; - default: /* no compiler noise */ - break; - } - - if (pAcc && pAcc->AccessEnable) - (*pAcc->AccessEnable)(pAcc->arg); -} - -/* * Parse a BUS ID string, and return the PCI bus parameters if it was * in the correct format for a PCI bus id. */ @@ -3114,36 +1599,42 @@ */ _X_EXPORT Bool -xf86IsPrimaryPci(pciVideoPtr pPci) +xf86IsPrimaryPci( struct pci_device * pPci ) { - if (primaryBus.type != BUS_PCI) return FALSE; - return (pPci->bus == primaryBus.id.pci.bus && - pPci->device == primaryBus.id.pci.device && - pPci->func == primaryBus.id.pci.func); + const unsigned busnum = PCI_MAKE_BUS( pPci->domain, pPci->bus ); + + return ( (primaryBus.type == BUS_PCI) + && (busnum == primaryBus.id.pci.bus) + && (pPci->dev == primaryBus.id.pci.device) + && (pPci->func == primaryBus.id.pci.func) ); } /* * xf86GetPciInfoForEntity() -- Get the pciVideoRec of entity. */ -_X_EXPORT pciVideoPtr +_X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex) { - pciVideoPtr *ppPci; EntityPtr p; if (entityIndex >= xf86NumEntities) return NULL; p = xf86Entities[entityIndex]; - if (p->busType != BUS_PCI) - return NULL; - - for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { - if (p->pciBusId.bus == (*ppPci)->bus && - p->pciBusId.device == (*ppPci)->device && - p->pciBusId.func == (*ppPci)->func) - return (*ppPci); + if ( p->busType == BUS_PCI ) { + const unsigned domain = PCI_DOM_FROM_BUS( p->pciBusId.bus ); + const unsigned bus = PCI_BUS_NO_DOMAIN( p->pciBusId.bus ); + struct pci_device ** ppPci; + + for (ppPci = xf86PciVideoInfo; *ppPci != NULL; ppPci++) { + if (domain == (*ppPci)->domain && + bus == (*ppPci)->bus && + p->pciBusId.device == (*ppPci)->dev && + p->pciBusId.func == (*ppPci)->func) + return (*ppPci); + } } + return NULL; } @@ -3169,12 +1660,12 @@ * PCI base address register values for the given PCI device. */ _X_EXPORT Bool -xf86CheckPciMemBase(pciVideoPtr pPci, memType base) +xf86CheckPciMemBase( struct pci_device * pPci, memType base ) { int i; for (i = 0; i < 6; i++) - if (base == pPci->memBase[i]) + if (base == pPci->regions[i].base_addr) return TRUE; return FALSE; } @@ -3184,16 +1675,17 @@ */ _X_EXPORT Bool -xf86CheckPciSlot(int bus, int device, int func) +xf86CheckPciSlot( const struct pci_device * d ) { int i; EntityPtr p; + const unsigned busnum = PCI_MAKE_BUS(d->domain, d->bus); for (i = 0; i < xf86NumEntities; i++) { p = xf86Entities[i]; /* Check if this PCI slot is taken */ - if (p->busType == BUS_PCI && p->pciBusId.bus == bus && - p->pciBusId.device == device && p->pciBusId.func == func) + if (p->busType == BUS_PCI && p->pciBusId.bus == busnum && + p->pciBusId.device == d->dev && p->pciBusId.func == d->func) return FALSE; } @@ -3208,125 +1700,43 @@ * so by setting pvp_exclude one pci device can be explicitely * _excluded if required. */ -_X_EXPORT pciVideoPtr -xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID, - char n, pciVideoPtr pvp_exclude) +_X_EXPORT struct pci_device * +xf86FindPciDeviceVendor( CARD16 vendorID, CARD16 deviceID, + char n, const struct pci_device * exclude ) { - pciVideoPtr pvp, *ppvp; + struct pci_device * pvp; + struct pci_device ** ppvp; + n++; for (ppvp = xf86PciVideoInfo, pvp =*ppvp; pvp ; pvp = *(++ppvp)) { - if (pvp == pvp_exclude) continue; - if ((pvp->vendor == vendorID) && (pvp->chipType == deviceID)) { + if ( (pvp != exclude) && (pvp->vendor_id == vendorID) + && (pvp->device_id == deviceID) ) { if (!(--n)) break; } } + return pvp; } -_X_EXPORT pciVideoPtr -xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class, - char n, pciVideoPtr pvp_exclude) +_X_EXPORT struct pci_device * +xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 _class, + char n, const struct pci_device * exclude) { - pciVideoPtr pvp, *ppvp; + struct pci_device * pvp; + struct pci_device ** ppvp; + const uint32_t device_class = ( ((uint32_t)_class) << 16) + | ( ((uint32_t)subClass) << 8) | intf; + n++; for (ppvp = xf86PciVideoInfo, pvp =*ppvp; pvp ; pvp = *(++ppvp)) { - if (pvp == pvp_exclude) continue; - if ((pvp->interface == intf) && (pvp->subclass == subClass) - && (pvp->class == class)) { + if ( (pvp != exclude) && (pvp->device_class == device_class) ) { if (!(--n)) break; } } - return pvp; -} -/* - * This attempts to detect a multi-device card and sets up a list - * of pci tags of the devices of this card. On some of these - * cards the BIOS is not visible from all chipsets. We therefore - * need to use the BIOS from a chipset where it is visible. - * We do the following heuristics: - * If we detect only identical pci devices on a bus we assume it's - * a multi-device card. This assumption isn't true always, however. - * One might just use identical cards on a bus. We therefore don't - * detect this situation when we set up the PCI video info. Instead - * we wait until an attempt to read the BIOS fails. - */ -int -pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag) -{ - pciConfigPtr *ppcrp = xf86PciInfo; - pciConfigPtr pcrp = NULL; - int i,j; - Bool multicard = FALSE; - Bool multifunc = FALSE; - char str[256]; - char *str1; - - str1 = str; - if (!pTag) - return 0; - - *pTag = NULL; - - for (i=0; i < 8; i++) { - j = 0; - - while (ppcrp[j]) { - if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i) { - pcrp = ppcrp[j]; - break; - } - j++; - } - - if (!pcrp) return 0; - - /* - * we check all functions here: since multifunc devices need - * to implement func 0 we catch all devices on the bus when - * i = 0 - */ - if (pcrp->pci_header_type &0x80) - multifunc = TRUE; - - j = 0; - - while (ppcrp[j]) { - if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i - && ppcrp[j]->devnum != pcrp->devnum) { - /* don't test subsys ID here. It might be set by POST - - however some cards might not have been POSTed */ - if (ppcrp[j]->pci_device_vendor != pcrp->pci_device_vendor - || ppcrp[j]->pci_header_type != pcrp->pci_header_type ) - return 0; - else - multicard = TRUE; - } - j++; - } - if (!multifunc) - break; - } - - if (!multicard) - return 0; - - j = 0; - i = 0; - while (ppcrp[i]) { - if (ppcrp[i]->busnum == bus && ppcrp[i]->funcnum == func) { - str1 += sprintf(str1,"[%x:%x:%x]",ppcrp[i]->busnum, - ppcrp[i]->devnum,ppcrp[i]->funcnum); - *pTag = xnfrealloc(*pTag,sizeof(PCITAG) * (j + 1)); - (*pTag)[j++] = pciTag(ppcrp[i]->busnum, - ppcrp[i]->devnum,ppcrp[i]->funcnum); - } - i++; - } - xf86MsgVerb(X_INFO,3,"Multi Device Card detected: %s\n",str); - return j; + return pvp; } static void @@ -3371,60 +1781,14 @@ pRange->type |= xf86GetPciDomain(tag) << 24; } -static void -pciConvertListToHost(int bus, int dev, int func, resPtr list) -{ - PCITAG tag = pciTag(bus,dev,func); - while (list) { - pciTagConvertRange2Host(tag, &list->val); - list = list->next; - } -} - -static void -updateAccessInfoStatusControlInfo(PCITAG tag, CARD32 ctrl) -{ - int i; - - if (!xf86PciAccInfo) - return; - - for (i = 0; xf86PciAccInfo[i] != NULL; i++) { - if (xf86PciAccInfo[i]->arg.tag == tag) - xf86PciAccInfo[i]->arg.ctrl = ctrl; - } -} - void pciConvertRange2Host(int entityIndex, resRange *pRange) { - PCITAG tag; - pciVideoPtr pvp; - - pvp = xf86GetPciInfoForEntity(entityIndex); - if (!pvp) return; - tag = TAG(pvp); - pciTagConvertRange2Host(tag, pRange); -} - - -#ifdef INCLUDE_DEPRECATED -_X_EXPORT void -xf86EnablePciBusMaster(pciVideoPtr pPci, Bool enable) -{ - CARD32 temp; - PCITAG tag; - - if (!pPci) return; + const struct pci_device * const pvp = xf86GetPciInfoForEntity(entityIndex); - tag = pciTag(pPci->bus, pPci->device, pPci->func); - temp = pciReadLong(tag, PCI_CMD_STAT_REG); - if (enable) { - updateAccessInfoStatusControlInfo(tag, temp | PCI_CMD_MASTER_ENABLE); - pciWriteLong(tag, PCI_CMD_STAT_REG, temp | PCI_CMD_MASTER_ENABLE); - } else { - updateAccessInfoStatusControlInfo(tag, temp & ~PCI_CMD_MASTER_ENABLE); - pciWriteLong(tag, PCI_CMD_STAT_REG, temp & ~PCI_CMD_MASTER_ENABLE); + if ( pvp != NULL ) { + const PCITAG tag = PCI_MAKE_TAG( PCI_MAKE_BUS( pvp->domain, pvp->bus ), + pvp->dev, pvp->func ); + pciTagConvertRange2Host(tag, pRange); } } -#endif /* INCLUDE_DEPRECATED */ Index: hw/xfree86/common/xf86pciBus.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86pciBus.h,v retrieving revision 1.2 diff -u -d -r1.2 xf86pciBus.h --- hw/xfree86/common/xf86pciBus.h 3 Jul 2005 07:01:24 -0000 1.2 +++ hw/xfree86/common/xf86pciBus.h 27 Apr 2006 17:26:46 -0000 @@ -43,7 +43,7 @@ } pciSave, *pciSavePtr; typedef struct { - PCITAG tag; + struct pci_device * dev; CARD32 ctrl; } pciArg; @@ -69,6 +69,7 @@ int primary, secondary, subordinate; int subclass; /* bridge type */ int interface; + struct pci_device * dev; resPtr preferred_io; /* I/O range */ resPtr preferred_mem; /* non-prefetchable memory range */ resPtr preferred_pmem; /* prefetchable memory range */ @@ -80,8 +81,6 @@ } PciBusRec, *PciBusPtr; void xf86PciProbe(void); -void ValidatePci(void); -resList GetImplicitPciResources(int entityIndex); void initPciState(void); void initPciBusState(void); void DisablePciAccess(void); @@ -90,10 +89,7 @@ void PciBusStateEnter(void); void PciStateLeave(void); void PciBusStateLeave(void); -resPtr ResourceBrokerInitPci(resPtr *osRes); void pciConvertRange2Host(int entityIndex, resRange *pRange); void isaConvertRange2Host(resRange *pRange); -extern pciAccPtr * xf86PciAccInfo; - #endif /* _XF86_PCI_BUS_H */ Index: hw/xfree86/common/xf86str.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/common/xf86str.h,v retrieving revision 1.13 diff -u -d -r1.13 xf86str.h --- hw/xfree86/common/xf86str.h 7 Mar 2006 23:58:22 -0000 1.13 +++ hw/xfree86/common/xf86str.h 27 Apr 2006 17:26:47 -0000 @@ -44,6 +44,8 @@ #include "xf86Opt.h" #include "xf86Pci.h" +#include + /* * memType is of the size of the addressable memory (machine size) * usually unsigned long. @@ -301,6 +303,9 @@ int refCount; } DriverRec1; +struct _SymTabRec; +struct _PciChipsets; + typedef struct _DriverRec { int driverVersion; char * driverName; @@ -310,6 +315,10 @@ pointer module; int refCount; xorgDriverFuncProc *driverFunc; + + const struct pci_id_match * supported_devices; + Bool (*PciProbe)( struct _DriverRec * drv, int entity_num, + struct pci_device * dev, intptr_t match_data ); } DriverRec, *DriverPtr; /* @@ -426,6 +435,9 @@ pointer extraOptions; } IDevRec, *IDevPtr; +#if 0 +/* Use struct pci_device from libpciaccess instead. + */ typedef struct { int vendor; int chipType; @@ -448,6 +460,7 @@ Bool validSize; Bool validate; } pciVideoRec, *pciVideoPtr; +#endif typedef struct { int frameX0; @@ -731,7 +744,7 @@ resRange *resList; } IsaChipsets; -typedef struct { +typedef struct _PciChipsets { /** * Key used to match this device with its name in an array of * \c SymTabRec. @@ -1060,7 +1073,7 @@ ); } DGAFunctionRec, *DGAFunctionPtr; -typedef struct { +typedef struct _SymTabRec { int token; /* id of the token */ const char * name; /* token name */ } SymTabRec, *SymTabPtr; Index: hw/xfree86/dri/dri.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/dri/dri.c,v retrieving revision 1.23 diff -u -d -r1.23 dri.c --- hw/xfree86/dri/dri.c 3 Apr 2006 01:35:05 -0000 1.23 +++ hw/xfree86/dri/dri.c 27 Apr 2006 17:26:47 -0000 @@ -2066,19 +2066,16 @@ } char * -DRICreatePCIBusID(pciVideoPtr PciInfo) +DRICreatePCIBusID( const struct pci_device * dev ) { char *busID; - int domain; - PCITAG tag; busID = xalloc(20); if (busID == NULL) return NULL; - tag = pciTag(PciInfo->bus, PciInfo->device, PciInfo->func); - domain = xf86GetPciDomain(tag); - snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", domain, PciInfo->bus, - PciInfo->device, PciInfo->func); + snprintf(busID, 20, "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus, + dev->dev, dev->func); + return busID; } Index: hw/xfree86/dri/dri.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/dri/dri.h,v retrieving revision 1.8 diff -u -d -r1.8 dri.h --- hw/xfree86/dri/dri.h 24 Sep 2005 18:45:45 -0000 1.8 +++ hw/xfree86/dri/dri.h 27 Apr 2006 17:26:47 -0000 @@ -36,6 +36,8 @@ #ifndef _DRI_H_ +#include + #include "scrnintstr.h" #include "xf86dri.h" @@ -338,7 +340,7 @@ int *ydir, RegionPtr reg); -extern char *DRICreatePCIBusID(pciVideoPtr PciInfo); +extern char *DRICreatePCIBusID( const struct pci_device * PciInfo ); #define _DRI_H_ Index: hw/xfree86/fbdevhw/fbdevhw.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/fbdevhw/fbdevhw.c,v retrieving revision 1.14 diff -u -d -r1.14 fbdevhw.c --- hw/xfree86/fbdevhw/fbdevhw.c 29 Mar 2006 01:05:09 -0000 1.14 +++ hw/xfree86/fbdevhw/fbdevhw.c 27 Apr 2006 17:26:47 -0000 @@ -271,51 +271,53 @@ /* try to find the framebuffer device for a given PCI device */ static int -fbdev_open_pci(pciVideoPtr pPci, char **namep) +fbdev_open_pci(struct pci_device * pPci, char **namep) { - struct fb_fix_screeninfo fix; - char filename[16]; - int fd,i,j; - memType res_start, res_end; + struct fb_fix_screeninfo fix; + char filename[16]; + int fd,i,j; - for (i = 0; i < 8; i++) { - sprintf(filename,"/dev/fb%d",i); - if (-1 == (fd = open(filename,O_RDWR,0))) { - xf86DrvMsg(-1, X_WARNING, - "open %s: %s\n", filename, strerror(errno)); - continue; - } - if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)&fix)) { - close(fd); - continue; - } - for (j = 0; j < 6; j++) { - res_start = pPci->memBase[j]; - res_end = res_start+pPci->size[j]; - if ((0 != fix.smem_len && - (memType) fix.smem_start >= res_start && - (memType) fix.smem_start < res_end) || - (0 != fix.mmio_len && - (memType) fix.mmio_start >= res_start && - (memType) fix.mmio_start < res_end)) - break; - } - if (j == 6) { - close(fd); - continue; - } - if (namep) { - *namep = xnfalloc(16); - strncpy(*namep,fix.id,16); - } - return fd; + + for (i = 0; i < 8; i++) { + sprintf(filename,"/dev/fb%d",i); + if (-1 == (fd = open(filename,O_RDWR,0))) { + xf86DrvMsg(-1, X_WARNING, + "open %s: %s\n", filename, strerror(errno)); + continue; } - if (namep) - *namep = NULL; - xf86DrvMsg(-1, X_ERROR, - "Unable to find a valid framebuffer device\n"); - return -1; + if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)&fix)) { + close(fd); + continue; + } + for (j = 0; j < 6; j++) { + const pciaddr_t res_start = pPci->regions[j].base_addr; + const pciaddr_t res_end = res_start + pPci->regions[j].size; + + if ((0 != fix.smem_len && + (pciaddr_t) fix.smem_start >= res_start && + (pciaddr_t) fix.smem_start < res_end) || + (0 != fix.mmio_len && + (pciaddr_t) fix.mmio_start >= res_start && + (pciaddr_t) fix.mmio_start < res_end)) + break; + } + if (j == 6) { + close(fd); + continue; + } + if (namep) { + *namep = xnfalloc(16); + strncpy(*namep,fix.id,16); + } + return fd; + } + + if (namep) + *namep = NULL; + xf86DrvMsg(-1, X_ERROR, + "Unable to find a valid framebuffer device\n"); + return -1; } static int @@ -360,7 +362,7 @@ /* -------------------------------------------------------------------- */ Bool -fbdevHWProbe(pciVideoPtr pPci, char *device,char **namep) +fbdevHWProbe(struct pci_device * pPci, char *device,char **namep) { int fd; @@ -376,7 +378,7 @@ } Bool -fbdevHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device) +fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device) { fbdevHWPtr fPtr; Index: hw/xfree86/fbdevhw/fbdevhw.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/fbdevhw/fbdevhw.h,v retrieving revision 1.6 diff -u -d -r1.6 fbdevhw.h --- hw/xfree86/fbdevhw/fbdevhw.h 24 Aug 2005 11:18:33 -0000 1.6 +++ hw/xfree86/fbdevhw/fbdevhw.h 27 Apr 2006 17:26:47 -0000 @@ -6,6 +6,8 @@ #include "xf86str.h" #include "colormapst.h" +#include + #define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */ #define FBDEVHW_PLANES 1 /* Non interleaved planes */ #define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */ @@ -15,8 +17,8 @@ Bool fbdevHWGetRec(ScrnInfoPtr pScrn); void fbdevHWFreeRec(ScrnInfoPtr pScrn); -Bool fbdevHWProbe(pciVideoPtr pPci, char *device, char **namep); -Bool fbdevHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device); +Bool fbdevHWProbe(struct pci_device * pPci, char *device, char **namep); +Bool fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device); char* fbdevHWGetName(ScrnInfoPtr pScrn); int fbdevHWGetDepth(ScrnInfoPtr pScrn, int *fbbpp); Index: hw/xfree86/int10/generic.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/int10/generic.c,v retrieving revision 1.5 diff -u -d -r1.5 generic.c --- hw/xfree86/int10/generic.c 10 Mar 2006 08:03:24 -0000 1.5 +++ hw/xfree86/int10/generic.c 27 Apr 2006 17:26:47 -0000 @@ -17,6 +17,7 @@ #define _INT10_PRIVATE #include "xf86int10.h" #include "int10Defines.h" +#include "Pci.h" #define ALLOC_ENTRIES(x) ((V_RAM / x) - 1) @@ -75,7 +76,7 @@ void* base = 0; void* vbiosMem = 0; void* options = NULL; - pciVideoPtr pvp; + struct pci_device * pvp; int screen; legacyVGARec vga; xf86int10BiosLocation bios; @@ -105,7 +106,10 @@ base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS); pvp = xf86GetPciInfoForEntity(entityIndex); - if (pvp) pInt->Tag = ((pciConfigPtr)(pvp->thisCard))->tag; + if ( pvp != NULL ) { + pInt->Tag = PCI_MAKE_TAG( PCI_MAKE_BUS( pvp->domain, pvp->bus ), + pvp->dev, pvp->func ); + } /* * we need to map video RAM MMIO as some chipsets map mmio Index: hw/xfree86/int10/pci.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/int10/pci.c,v retrieving revision 1.4 diff -u -d -r1.4 pci.c --- hw/xfree86/int10/pci.c 10 Feb 2006 22:00:25 -0000 1.4 +++ hw/xfree86/int10/pci.c 27 Apr 2006 17:26:47 -0000 @@ -19,11 +19,8 @@ int mapPciRom(int pciEntity, unsigned char * address) { - PCITAG tag; - unsigned char *mem, *ptr; - int length; - - pciVideoPtr pvp = xf86GetPciInfoForEntity(pciEntity); + struct pci_device * pvp = xf86GetPciInfoForEntity(pciEntity); + int err; if (pvp == NULL) { #ifdef DEBUG @@ -32,19 +29,11 @@ return 0; } - tag = pciTag(pvp->bus,pvp->device,pvp->func); - length = 1 << pvp->biosSize; - /* Read in entire PCI ROM */ - mem = ptr = xnfcalloc(length, 1); - length = xf86ReadPciBIOS(0, tag, -1, ptr, length); - if (length > 0) - memcpy(address, ptr, length); - /* unmap/close/disable PCI bios mem */ - xfree(mem); + err = pci_device_read_rom( pvp, address ); #ifdef DEBUG - if (!length) + if ( err != 0 ) ErrorF("mapPciRom: no BIOS found\n"); #ifdef PRINT_PCI else @@ -52,5 +41,5 @@ #endif #endif - return length; + return pvp->rom_size; } Index: hw/xfree86/int10/xf86int10.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/int10/xf86int10.c,v retrieving revision 1.4 diff -u -d -r1.4 xf86int10.c --- hw/xfree86/int10/xf86int10.c 10 Feb 2006 22:00:25 -0000 1.4 +++ hw/xfree86/int10/xf86int10.c 27 Apr 2006 17:26:48 -0000 @@ -24,8 +24,9 @@ static int int42_handler(xf86Int10InfoPtr pInt); #endif static int intE6_handler(xf86Int10InfoPtr pInt); -static PCITAG findPci(xf86Int10InfoPtr pInt, unsigned short bx); -static CARD32 pciSlotBX(pciVideoPtr pvp); +static struct pci_device * findPci( xf86Int10InfoPtr pInt, + unsigned short bx ); +static CARD32 pciSlotBX( const struct pci_device * pvp ); int int_handler(xf86Int10InfoPtr pInt) @@ -597,7 +598,8 @@ int1A_handler(xf86Int10InfoPtr pInt) { PCITAG tag; - pciVideoPtr pvp; + struct pci_device * pvp; + struct pci_device * dev; if (!(pvp = xf86GetPciInfoForEntity(pInt->entityIndex))) return 0; /* oops */ @@ -620,7 +622,9 @@ #endif return 1; case 0xb102: - if (X86_DX == pvp->vendor && X86_CX == pvp->chipType && X86_ESI == 0) { + if ( (X86_DX == pvp->vendor_id) + && (X86_CX == pvp->device_id) + && (X86_ESI == 0) ) { X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ X86_EBX = pciSlotBX(pvp); @@ -642,9 +646,7 @@ #endif return 1; case 0xb103: - if (X86_CL == pvp->interface && - X86_CH == pvp->subclass && - ((X86_ECX & 0xFFFF0000) >> 16) == pvp->class) { + if ( (X86_ECX & 0x00FFFFFF) == pvp->device_class ) { X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EBX = pciSlotBX(pvp); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ @@ -667,8 +669,8 @@ #endif return 1; case 0xb108: - if ((tag = findPci(pInt, X86_EBX)) != PCI_NOT_FOUND) { - X86_CL = pciReadByte(tag, X86_EDI); + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_read_u8( dev, & X86_CL, X86_EDI ); X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ } else { @@ -680,8 +682,8 @@ #endif return 1; case 0xb109: - if ((tag = findPci(pInt, X86_EBX)) != PCI_NOT_FOUND) { - X86_CX = pciReadWord(tag, X86_EDI); + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_read_u16( dev, & X86_CX, X86_EDI ); X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ } else { @@ -693,8 +695,8 @@ #endif return 1; case 0xb10a: - if ((tag = findPci(pInt, X86_EBX)) != PCI_NOT_FOUND) { - X86_ECX = pciReadLong(tag, X86_EDI); + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_read_u32( dev, & X86_ECX, X86_EDI ); X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ } else { @@ -706,8 +708,8 @@ #endif return 1; case 0xb10b: - if ((tag = findPci(pInt, X86_EBX)) != PCI_NOT_FOUND) { - pciWriteByte(tag, X86_EDI, X86_CL); + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_write_u8( dev, & X86_CL, X86_EDI ); X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ } else { @@ -719,8 +721,8 @@ #endif return 1; case 0xb10c: - if ((tag = findPci(pInt, X86_EBX)) != PCI_NOT_FOUND) { - pciWriteWord(tag, X86_EDI, X86_CX); + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_write_u16( dev, & X86_CX, X86_EDI ); X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ } else { @@ -732,8 +734,8 @@ #endif return 1; case 0xb10d: - if ((tag = findPci(pInt, X86_EBX)) != PCI_NOT_FOUND) { - pciWriteLong(tag, X86_EDI, X86_ECX); + if ((dev = findPci(pInt, X86_EBX)) != NULL) { + pci_device_cfg_write_u32( dev, & X86_ECX, X86_EDI ); X86_EAX = X86_AL | (SUCCESSFUL << 8); X86_EFLAGS &= ~((unsigned long)0x01); /* clear carry flag */ } else { @@ -754,21 +756,21 @@ } } -static PCITAG +static struct pci_device * findPci(xf86Int10InfoPtr pInt, unsigned short bx) { - int bus = ((pInt->Tag >> 16) & ~0x00FF) | ((bx >> 8) & 0x00FF); - int dev = (bx >> 3) & 0x1F; - int func = bx & 0x7; - if (xf86IsPciDevPresent(bus, dev, func)) - return pciTag(bus, dev, func); - return PCI_NOT_FOUND; + const unsigned domain = PCI_DOM_FROM_TAG( pInt->Tag ); + const unsigned bus = (bx >> 8) & 0x00FF; + const unsigned dev = (bx >> 3) & 0x001F; + const unsigned func = (bx ) & 0x0007; + + return pci_device_find_by_slot( domain, bus, dev, func ); } static CARD32 -pciSlotBX(pciVideoPtr pvp) +pciSlotBX(const struct pci_device * pvp) { - return ((pvp->bus << 8) & 0x00FF00) | (pvp->device << 3) | (pvp->func); + return ((pvp->bus << 8) & 0x00FF00) | (pvp->dev << 3) | (pvp->func); } /* @@ -777,10 +779,10 @@ static int intE6_handler(xf86Int10InfoPtr pInt) { - pciVideoPtr pvp; + struct pci_device * pvp; if ((pvp = xf86GetPciInfoForEntity(pInt->entityIndex))) - X86_AX = (pvp->bus << 8) | (pvp->device << 3) | (pvp->func & 0x7); + X86_AX = (pvp->bus << 8) | (pvp->dev << 3) | (pvp->func & 0x7); pushw(pInt, X86_CS); pushw(pInt, X86_IP); X86_CS = pInt->BIOSseg; Index: hw/xfree86/loader/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/loader/Makefile.am,v retrieving revision 1.9 diff -u -d -r1.9 Makefile.am --- hw/xfree86/loader/Makefile.am 2 Dec 2005 06:02:41 -0000 1.9 +++ hw/xfree86/loader/Makefile.am 27 Apr 2006 17:26:48 -0000 @@ -1,7 +1,7 @@ noinst_LIBRARIES = libloader.a INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(srcdir)/../vbe \ -I$(srcdir)/../ddc -I$(srcdir)/../int10 -I$(srcdir)/../i2c \ - -I$(srcdir)/../fbdevhw -I$(srcdir)/../scanpci -I$(srcdir)/../xaa \ + -I$(srcdir)/../fbdevhw -I$(srcdir)/../xaa \ -I$(srcdir)/../vgahw -I$(srcdir)/../ramdac -I$(srcdir)/../shadowfb \ -I$(srcdir)/../dixmods/extmod -I$(srcdir)/../../../miext/cw \ -I$(srcdir)/../../../miext/damage Index: hw/xfree86/loader/xf86sym.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/loader/xf86sym.c,v retrieving revision 1.21 diff -u -d -r1.21 xf86sym.c --- hw/xfree86/loader/xf86sym.c 28 Mar 2006 07:21:50 -0000 1.21 +++ hw/xfree86/loader/xf86sym.c 27 Apr 2006 17:26:48 -0000 @@ -49,8 +49,6 @@ * authorization from the copyright holder(s) and author(s). */ -#define INCLUDE_DEPRECATED 1 - #ifdef HAVE_XORG_CONFIG_H #include #endif @@ -308,10 +306,7 @@ /* xf86Bus.c */ SYMFUNC(xf86CheckPciSlot) SYMFUNC(xf86ClaimPciSlot) - SYMFUNC(xf86GetPciVideoInfo) SYMFUNC(xf86GetPciEntity) - SYMFUNC(xf86GetPciConfigInfo) - SYMFUNC(xf86SetPciVideo) SYMFUNC(xf86ClaimIsaSlot) SYMFUNC(xf86ClaimFbSlot) SYMFUNC(xf86ClaimNoSlot) @@ -342,20 +337,14 @@ SYMFUNC(xf86CheckPciMemBase) SYMFUNC(xf86SetAccessFuncs) SYMFUNC(xf86IsEntityPrimary) - SYMFUNC(xf86FixPciResource) SYMFUNC(xf86SetOperatingState) SYMFUNC(xf86EnterServerState) SYMFUNC(xf86GetBlock) SYMFUNC(xf86GetSparse) - SYMFUNC(xf86ReallocatePciResources) SYMFUNC(xf86ChkConflict) - SYMFUNC(xf86IsPciDevPresent) SYMFUNC(xf86FindScreenForEntity) SYMFUNC(xf86FindPciDeviceVendor) SYMFUNC(xf86FindPciClass) -#ifdef INCLUDE_DEPRECATED - SYMFUNC(xf86EnablePciBusMaster) -#endif SYMFUNC(xf86RegisterStateChangeNotificationCallback) SYMFUNC(xf86DeregisterStateChangeNotificationCallback) SYMFUNC(xf86NoSharedResources) @@ -739,9 +728,7 @@ SYMFUNC(pciTag) SYMFUNC(pciBusAddrToHostAddr) SYMFUNC(pciHostAddrToBusAddr) - SYMFUNC(xf86MapPciMem) SYMFUNC(xf86scanpci) - SYMFUNC(xf86ReadPciBIOS) /* Loader functions */ SYMFUNC(LoaderDefaultFunc) Index: hw/xfree86/os-support/bus/Pci.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/bus/Pci.c,v retrieving revision 1.14 diff -u -d -r1.14 Pci.c --- hw/xfree86/os-support/bus/Pci.c 26 Apr 2006 11:40:58 -0000 1.14 +++ hw/xfree86/os-support/bus/Pci.c 27 Apr 2006 17:26:48 -0000 @@ -23,13 +23,6 @@ * function * pciBusAddrToHostAddr() - Convert a PCI address to a host address * pciHostAddrToBusAddr() - Convert a host address to a PCI address - * pciGetBaseSize() - Returns the number of bits in a PCI base - * addr mapping - * xf86MapPciMem() - Like xf86MapVidMem() except function expects - * a PCI address and a PCITAG that identifies - * a PCI device - * xf86ReadPciBIOS() - Like xf86ReadBIOS() but can handle PCI/host - * address translation and BIOS decode enabling * xf86scanpci() - Return info about all PCI devices * xf86GetPciDomain() - Return domain number from a PCITAG * xf86MapDomainMemory() - Like xf86MapPciMem() but can handle @@ -209,6 +202,14 @@ #include "xf86_OSproc.h" #include "Pci.h" +#if 0 +#include +#include +#include +#include +#include +#endif + #define PCI_MFDEV_SUPPORT 1 /* Include PCI multifunction device support */ #define PCI_BRIDGE_SUPPORT 1 /* Include support for PCI-to-PCI bridges */ @@ -490,123 +491,6 @@ return(addr); } -/* - * pciGetBaseSize() returns the size of a PCI base address mapping in bits. - * The index identifies the base register: 0-5 are the six standard registers, - * and 6 is the ROM base register. If destructive is TRUE, it will write - * to the base address register to get an accurate result. Otherwise it - * makes a conservative guess based on the alignment of the already allocated - * address. If the result is accurate (ie, not an over-estimate), this is - * indicated by setting *min to TRUE (when min is non-NULL). This happens - * when either the destructive flag is set, the information is supplied by - * the OS if the OS supports this. - */ - -int -pciGetBaseSize(PCITAG tag, int index, Bool destructive, Bool *min) -{ - int offset; - CARD32 addr1; - CARD32 addr2; - CARD32 mask1; - CARD32 mask2; - int bits = 0; - - /* - * Eventually a function for this should be added to pciBusFuncs_t, but for - * now we'll just use a simple method based on the alignment of the already - * allocated address. - */ - - /* - * silently ignore bogus index values. Valid values are 0-6. 0-5 are - * the 6 base address registers, and 6 is the ROM base address register. - */ - if (index < 0 || index > 6) - return 0; - - pciInit(); - - if (xf86GetPciSizeFromOS(tag, index, &bits)) { - if (min) - *min = TRUE; - return bits; - } - - if (min) - *min = destructive; - - /* Get the PCI offset */ - if (index == 6) - offset = PCI_MAP_ROM_REG; - else - offset = PCI_MAP_REG_START + (index << 2); - - addr1 = pciReadLong(tag, offset); - /* - * Check if this is the second part of a 64 bit address. - * XXX need to check how endianness affects 64 bit addresses. - */ - if (index > 0 && index < 6) { - addr2 = pciReadLong(tag, offset - 4); - if (PCI_MAP_IS_MEM(addr2) && PCI_MAP_IS64BITMEM(addr2)) - return 0; - } - - if (destructive) { - pciWriteLong(tag, offset, 0xffffffff); - mask1 = pciReadLong(tag, offset); - pciWriteLong(tag, offset, addr1); - } else { - mask1 = addr1; - } - - /* Check if this is the first part of a 64 bit address. */ - if (index < 5 && PCI_MAP_IS_MEM(mask1) && PCI_MAP_IS64BITMEM(mask1)) { - if (PCIGETMEMORY(mask1) == 0) { - addr2 = pciReadLong(tag, offset + 4); - if (destructive) { - pciWriteLong(tag, offset + 4, 0xffffffff); - mask2 = pciReadLong(tag, offset + 4); - pciWriteLong(tag, offset + 4, addr2); - } else { - mask2 = addr2; - } - if (mask2 == 0) - return 0; - bits = 32; - while ((mask2 & 1) == 0) { - bits++; - mask2 >>= 1; - } - if (bits > 32) - return bits; - } - } - if (index < 6) - if (PCI_MAP_IS_MEM(mask1)) - mask1 = PCIGETMEMORY(mask1); - else - mask1 = PCIGETIO(mask1); - else - mask1 = PCIGETROM(mask1); - if (mask1 == 0) - return 0; - bits = 0; - while ((mask1 & 1) == 0) { - bits++; - mask1 >>= 1; - } - /* I/O maps can be no larger than 8 bits */ - - if ((index < 6) && PCI_MAP_IS_IO(addr1) && bits > 8) - bits = 8; - /* ROM maps can be no larger than 24 bits */ - if (index == 6 && bits > 24) - bits = 24; - return bits; -} - _X_EXPORT PCITAG pciTag(int busnum, int devnum, int funcnum) { @@ -887,7 +771,7 @@ #else /* !BIG_ENDIAN */ return(u); - + #endif } @@ -962,10 +846,6 @@ switch (devp->pci_header_type & 0x7f) { case 0: - /* Get base address sizes for type 0 headers */ - for (i = 0; i < 7; i++) - devp->basesize[i] = - pciGetBaseSize(tag, i, FALSE, &devp->minBasesize); break; case 1: @@ -987,13 +867,13 @@ xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", devp->busnum, devp->devnum, devp->funcnum, - devp->pci_vendor, devp->pci_device, devp->pci_rev_id, + devp->pci_vendor, devp->_pci_device, devp->pci_rev_id, devp->pci_base_class, devp->pci_sub_class); #else xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", devp->busnum, devp->devnum, devp->funcnum, - devp->pci_vendor, devp->pci_device, + devp->pci_vendor, devp->_pci_device, devp->pci_subsys_vendor, devp->pci_subsys_card, devp->pci_rev_id, devp->pci_base_class, devp->pci_sub_class, devp->pci_prog_if, @@ -1075,261 +955,6 @@ return pciReadLong(Tag, PCI_MAP_REG_START + (basereg << 2)); } -#if defined(INCLUDE_XF86_MAP_PCI_MEM) - -_X_EXPORT pointer -xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, ADDRESS Base, - unsigned long Size) -{ - ADDRESS hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM,Base); - pointer base; - CARD32 save = 0; - - /* - * If there are possible read side-effects, disable memory while - * doing the mapping. - */ - if (Flags & VIDMEM_READSIDEEFFECT) { - save = pciReadLong(Tag, PCI_CMD_STAT_REG); - pciWriteLong(Tag, PCI_CMD_STAT_REG, - save & ~PCI_CMD_MEM_ENABLE); - } - base = xf86MapDomainMemory(ScreenNum, Flags, Tag, hostbase, Size); - if (!base) { - FatalError("xf86MapPciMem: Could not mmap PCI memory " - "[base=0x%lx,hostbase=0x%lx,size=%lx] (%s)\n", - Base, hostbase, Size, strerror(errno)); - } - /* - * If read side-effects, do whatever might be needed to prevent - * unintended reads, then restore PCI_CMD_STAT_REG. - */ - if (Flags & VIDMEM_READSIDEEFFECT) { - xf86MapReadSideEffects(ScreenNum, Flags, base, Size); - pciWriteLong(Tag, PCI_CMD_STAT_REG, save); - } - return((pointer)base); -} - -static int -handlePciBIOS( PCITAG Tag, int basereg, unsigned char * buf, int len ) -{ - CARD32 romsave = 0; - int i; - romBaseSource b_reg; - ADDRESS hostbase; - CARD8 tmp[64]; - int ret = 0; - - romsave = pciReadLong(Tag, PCI_MAP_ROM_REG); - - for (i = ROM_BASE_PRESET; i <= ROM_BASE_FIND; i++) { - memType savebase = 0, newbase, romaddr; - - switch (i) { - case ROM_BASE_PRESET: - /* Does the driver have a preference? */ - if (basereg > ROM_BASE_PRESET && basereg <= ROM_BASE_FIND) - b_reg = basereg; - else - b_reg = ++i; - break; - case ROM_BASE_FIND: - /* - * If we have something that looks like a valid address - * in romsave, it's probably not going to help to try - * to guess a new address and reprogram it. - */ - if (PCIGETROM(romsave)) { - pciWriteLong(Tag, PCI_MAP_ROM_REG, PCI_MAP_ROM_ADDRESS_MASK); - if (romsave != pciReadLong(Tag, PCI_MAP_ROM_REG)) { - pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave); - continue; - } - } - default: - b_reg = i; - } - - if (!(newbase = getValidBIOSBase(Tag, b_reg))) - continue; /* no valid address found */ - - romaddr = PCIGETROM(newbase); - - /* if we use a mem base save it and move it out of the way */ - if (b_reg >= 0 && b_reg <= 5) { - savebase = pciReadLong(Tag, PCI_MAP_REG_START+(b_reg<<2)); - xf86MsgVerb(X_INFO,5,"xf86ReadPciBios: modifying membase[%i]" - " for device %i:%i:%i\n", basereg, - (int)PCI_BUS_FROM_TAG(Tag), (int)PCI_DEV_FROM_TAG(Tag), - (int)PCI_FUNC_FROM_TAG(Tag)); - pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2), - (CARD32)~0); - } - /* Set ROM base address and enable ROM address decoding */ - pciWriteLong(Tag, PCI_MAP_ROM_REG, romaddr - | PCI_MAP_ROM_DECODE_ENABLE); - - hostbase = pciBusAddrToHostAddr(Tag, PCI_MEM, PCIGETROM(romaddr)); - - if ((xf86ReadDomainMemory(Tag, hostbase, sizeof(tmp), tmp) != - sizeof(tmp)) || - (tmp[0] != 0x55) || (tmp[1] != 0xaa) || !tmp[2] ) { - /* Restore the base registers if they were changed. */ - pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave); - if (savebase) pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2), - (CARD32) savebase); - - /* No BIOS found: try another address */ - continue; - } - - ret = readPciBios( Tag, tmp, hostbase, buf, len, PCI_BIOS_PC ); - - /* Restore the base register if it was changed. */ - if (savebase) pciWriteLong(Tag, PCI_MAP_REG_START + (b_reg << 2), - (CARD32) savebase); - /* Restore ROM address decoding */ - pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave); - - return ret; - } - /* Restore ROM address decoding */ - pciWriteLong(Tag, PCI_MAP_ROM_REG, romsave); - return 0; -} - - -static int -readPciBios(PCITAG Tag, CARD8* tmp, ADDRESS hostbase, unsigned char * buf, - int len, PciBiosType bios_type ) -{ - unsigned int image_length = 0; - int ret; - - /* We found a PCI BIOS Image. Now we look for the correct type */ - while ((tmp[0] == 0x55) && (tmp[1] == 0xAA)) { - unsigned short data_off = tmp[0x18] | (tmp[0x19] << 8); - unsigned char data[0x18]; - unsigned char type; - - if ((xf86ReadDomainMemory(Tag, hostbase + data_off, sizeof(data), data) - != sizeof(data)) || - (data[0] != 'P') || - (data[1] != 'C') || - (data[2] != 'I') || - (data[3] != 'R')) - break; - - type = data[0x14]; -#ifdef PRINT_PCI - ErrorF("data segment in BIOS: 0x%x, type: 0x%x\n", data_off, type); -#endif - if (type != bios_type) { /* not correct image: find next one */ - const unsigned char indicator = data[0x15]; - unsigned int i_length; - - if (indicator & 0x80) /* last image */ - break; - - i_length = (data[0x10] | (data[0x11] << 8)) << 9; - -#ifdef PRINT_PCI - ErrorF( "data image length: 0x%x, ind: 0x%x\n", i_length, indicator ); -#endif - hostbase += i_length; - if (xf86ReadDomainMemory(Tag, hostbase, sizeof(tmp), tmp) - != sizeof(tmp)) - break; - continue; - } - /* OK, we have a PCI BIOS Image of the correct type */ - - if ( bios_type == PCI_BIOS_PC ) - image_length = tmp[2] << 9; - else - image_length = (data[0x10] | (data[0x11] << 8)) << 9; -#ifdef PRINT_PCI - ErrorF("BIOS length: 0x%x\n", image_length); -#endif - break; - } - - ret = 0; - if (image_length) { - - /* If no length is given return the full length. Beware: Area pointed to - * by Buf must be large enough! - */ - if (len == 0) { - len = image_length; - } - else if ( len > image_length ) { - len = image_length; - xf86MsgVerb( X_INFO, 3, "Truncating PCI BIOS Length to %i\n", - len ); - } - - /* Read BIOS */ - ret = xf86ReadDomainMemory( Tag, hostbase, len, buf ); - } - - return ret; -} - - -static int -HandlePciBios(PCITAG Tag, int basereg, unsigned char * buf, int len) -{ - int n, num; - CARD32 Acc1, Acc2; - PCITAG *pTag; - int i; - - /* fall back to the old code if the OS code fails */ - if (pciOSHandleBIOS) { - n = pciOSHandleBIOS(Tag, basereg, buf, len); - if (n) - return n; - } - - n = handlePciBIOS( Tag, basereg, buf, len ); - if (n) - return n; - - num = pciTestMultiDeviceCard(PCI_BUS_FROM_TAG(Tag), - PCI_DEV_FROM_TAG(Tag), - PCI_FUNC_FROM_TAG(Tag),&pTag); - - if (!num) return 0; - -#define PCI_ENA (PCI_CMD_MEM_ENABLE | PCI_CMD_IO_ENABLE) - Acc1 = pciReadLong(Tag, PCI_CMD_STAT_REG); - pciWriteLong(Tag, PCI_CMD_STAT_REG, (Acc1 & ~PCI_ENA)); - - for (i = 0; i < num; i++) { - Acc2 = pciReadLong(pTag[i], PCI_CMD_STAT_REG); - pciWriteLong(pTag[i], PCI_CMD_STAT_REG, (Acc2 | PCI_ENA)); - - n = handlePciBIOS( pTag[i], 0, buf, len ); - - pciWriteLong(pTag[i], PCI_CMD_STAT_REG, Acc2); - if (n) - break; - } - pciWriteLong(Tag, PCI_CMD_STAT_REG, Acc1); - return n; -} - -_X_EXPORT int -xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg, - unsigned char *Buf, int Len) -{ - return HandlePciBios(Tag, basereg, Buf, Len); -} - -#endif /* INCLUDE_XF86_MAP_PCI_MEM */ - #ifdef INCLUDE_XF86_NO_DOMAIN _X_EXPORT int Index: hw/xfree86/os-support/bus/linuxPci.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/bus/linuxPci.c,v retrieving revision 1.13 diff -u -d -r1.13 linuxPci.c --- hw/xfree86/os-support/bus/linuxPci.c 26 Apr 2006 11:40:58 -0000 1.13 +++ hw/xfree86/os-support/bus/linuxPci.c 27 Apr 2006 17:26:48 -0000 @@ -441,9 +441,9 @@ continue; if (pPCI->pci_vendor < pciControllerSizes[i].vendor) break; - if (pPCI->pci_device > pciControllerSizes[i].device) + if (pPCI->_pci_device > pciControllerSizes[i].device) continue; - if (pPCI->pci_device < pciControllerSizes[i].device) + if (pPCI->_pci_device < pciControllerSizes[i].device) break; return pciControllerSizes[i].io_size; } @@ -469,9 +469,9 @@ continue; if (pPCI->pci_vendor < pciControllerSizes[i].vendor) break; - if (pPCI->pci_device > pciControllerSizes[i].device) + if (pPCI->_pci_device > pciControllerSizes[i].device) continue; - if (pPCI->pci_device < pciControllerSizes[i].device) + if (pPCI->_pci_device < pciControllerSizes[i].device) break; *io_size = pciControllerSizes[i].io_size; *mem_size = pciControllerSizes[i].mem_size; Index: hw/xfree86/os-support/bus/xf86Pci.h =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/bus/xf86Pci.h,v retrieving revision 1.10 diff -u -d -r1.10 xf86Pci.h --- hw/xfree86/os-support/bus/xf86Pci.h 21 Feb 2006 00:02:08 -0000 1.10 +++ hw/xfree86/os-support/bus/xf86Pci.h 27 Apr 2006 17:26:49 -0000 @@ -651,7 +651,7 @@ * Data structure returned by xf86scanpci including contents of * PCI config space header */ -typedef struct pci_device { +typedef struct { PCITAG tag; int busnum; int devnum; @@ -676,7 +676,7 @@ #define pci_device_vendor cfgspc.regs.dv_id.device_vendor #define pci_vendor cfgspc.regs.dv_id.dv.vendor -#define pci_device cfgspc.regs.dv_id.dv.device +#define _pci_device cfgspc.regs.dv_id.dv.device #define pci_status_command cfgspc.regs.stat_cmd.status_command #define pci_command cfgspc.regs.stat_cmd.sc.command #define pci_status cfgspc.regs.stat_cmd.sc.status @@ -769,10 +769,6 @@ PCITAG pciTag(int busnum, int devnum, int funcnum); int pciGetBaseSize(PCITAG tag, int indx, Bool destructive, Bool *min); CARD32 pciCheckForBrokenBase(PCITAG tag,int basereg); -pointer xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, - ADDRESS Base, unsigned long Size); -int xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg, - unsigned char *Buf, int Len); pciConfigPtr *xf86scanpci(int flags); extern int pciNumBuses; Index: hw/xfree86/os-support/bus/zx1PCI.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/bus/zx1PCI.c,v retrieving revision 1.6 diff -u -d -r1.6 zx1PCI.c --- hw/xfree86/os-support/bus/zx1PCI.c 16 Mar 2006 16:29:17 -0000 1.6 +++ hw/xfree86/os-support/bus/zx1PCI.c 27 Apr 2006 17:26:49 -0000 @@ -1074,13 +1074,13 @@ xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->pci_device, pPCI->pci_rev_id, + pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_rev_id, pPCI->pci_base_class, pPCI->pci_sub_class); #else xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->pci_device, + pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_subsys_vendor, pPCI->pci_subsys_card, pPCI->pci_rev_id, pPCI->pci_base_class, pPCI->pci_sub_class, pPCI->pci_prog_if, @@ -1123,13 +1123,13 @@ xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->pci_device, pPCI->pci_rev_id, + pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_rev_id, pPCI->pci_base_class, pPCI->pci_sub_class); #else xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->pci_device, + pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_subsys_vendor, pPCI->pci_subsys_card, pPCI->pci_rev_id, pPCI->pci_base_class, pPCI->pci_sub_class, pPCI->pci_prog_if, Index: hw/xfree86/os-support/linux/lnx_agp.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/os-support/linux/lnx_agp.c,v retrieving revision 1.12 diff -u -d -r1.12 lnx_agp.c --- hw/xfree86/os-support/linux/lnx_agp.c 25 Mar 2006 19:52:04 -0000 1.12 +++ hw/xfree86/os-support/linux/lnx_agp.c 27 Apr 2006 17:26:49 -0000 @@ -13,6 +13,10 @@ #include #endif +#if defined(linux) +#include +#endif + #include #include "xf86.h" #include "xf86Priv.h" @@ -21,7 +25,7 @@ #if defined(linux) #include -#include +/*#include */ #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) #include #include Index: hw/xfree86/utils/Makefile.am =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/utils/Makefile.am,v retrieving revision 1.5 diff -u -d -r1.5 Makefile.am --- hw/xfree86/utils/Makefile.am 28 Dec 2005 15:22:21 -0000 1.5 +++ hw/xfree86/utils/Makefile.am 27 Apr 2006 17:26:49 -0000 @@ -3,7 +3,5 @@ cvt \ ioport \ kbd_mode \ - pcitweak \ - scanpci \ xorgcfg \ xorgconfig Index: hw/xfree86/utils/xorgcfg/loadmod.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/utils/xorgcfg/loadmod.c,v retrieving revision 1.4 diff -u -d -r1.4 loadmod.c --- hw/xfree86/utils/xorgcfg/loadmod.c 25 Mar 2006 19:52:05 -0000 1.4 +++ hw/xfree86/utils/xorgcfg/loadmod.c 27 Apr 2006 17:26:49 -0000 @@ -70,15 +70,13 @@ void xf86MsgVerb(int, int, const char*, ...); void xf86PrintChipsets(const char*, const char*, SymTabPtr); void xf86ErrorFVerb(int verb, const char *format, ...); -pciVideoPtr *xf86GetPciVideoInfo(void); int xf86MatchDevice(const char*, GDevPtr**); int xf86MatchPciInstances(const char*, int, SymTabPtr, PciChipsets*, GDevPtr*, int, DriverPtr,int**); int xf86MatchIsaInstances(const char*, SymTabPtr, pointer*, DriverPtr, pointer, GDevPtr*, int, int**); void *xf86LoadDrvSubModule(DriverPtr drv, const char*); void xf86DrvMsg(int, int, const char*, ...); -pciConfigPtr *xf86GetPciConfigInfo(void); Bool xf86IsPrimaryPci(pcVideoPtr*); -Bool xf86CheckPciSlot(int bus, int device, int func); +Bool xf86CheckPciSlot( const struct pci_device * ); #endif extern char *loaderPath, **loaderList, **ploaderList; @@ -307,14 +305,12 @@ SYMFUNC(ErrorF) SYMFUNC(xf86PrintChipsets) SYMFUNC(xf86ErrorFVerb) - SYMFUNC(xf86GetPciVideoInfo) SYMFUNC(xf86MatchDevice) SYMFUNC(xf86MatchPciInstances) SYMFUNC(xf86MatchIsaInstances) SYMFUNC(Xfree) SYMFUNC(xf86LoadDrvSubModule) SYMFUNC(xf86DrvMsg) - SYMFUNC(xf86GetPciConfigInfo) SYMFUNC(xf86IsPrimaryPci) SYMFUNC(xf86CheckPciSlot) SYMFUNC(XNFalloc) @@ -608,17 +604,6 @@ chips = chipsets; } -_X_EXPORT pciVideoPtr * -xf86GetPciVideoInfo(void) -{ - static pciVideoRec pci_video; - static pciVideoPtr pci_video_ptr[2] = { &pci_video }; - - memset(&pci_video, 0, sizeof(pciVideoRec)); - - return (pci_video_ptr); -} - _X_EXPORT int xf86MatchDevice(const char *name, GDevPtr **gdev) { @@ -662,12 +647,6 @@ return (ret); } -_X_EXPORT pciConfigPtr * -xf86GetPciConfigInfo(void) -{ - return (NULL); -} - _X_EXPORT Bool xf86IsPrimaryPci(pciVideoPtr pPci) { @@ -675,8 +654,9 @@ } _X_EXPORT Bool -xf86CheckPciSlot(int bus, int device, int func) +xf86CheckPciSlot( const struct pci_device * d ) { + (void) d; return (False); } #endif Index: hw/xfree86/vgahw/vgaHW.c =================================================================== RCS file: /cvs/xorg/xserver/xorg/hw/xfree86/vgahw/vgaHW.c,v retrieving revision 1.10 diff -u -d -r1.10 vgaHW.c --- hw/xfree86/vgahw/vgaHW.c 10 Feb 2006 22:00:27 -0000 1.10 +++ hw/xfree86/vgahw/vgaHW.c 27 Apr 2006 17:26:49 -0000 @@ -31,6 +31,8 @@ #include "xf86cmap.h" +#include "Pci.h" + #ifndef SAVE_FONT1 #define SAVE_FONT1 1 #endif @@ -1637,7 +1639,7 @@ { vgaRegPtr regp; vgaHWPtr hwp; - pciVideoPtr pvp; + struct pci_device * pvp; int i; /* @@ -1724,7 +1726,8 @@ hwp->PIOOffset = scrp->domainIOBase; if ((pvp = xf86GetPciInfoForEntity(scrp->entityList[0]))) - hwp->Tag = pciTag(pvp->bus, pvp->device, pvp->func); + hwp->Tag = pciTag( PCI_MAKE_BUS( pvp->domain, pvp->bus ), + pvp->dev, pvp->func ); return TRUE; }