When probing the PCI bars, make sure to only probe BARS (PPBs and PCB has

fewer bars than type 0 devices).
This commit is contained in:
matt 2011-03-02 21:57:40 +00:00
parent c1bec41104
commit 5469ac9d1c
1 changed files with 9 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pci.c,v 1.134 2011/02/27 18:10:25 jmcneill Exp $ */ /* $NetBSD: pci.c,v 1.135 2011/03/02 21:57:40 matt Exp $ */
/* /*
* Copyright (c) 1995, 1996, 1997, 1998 * Copyright (c) 1995, 1996, 1997, 1998
@ -36,7 +36,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.134 2011/02/27 18:10:25 jmcneill Exp $"); __KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.135 2011/03/02 21:57:40 matt Exp $");
#include "opt_pci.h" #include "opt_pci.h"
@ -272,7 +272,7 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag,
{ {
pci_chipset_tag_t pc = sc->sc_pc; pci_chipset_tag_t pc = sc->sc_pc;
struct pci_attach_args pa; struct pci_attach_args pa;
pcireg_t id, csr, class, intr, bhlcr, bar; pcireg_t id, csr, class, intr, bhlcr, bar, endbar;
int ret, pin, bus, device, function, i, width; int ret, pin, bus, device, function, i, width;
int locs[PCICF_NLOCS]; int locs[PCICF_NLOCS];
@ -301,7 +301,12 @@ pci_probe_device(struct pci_softc *sc, pcitag_t tag,
memset(sc->PCI_SC_DEVICESC(device, function).c_range, 0, memset(sc->PCI_SC_DEVICESC(device, function).c_range, 0,
sizeof(sc->PCI_SC_DEVICESC(device, function).c_range)); sizeof(sc->PCI_SC_DEVICESC(device, function).c_range));
i = 0; i = 0;
for (bar = PCI_MAPREG_START; bar < PCI_MAPREG_END; bar += width) { switch (PCI_HDRTYPE_TYPE(bhlcr)) {
case PCI_HDRTYPE_PPB: endbar = PCI_MAPREG_PPB_END; break;
case PCI_HDRTYPE_PCB: endbar = PCI_MAPREG_PCB_END; break;
default: endbar = PCI_MAPREG_END; break;
}
for (bar = PCI_MAPREG_START; bar < endbar; bar += width) {
struct pci_range *r; struct pci_range *r;
pcireg_t type; pcireg_t type;