Initial batch of changes for PCI rework. All future changes will be

tracked individually.
This commit is contained in:
Ian Romanick 2006-06-07 14:09:02 -07:00
parent d00aa6b855
commit 46f55f5dea
38 changed files with 1039 additions and 3403 deletions

View File

@ -1032,6 +1032,10 @@ if test "x$XORG" = xyes -o "x$XGL" = xyes; then
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*)
if test "x$LNXAPM" = xyes; then
@ -1191,7 +1195,6 @@ if test "x$XORG" = xyes -o "x$XGL" = xyes; then
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
@ -1670,7 +1673,6 @@ hw/xfree86/os-support/usl/Makefile
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
@ -1685,8 +1687,6 @@ hw/xfree86/utils/cvt/Makefile
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

View File

@ -6,12 +6,12 @@ DOC_SUBDIR = doc
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

View File

@ -47,7 +47,7 @@ libinit_a_SOURCES = xf86Build.h xf86Init.c
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 \

View File

@ -37,6 +37,8 @@
#ifndef _XF86_H
#define _XF86_H
#include <pciaccess.h>
#include "xf86str.h"
#include "xf86Opt.h"
#include <X11/Xfuncproto.h>
@ -94,16 +96,13 @@ extern CARD32 xf86DummyVar3;
/* 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 xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
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 @@ int xf86GetNumEntityInstances(int entityIndex);
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 @@ resRange xf86GetSparse(unsigned long type, memType fixed_bits,
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 @@ DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
/* 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 */

View File

@ -176,7 +176,8 @@ xf86AutoConfig(void)
{
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 @@ xf86AutoConfig(void)
}
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 @@ xf86AutoConfig(void)
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 @@ xf86AutoConfig(void)
return FALSE;
}
}

View File

@ -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 @@ xf86AddRangesToList(resPtr list, resRange *pRange, int entityIndex)
void
xf86ResourceBrokerInit(void)
{
#if 0
resPtr resPci;
#endif
osRes = NULL;
@ -1417,8 +1420,12 @@ xf86ResourceBrokerInit(void)
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 @@ xf86GetResourcesImplicitly(int entityIndex)
case BUS_SBUS:
return NULL;
case BUS_PCI:
return GetImplicitPciResources(entityIndex);
return NULL;
case BUS_last:
return NULL;
}
@ -1888,31 +1895,32 @@ xf86RegisterResources(int entityIndex, resList list, unsigned long access)
}
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 @@ setAccess(EntityPtr pEnt, xf86State state)
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 @@ xf86PostProbe(void)
#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);

View File

@ -124,7 +124,7 @@ typedef struct x_BusAccRec {
struct {
int bus;
int primary_bus;
PCITAG acc;
struct pci_device * dev;
pciBridgesSave save;
} pci;
} busdep;

View File

@ -36,6 +36,8 @@
#include <fcntl.h>
#include <X11/X.h>
#include <X11/Xmd.h>
#include <pciaccess.h>
#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 @@ GDevPtr
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 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
/* 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 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
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 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
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 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
* 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);
@ -828,22 +831,20 @@ DoConfigure()
/* 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) {
@ -932,7 +933,7 @@ DoConfigure()
oldNumScreens = xf86NumScreens;
(*xf86DriverList[i]->Probe)(xf86DriverList[i], 0);
xf86CallDriverProbe( xf86DriverList[i], FALSE );
/* reorder */
k = screennum > 0 ? screennum : 1;
@ -960,7 +961,6 @@ DoConfigure()
}
}
}
xf86SetPciVideo(NULL,NONE);
}
xfree(driverProbed);
}

View File

@ -97,9 +97,7 @@ DoProbe()
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);

View File

@ -39,6 +39,7 @@
#include <stdlib.h>
#include <X11/X.h>
#include <X11/Xmd.h>
#include <pciaccess.h>
#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 @@ void DoScanPci(int argc, char **argv, int i)
* 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

View File

@ -40,6 +40,9 @@
#include <xorg-config.h>
#endif
#include <pciaccess.h>
#include "Pci.h"
#include <X11/X.h>
#include "os.h"
#include "servermd.h"
@ -1591,7 +1594,7 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
}
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 @@ struct Inst {
};
#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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
&& *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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
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 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
* 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);

View File

@ -1,5 +1,5 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.212 2004/01/27 01:31:45 dawes Exp $ */
/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Init.c,v 1.36 2006/06/01 18:47:01 daniels Exp $ */
/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Init.c,v 1.37 2006/06/01 19:37:53 ajax Exp $ */
/*
* Loosely based on code bearing the following copyright:
@ -114,13 +114,6 @@ extern void os2ServerVideoAccess();
void (*xf86OSPMClose)(void) = NULL;
#endif
#ifdef XFree86LOADER
static char *baseModules[] = {
"pcidata",
NULL
};
#endif
/* Common pixmap formats */
static PixmapFormatRec formats[MAXFORMATS] = {
@ -267,6 +260,53 @@ PostConfigInit(void)
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)
{
@ -372,11 +412,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
LoaderFreeDirList(list);
}
#endif
/* Force load mandatory base modules */
if (!xf86LoadModules(baseModules, NULL))
FatalError("Unable to load required base modules, Exiting...\n");
#endif
xf86OpenConsole();
@ -501,16 +536,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
|| 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 );
}
/*

View File

@ -37,6 +37,8 @@
#ifndef _XF86PRIV_H
#define _XF86PRIV_H
#include <pciaccess.h>
#include "xf86Privstr.h"
#include "propertyst.h"
@ -107,7 +109,7 @@ extern Bool xf86Resetting;
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,9 +156,6 @@ void xf86ClearEntityListForScreen(int scrnIndex);
void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
extern void xf86PostPreInit(void);
extern void xf86PostScreenInit(void);
extern memType getValidBIOSBase(PCITAG tag, int num);
extern memType getEmptyPciRange(PCITAG tag, int base_reg);
extern int pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag);
/* xf86Config.c */
@ -197,6 +196,7 @@ void xf86CloseLog(void);
Bool xf86LoadModules(char **list, pointer *optlist);
int xf86SetVerbosity(int verb);
int xf86SetLogVerbosity(int verb);
Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
/* xf86Io.c */

File diff suppressed because it is too large Load Diff

View File

@ -43,7 +43,7 @@ typedef struct {
} pciSave, *pciSavePtr;
typedef struct {
PCITAG tag;
struct pci_device * dev;
CARD32 ctrl;
} pciArg;
@ -69,6 +69,7 @@ typedef struct pciBusRec {
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 @@ typedef struct pciBusRec {
} 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 PciStateEnter(void);
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 */

View File

@ -44,6 +44,8 @@
#include "xf86Opt.h"
#include "xf86Pci.h"
#include <pciaccess.h>
/*
* memType is of the size of the addressable memory (machine size)
* usually unsigned long.
@ -301,6 +303,9 @@ typedef struct {
int refCount;
} DriverRec1;
struct _SymTabRec;
struct _PciChipsets;
typedef struct _DriverRec {
int driverVersion;
char * driverName;
@ -310,6 +315,10 @@ typedef struct _DriverRec {
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,29 +435,6 @@ typedef struct {
pointer extraOptions;
} IDevRec, *IDevPtr;
typedef struct {
int vendor;
int chipType;
int chipRev;
int subsysVendor;
int subsysCard;
int bus;
int device;
int func;
int class;
int subclass;
int interface;
memType memBase[6];
memType ioBase[6];
int size[6];
unsigned char type[6];
memType biosBase;
int biosSize;
pointer thisCard;
Bool validSize;
Bool validate;
} pciVideoRec, *pciVideoPtr;
typedef struct {
int frameX0;
int frameY0;
@ -731,7 +717,7 @@ typedef struct {
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 +1046,7 @@ typedef struct {
);
} DGAFunctionRec, *DGAFunctionPtr;
typedef struct {
typedef struct _SymTabRec {
int token; /* id of the token */
const char * name; /* token name */
} SymTabRec, *SymTabPtr;

View File

@ -2066,19 +2066,16 @@ DRIMoveBuffersHelper(
}
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;
}

View File

@ -36,6 +36,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _DRI_H_
#include <pciaccess.h>
#include "scrnintstr.h"
#include "xf86dri.h"
@ -338,7 +340,7 @@ extern void DRIMoveBuffersHelper(ScreenPtr pScreen,
int *ydir,
RegionPtr reg);
extern char *DRICreatePCIBusID(pciVideoPtr PciInfo);
extern char *DRICreatePCIBusID(const struct pci_device *PciInfo);
#define _DRI_H_

View File

@ -268,53 +268,99 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode)
/* -------------------------------------------------------------------- */
/* open correct framebuffer device */
/* try to find the framebuffer device for a given PCI device */
/**
* 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[256];
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;
/* There are two ways to that we can determine which fb device is
* associated with this PCI device. The more modern way is to look in
* the sysfs directory for the PCI device for a file named
* "graphics:fb*"
*/
for (i = 0; i < 8; i++) {
sprintf(filename,
"/sys/bus/pci/devices/%04x:%02x:%02x.%d/graphics:fb%d",
pPci->domain, pPci->bus, pPci->dev, pPci->func, i);
fd = open(filename, O_RDONLY, 0);
if (fd != -1) {
close(fd);
sprintf(filename, "/dev/fb%d", i);
fd = open(filename, O_RDWR, 0);
if (fd != -1) {
if (ioctl(fd, FBIOGET_FSCREENINFO, (void*) & fix) != -1) {
if (namep) {
*namep = xnfalloc(16);
strncpy(*namep,fix.id,16);
}
return fd;
}
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;
}
}
if (namep)
*namep = NULL;
xf86DrvMsg(-1, X_ERROR,
"Unable to find a valid framebuffer device\n");
return -1;
close(fd);
}
/* The other way is to examine the resources associated with each fb
* device and see if there is a match with the PCI device. This technique
* has some problems on certain mixed 64-bit / 32-bit architectures.
* There is a flaw in the fb_fix_screeninfo structure in that it only
* returns the low 32-bits of the address of the resources associated with
* a device. However, on a mixed architecture the base addresses of PCI
* devices, even for 32-bit applications, may be higher than 0x0f0000000.
*/
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++) {
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
@ -359,7 +405,7 @@ fbdev_open(int scrnIndex, char *dev, char** namep)
/* -------------------------------------------------------------------- */
Bool
fbdevHWProbe(pciVideoPtr pPci, char *device,char **namep)
fbdevHWProbe(struct pci_device * pPci, char *device,char **namep)
{
int fd;
@ -375,7 +421,7 @@ fbdevHWProbe(pciVideoPtr pPci, char *device,char **namep)
}
Bool
fbdevHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device)
fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device * pPci, char *device)
{
fbdevHWPtr fPtr;

View File

@ -6,6 +6,8 @@
#include "xf86str.h"
#include "colormapst.h"
#include <pciaccess.h>
#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */
#define FBDEVHW_PLANES 1 /* Non interleaved planes */
#define FBDEVHW_INTERLEAVED_PLANES 2 /* Interleaved planes */
@ -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);

View File

@ -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 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
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 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
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
@ -288,16 +292,18 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
vbiosMem = (char *)base + V_BIOS;
(void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
if (xf86ReadDomainMemory(pInt->Tag, V_BIOS, V_BIOS_SIZE, vbiosMem) <
V_BIOS_SIZE)
V_BIOS_SIZE) {
xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x0C0000.\n");
"Unable to retrieve all of segment 0x0C0000.\n");
}
else if ((((unsigned char *)vbiosMem)[0] == 0x55) &&
(((unsigned char *)vbiosMem)[1] == 0xAA) &&
(((unsigned char *)vbiosMem)[2] > 0x80))
if (xf86ReadDomainMemory(pInt->Tag, V_BIOS + V_BIOS_SIZE, V_BIOS_SIZE,
(unsigned char *)vbiosMem + V_BIOS_SIZE) < V_BIOS_SIZE)
xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x0D0000.\n");
(((unsigned char *)vbiosMem)[2] > 0x80)) {
if (xf86ReadDomainMemory(pInt->Tag, V_BIOS + V_BIOS_SIZE, V_BIOS_SIZE,
(unsigned char *)vbiosMem + V_BIOS_SIZE) < V_BIOS_SIZE)
xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x0D0000.\n");
}
/*
* If this adapter is the primary, use its post-init BIOS (if we can find

View File

@ -472,6 +472,8 @@ static CARD32 PciCfg1Addr = 0;
#define TAG(Cfg1Addr) (Cfg1Addr & 0xffff00)
#define OFFSET(Cfg1Addr) (Cfg1Addr & 0xff)
#define _BUS(x) (((x) >> 16) & 0x0ff)
#define _DEV(x) (((x) >> 8) & 0x0ff)
static int
pciCfg1in(CARD16 addr, CARD32 *val)
@ -481,7 +483,12 @@ pciCfg1in(CARD16 addr, CARD32 *val)
return 1;
}
if (addr == 0xCFC) {
*val = pciReadLong(TAG(PciCfg1Addr), OFFSET(PciCfg1Addr));
struct pci_device * dev = pci_device_find_by_slot(0,
_BUS(PciCfg1Addr),
_DEV(PciCfg1Addr),
0);
pci_device_cfg_read_u32(dev, val, OFFSET(PciCfg1Addr));
return 1;
}
return 0;
@ -495,7 +502,12 @@ pciCfg1out(CARD16 addr, CARD32 val)
return 1;
}
if (addr == 0xCFC) {
pciWriteLong(TAG(PciCfg1Addr), OFFSET(PciCfg1Addr), val);
struct pci_device * dev = pci_device_find_by_slot(0,
_BUS(PciCfg1Addr),
_DEV(PciCfg1Addr),
0);
pci_device_cfg_write_u32(dev, & val, OFFSET(PciCfg1Addr));
return 1;
}
return 0;
@ -504,7 +516,7 @@ pciCfg1out(CARD16 addr, CARD32 val)
static int
pciCfg1inw(CARD16 addr, CARD16 *val)
{
int offset, shift;
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
shift = (addr - 0xCF8) * 8;
@ -512,8 +524,13 @@ pciCfg1inw(CARD16 addr, CARD16 *val)
return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
*val = pciReadWord(TAG(PciCfg1Addr), OFFSET(PciCfg1Addr) + offset);
const unsigned offset = addr - 0xCFC;
struct pci_device * dev = pci_device_find_by_slot(0,
_BUS(PciCfg1Addr),
_DEV(PciCfg1Addr),
0);
pci_device_cfg_read_u16(dev, val, OFFSET(PciCfg1Addr) + offset);
return 1;
}
return 0;
@ -522,7 +539,7 @@ pciCfg1inw(CARD16 addr, CARD16 *val)
static int
pciCfg1outw(CARD16 addr, CARD16 val)
{
int offset, shift;
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
shift = (addr - 0xCF8) * 8;
@ -531,8 +548,13 @@ pciCfg1outw(CARD16 addr, CARD16 val)
return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
pciWriteWord(TAG(PciCfg1Addr), OFFSET(PciCfg1Addr) + offset, val);
const unsigned offset = addr - 0xCFC;
struct pci_device * dev = pci_device_find_by_slot(0,
_BUS(PciCfg1Addr),
_DEV(PciCfg1Addr),
0);
pci_device_cfg_write_u16(dev, & val, OFFSET(PciCfg1Addr) + offset);
return 1;
}
return 0;
@ -541,7 +563,7 @@ pciCfg1outw(CARD16 addr, CARD16 val)
static int
pciCfg1inb(CARD16 addr, CARD8 *val)
{
int offset, shift;
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
shift = (addr - 0xCF8) * 8;
@ -549,8 +571,13 @@ pciCfg1inb(CARD16 addr, CARD8 *val)
return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
*val = pciReadByte(TAG(PciCfg1Addr), OFFSET(PciCfg1Addr) + offset);
const unsigned offset = addr - 0xCFC;
struct pci_device * dev = pci_device_find_by_slot(0,
_BUS(PciCfg1Addr),
_DEV(PciCfg1Addr),
0);
pci_device_cfg_read_u8(dev, val, OFFSET(PciCfg1Addr) + offset);
return 1;
}
return 0;
@ -559,7 +586,7 @@ pciCfg1inb(CARD16 addr, CARD8 *val)
static int
pciCfg1outb(CARD16 addr, CARD8 val)
{
int offset, shift;
int shift;
if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
shift = (addr - 0xCF8) * 8;
@ -568,8 +595,13 @@ pciCfg1outb(CARD16 addr, CARD8 val)
return 1;
}
if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
offset = addr - 0xCFC;
pciWriteByte(TAG(PciCfg1Addr), OFFSET(PciCfg1Addr) + offset, val);
const unsigned offset = addr - 0xCFC;
struct pci_device * dev = pci_device_find_by_slot(0,
_BUS(PciCfg1Addr),
_DEV(PciCfg1Addr),
0);
pci_device_cfg_write_u8(dev, & val, OFFSET(PciCfg1Addr) + offset);
return 1;
}
return 0;

View File

@ -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 @@ mapPciRom(int pciEntity, unsigned char * address)
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 @@ mapPciRom(int pciEntity, unsigned char * address)
#endif
#endif
return length;
return pvp->rom_size;
}

View File

@ -24,8 +24,9 @@ static int int1A_handler(xf86Int10InfoPtr pInt);
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 @@ static int
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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
#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 @@ int1A_handler(xf86Int10InfoPtr pInt)
}
}
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 @@ pciSlotBX(pciVideoPtr pvp)
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;

View File

@ -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

View File

@ -49,8 +49,6 @@
* authorization from the copyright holder(s) and author(s).
*/
#define INCLUDE_DEPRECATED 1
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
@ -308,10 +306,7 @@ LOOKUP xfree86LookupTab[] = {
/* xf86Bus.c */
SYMFUNC(xf86CheckPciSlot)
SYMFUNC(xf86ClaimPciSlot)
SYMFUNC(xf86GetPciVideoInfo)
SYMFUNC(xf86GetPciEntity)
SYMFUNC(xf86GetPciConfigInfo)
SYMFUNC(xf86SetPciVideo)
SYMFUNC(xf86ClaimIsaSlot)
SYMFUNC(xf86ClaimFbSlot)
SYMFUNC(xf86ClaimNoSlot)
@ -342,20 +337,14 @@ LOOKUP xfree86LookupTab[] = {
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)
@ -729,21 +718,10 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86STimestamp)
#endif
SYMFUNC(pciFindFirst)
SYMFUNC(pciFindNext)
SYMFUNC(pciWriteByte)
SYMFUNC(pciWriteWord)
SYMFUNC(pciWriteLong)
SYMFUNC(pciReadByte)
SYMFUNC(pciReadWord)
SYMFUNC(pciReadLong)
SYMFUNC(pciSetBitsLong)
SYMFUNC(pciTag)
SYMFUNC(pciBusAddrToHostAddr)
SYMFUNC(pciHostAddrToBusAddr)
SYMFUNC(xf86MapPciMem)
SYMFUNC(xf86scanpci)
SYMFUNC(xf86ReadPciBIOS)
/* Loader functions */
SYMFUNC(LoaderDefaultFunc)

File diff suppressed because it is too large Load Diff

View File

@ -422,25 +422,10 @@ void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
CARD32 val);
CARD32 pciByteSwap(CARD32);
Bool pciMfDev(int, int);
ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
extern void pciSetOSBIOSPtr(int (*bios_fn)(PCITAG Tag, int basereg, unsigned char * buf, int len));
extern PCITAG (*pciFindFirstFP)(void);
extern PCITAG (*pciFindNextFP)(void);
extern CARD32 pciDevid;
extern CARD32 pciDevidMask;
extern int pciMaxBusNum;
extern int pciBusNum;
extern int pciDevNum;
extern int pciFuncNum;
extern PCITAG pciDeviceTag;
extern int xf86MaxPciDevs;
extern pciBusInfo_t *pciBusInfo[];
#endif /* _PCI_H */

View File

@ -229,9 +229,6 @@ axpPciInit()
pciNumBuses = bus + 1;
}
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
}
/*

View File

@ -125,8 +125,6 @@ freebsdPciInit()
pciNumBuses = 1;
pciBusInfo[0] = &freebsdPci0;
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
}
static CARD32

View File

@ -688,8 +688,6 @@ ix86PciInit()
/* Initialize pciBusInfo[] array and function pointers */
pciNumBuses = 1;
pciBusInfo[0] = &ix86Pci0;
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
/* Make sure that there is a PCI bus present. */
ix86PciSelectCfgmech();

View File

@ -73,7 +73,6 @@ static CARD8 linuxPciCfgReadByte(PCITAG tag, int off);
static void linuxPciCfgWriteByte(PCITAG tag, int off, CARD8 val);
static CARD16 linuxPciCfgReadWord(PCITAG tag, int off);
static void linuxPciCfgWriteWord(PCITAG tag, int off, CARD16 val);
static int linuxPciHandleBIOS(PCITAG Tag, int basereg, unsigned char *buf, int len);
static pciBusFuncs_t linuxFuncs0 = {
/* pciReadLong */ linuxPciCfgRead,
@ -123,10 +122,6 @@ linuxPciInit()
}
pciNumBuses = 1;
pciBusInfo[0] = &linuxPci0;
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
pciSetOSBIOSPtr(linuxPciHandleBIOS);
xf86MaxPciDevs = lnxPciInit();
}
static int
@ -458,9 +453,9 @@ linuxGetIOSize(PCITAG Tag)
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;
}
@ -486,9 +481,9 @@ linuxGetSizes(PCITAG Tag, unsigned long *io_size, unsigned long *mem_size)
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;
@ -907,44 +902,3 @@ xf86AccResFromOS(resPtr pRes)
}
#endif /* !INCLUDE_XF86_NO_DOMAIN */
int linuxPciHandleBIOS(PCITAG Tag, int basereg, unsigned char *buf, int len)
{
unsigned int dom, bus, dev, func;
unsigned int fd;
char file[256];
struct stat st;
int ret;
int sofar = 0;
dom = PCI_DOM_FROM_TAG(Tag);
bus = PCI_BUS_FROM_TAG(Tag);
dev = PCI_DEV_FROM_TAG(Tag);
func = PCI_FUNC_FROM_TAG(Tag);
sprintf(file, "/sys/bus/pci/devices/%04x:%02x:%02x.%1x/rom",
dom, bus, dev, func);
if (stat(file, &st) == 0)
{
if ((fd = open(file, O_RDWR)))
basereg = 0x0;
/* enable the ROM first */
write(fd, "1", 2);
lseek(fd, 0, SEEK_SET);
do {
/* copy the ROM until we hit Len, EOF or read error */
ret = read(fd, buf+sofar, len-sofar);
if (ret <= 0)
break;
sofar += ret;
} while (sofar < len);
write(fd, "0", 2);
close(fd);
if (sofar < len)
xf86MsgVerb(X_INFO, 3, "Attempted to read BIOS %dKB from %s: got %dKB\n", len/1024, file, sofar/1024);
return sofar;
}
return 0;
}

View File

@ -80,8 +80,6 @@ netbsdPciInit()
pciNumBuses = 1;
pciBusInfo[0] = &netbsdPci0;
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
/* use businfo to get the number of devs */
if (ioctl(devpci, PCI_IOC_BUSINFO, &pci_businfo) != 0)
FatalError("netbsdPciInit: not a PCI bus device");

View File

@ -651,7 +651,7 @@ typedef union pci_cfg_spc {
* Data structure returned by xf86scanpci including contents of
* PCI config space header
*/
typedef struct pci_device {
typedef struct {
PCITAG tag;
int busnum;
int devnum;
@ -661,6 +661,7 @@ typedef struct pci_device {
Bool minBasesize;
pointer businfo; /* pointer to secondary's bus info structure */
Bool fakeDevice; /* Device added by system chipset support */
struct pci_device * dev;
} pciDevice, *pciConfigPtr;
typedef enum {
@ -676,7 +677,7 @@ typedef enum {
#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
@ -753,26 +754,10 @@ typedef enum {
} PciBiosType;
/* Public PCI access functions */
void pciInit(void);
PCITAG pciFindFirst(CARD32 id, CARD32 mask);
PCITAG pciFindNext(void);
CARD32 pciReadLong(PCITAG tag, int offset);
CARD16 pciReadWord(PCITAG tag, int offset);
CARD8 pciReadByte(PCITAG tag, int offset);
void pciWriteLong(PCITAG tag, int offset, CARD32 val);
void pciWriteWord(PCITAG tag, int offset, CARD16 val);
void pciWriteByte(PCITAG tag, int offset, CARD8 val);
void pciSetBitsLong(PCITAG tag, int offset, CARD32 mask, CARD32 val);
void pciSetBitsByte(PCITAG tag, int offset, CARD8 mask, CARD8 val);
ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
ADDRESS pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
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);
pciConfigPtr xf86GetPciConfigFromTag(PCITAG Tag);

View File

@ -1074,13 +1074,13 @@ xf86PostScanZX1(void)
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 @@ xf86PostScanZX1(void)
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,

View File

@ -3,7 +3,5 @@ SUBDIRS = \
cvt \
ioport \
kbd_mode \
pcitweak \
scanpci \
xorgcfg \
xorgconfig

View File

@ -70,15 +70,13 @@ void xf86Msg(int, const char*, ...);
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 @@ LOOKUP xfree86LookupTab[] = {
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 @@ xf86PrintChipsets(const char *name, const char *msg, SymTabPtr chipsets)
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 @@ xf86LoadDrvSubModule(DriverPtr drv, const char *name)
return (ret);
}
_X_EXPORT pciConfigPtr *
xf86GetPciConfigInfo(void)
{
return (NULL);
}
_X_EXPORT Bool
xf86IsPrimaryPci(pciVideoPtr pPci)
{
@ -675,8 +654,9 @@ xf86IsPrimaryPci(pciVideoPtr pPci)
}
_X_EXPORT Bool
xf86CheckPciSlot(int bus, int device, int func)
xf86CheckPciSlot( const struct pci_device * d )
{
(void) d;
return (False);
}
#endif

View File

@ -31,6 +31,8 @@
#include "xf86cmap.h"
#include "Pci.h"
#ifndef SAVE_FONT1
#define SAVE_FONT1 1
#endif
@ -1637,7 +1639,7 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
{
vgaRegPtr regp;
vgaHWPtr hwp;
pciVideoPtr pvp;
struct pci_device * pvp;
int i;
/*
@ -1724,7 +1726,8 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
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;
}