From ee2d512823a307e30456534f1160f12239b021b3 Mon Sep 17 00:00:00 2001 From: jmg Date: Sun, 22 Jun 2003 02:26:17 +0000 Subject: 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 --- sys/dev/pci/pci.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'sys/dev/pci') 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 -- cgit v1.1