diff --git a/ChangeLog b/ChangeLog index 019eb90a0..77a936667 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-06-05 Daniel Stone + + * 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 * acinclude.m4: @@ -58,7 +68,7 @@ * configure.ac: Bump to 1.1.99.2. - + * configure.ac: * hw/xfree86/os-support/bus/Pci.h: Add support for kFreeBSD systems. (Robert Millan, Aurelien Jarno) diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c index eeed8b00f..15006e179 100644 --- a/hw/xfree86/os-support/bus/Pci.c +++ b/hw/xfree86/os-support/bus/Pci.c @@ -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 diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h index 80e5fdb05..a91c6b27d 100644 --- a/hw/xfree86/os-support/bus/Pci.h +++ b/hw/xfree86/os-support/bus/Pci.h @@ -439,6 +439,8 @@ extern int pciDevNum; extern int pciFuncNum; extern PCITAG pciDeviceTag; +extern int xf86MaxPciDevs; + extern pciBusInfo_t *pciBusInfo[]; #endif /* _PCI_H */ diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c index 3e82f211b..0714c9cea 100644 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ b/hw/xfree86/os-support/bus/linuxPci.c @@ -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 diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c index 4a80786b6..72939f489 100644 --- a/hw/xfree86/os-support/linux/lnx_pci.c +++ b/hw/xfree86/os-support/linux/lnx_pci.c @@ -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]; @@ -42,6 +45,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); @@ -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; - }