When we can, bound the maximum number of PCI devices to attempt to scan, by

the number found on the system. Only implemented for Linux right now.
This commit is contained in:
Daniel Stone 2006-06-05 20:22:06 +00:00
parent 11cf4d2fde
commit 8444bb77c9
5 changed files with 36 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2006-06-05 Daniel Stone <daniel@freedesktop.org>
* hw/xfree86/os-support/bus/Pci.c:
* hw/xfree86/os-support/bus/Pci.h:
* hw/xfree86/os-support/bus/linuxPci.c:
* hw/xfree86/os-support/linux/lnx_pci.c:
When we can, bound the maximum number of PCI devices to attempt to
scan, by the number found on the system. Only implemented for Linux
right now.
2006-06-05 Keith Packard <keithp@keithp.com>
* acinclude.m4:

View File

@ -238,6 +238,8 @@ static int readPciBios( PCITAG Tag, CARD8* tmp, ADDRESS hostbase,
static int (*pciOSHandleBIOS)(PCITAG Tag, int basereg, unsigned char *buf, int len);
int xf86MaxPciDevs = MAX_PCI_DEVICES;
/*
* Platform specific PCI function pointers.
*
@ -938,7 +940,7 @@ xf86scanpci(int flags)
xf86MsgVerb(X_INFO, 2, "PCI: PCI scan (all values are in hex)\n");
#endif
while (idx < MAX_PCI_DEVICES && tag != PCI_NOT_FOUND) {
while (idx < xf86MaxPciDevs && tag != PCI_NOT_FOUND) {
devp = xcalloc(1, sizeof(pciDevice));
if (!devp) {
xf86Msg(X_ERROR,
@ -1001,6 +1003,8 @@ xf86scanpci(int flags)
#endif
pci_devp[idx++] = devp;
if (idx == xf86MaxPciDevs)
break;
tag = pciFindNext();
#ifdef DEBUGPCI

View File

@ -439,6 +439,8 @@ extern int pciDevNum;
extern int pciFuncNum;
extern PCITAG pciDeviceTag;
extern int xf86MaxPciDevs;
extern pciBusInfo_t *pciBusInfo[];
#endif /* _PCI_H */

View File

@ -108,6 +108,9 @@ static pciBusInfo_t linuxPci0 = {
/* bridge */ NULL
};
/* from lnx_pci.c. */
extern int lnxPciInit(void);
void
linuxPciInit()
{
@ -123,6 +126,7 @@ linuxPciInit()
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
pciSetOSBIOSPtr(linuxPciHandleBIOS);
xf86MaxPciDevs = lnxPciInit();
}
static int

View File

@ -23,6 +23,8 @@
#define PCIADDR_FMT "%lx"
#endif
int lnxPciInit(void);
struct pci_dev {
unsigned int bus;
unsigned int devfn;
@ -32,6 +34,7 @@ struct pci_dev {
};
struct pci_dev *xf86OSLinuxPCIDevs = NULL;
int xf86OSLinuxNumPciDevs = 0;
static struct pci_dev *xf86OSLinuxGetPciDevs(void) {
char c[0x200];
@ -43,6 +46,8 @@ static struct pci_dev *xf86OSLinuxGetPciDevs(void) {
file = fopen("/proc/bus/pci/devices", "r");
if (!file) return NULL;
xf86OSLinuxNumPciDevs = 0;
do {
res = fgets(c, 0x1ff, file);
if (res) {
@ -78,12 +83,21 @@ static struct pci_dev *xf86OSLinuxGetPciDevs(void) {
tmp->next = ret;
}
ret = tmp;
xf86OSLinuxNumPciDevs++;
}
} while (res);
fclose(file);
return ret;
}
/* not to be confused with linuxPciInit (i.e. ARCH_PCI_INIT), found in
* os-support/bus/linuxPci.c. */
int lnxPciInit(void) {
if (!xf86OSLinuxPCIDevs)
xf86OSLinuxPCIDevs = xf86OSLinuxGetPciDevs();
return xf86OSLinuxNumPciDevs;
}
Bool
xf86GetPciSizeFromOS(PCITAG tag, int index, int* bits)
{
@ -198,5 +212,4 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base)
};
return 0;
}