summaryrefslogtreecommitdiffstats
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2003-06-22 02:26:17 +0000
committerjmg <jmg@FreeBSD.org>2003-06-22 02:26:17 +0000
commitee2d512823a307e30456534f1160f12239b021b3 (patch)
treeacd5bac6b1a0b5dcf00fb35b1c35472a7d7ba9a6 /sys/dev/pci
parent6bb0e5cb462431a2a86e4263d027ba8ad04eddc4 (diff)
downloadFreeBSD-src-ee2d512823a307e30456534f1160f12239b021b3.zip
FreeBSD-src-ee2d512823a307e30456534f1160f12239b021b3.tar.gz
use a REG macro that was already defined.
Reorder how the pci probing in handled. before adding devices, check to see if the slot is a multi-function device to see if we should probe all the functions. Original idea by: imp
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/pci.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index f50ab27..ba81428 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -334,7 +334,7 @@ pci_read_device(device_t pcib, int b, int s, int f, size_t size)
devlist_entry = NULL;
- if (PCIB_READ_CONFIG(pcib, b, s, f, PCIR_DEVVENDOR, 4) != -1) {
+ if (REG(PCIR_DEVVENDOR, 4) != -1) {
devlist_entry = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
if (devlist_entry == NULL)
return (NULL);
@@ -819,25 +819,32 @@ pci_add_resources(device_t pcib, device_t dev)
void
pci_add_children(device_t dev, int busno, size_t dinfo_size)
{
+#define REG(n, w) PCIB_READ_CONFIG(pcib, busno, s, f, n, w)
device_t pcib = device_get_parent(dev);
struct pci_devinfo *dinfo;
int maxslots;
int s, f, pcifunchigh;
+ u_int8_t hdrtype;
KASSERT(dinfo_size >= sizeof(struct pci_devinfo),
("dinfo_size too small"));
maxslots = PCIB_MAXSLOTS(pcib);
for (s = 0; s <= maxslots; s++) {
pcifunchigh = 0;
+ f = 0;
+ hdrtype = REG(PCIR_HEADERTYPE, 1);
+ if ((hdrtype & ~PCIM_MFDEV) > 2)
+ continue;
+ if (hdrtype & PCIM_MFDEV)
+ pcifunchigh = PCI_FUNCMAX;
for (f = 0; f <= pcifunchigh; f++) {
dinfo = pci_read_device(pcib, busno, s, f, dinfo_size);
if (dinfo != NULL) {
- if (dinfo->cfg.mfdev)
- pcifunchigh = PCI_FUNCMAX;
pci_add_child(dev, dinfo);
}
}
}
+#undef REG
}
void
OpenPOWER on IntegriCloud