if (pcr._base_class == PCI_CLASS_BRIDGE && pcr._sub_class == PCI_SUBCLASS_BRIDGE_PCI) { if (pcr._secondary_bus_number > 0) { pcibuses[pcinumbus++] = pcr._secondary_bus_number;
if (pcr._base_class == PCI_CLASS_BRIDGE) { if (pcr._sub_class == PCI_SUBCLASS_BRIDGE_PCI) { if (pcr._secondary_bus_number > 0) pcibuses[pcinumbus++] = pcr._secondary_bus_number; } else if (++hostbridges > 1) { pcibuses[pcinumbus] = pcinumbus; pcinumbus++;
xf86scanpci(int scrnIndex){    pciConfigRec pcr;    int pcibusidx, pcinumbus, pcibuses[16];    int idx = 0;    if (pci_devp[0])	return pci_devp;    pciEnableIO(scrnIndex);    /* Check for a PCI bus, and find the config type */    pcibusSetup();    if (pciConfigType == 0)	return (pciConfigPtr *)NULL;    pcibusidx = 0;    pcibuses[0] = 0;    pcinumbus = 1;    do {	for (pcr._cardnum = 0; pcr._cardnum < pciMaxDevice; pcr._cardnum++) {	    int maxfunc = 0;	    pciTagRec tag;	    pcr._bus = pcibuses[pcibusidx];	    if (pciMfDev(pcr._bus, pcr._cardnum))		maxfunc = 7;	    tag = pcibusTag(pcr._bus, pcr._cardnum, 0);	    for (pcr._func = 0; pcr._func <= maxfunc; pcr._func++) {		tag = pcibusFTag(tag, pcr._func);		pcr._device_vendor = pcibusRead(tag, PCI_ID_REG);		if (pcr._device_vendor == 0xffffffff)	/* nothing there */		    continue;		pcr._status_command = pcibusRead(tag, PCI_CMD_STAT_REG);		pcr._class_revision = pcibusRead(tag, PCI_CLASS_REG);		pcr._bist_header_latency_cache =			pcibusRead(tag, PCI_HEADER_MISC);		pcr._base0 = pcibusRead(tag, PCI_MAP_REG_START);		pcr._base1 = pcibusRead(tag, PCI_MAP_REG_START + 0x04);		pcr._base2 = pcibusRead(tag, PCI_MAP_REG_START + 0x08);		pcr._base3 = pcibusRead(tag, PCI_MAP_REG_START + 0x0c);		pcr._base4 = pcibusRead(tag, PCI_MAP_REG_START + 0x10);		pcr._base5 = pcibusRead(tag, PCI_MAP_REG_START + 0x14);		pcr.rsvd1  = pcibusRead(tag, PCI_MAP_REG_START + 0x18);		pcr.rsvd2  = pcibusRead(tag, PCI_MAP_REG_START + 0x1C);		pcr._baserom = pcibusRead(tag, PCI_MAP_ROM_REG);		pcr._max_min_ipin_iline = pcibusRead(tag, PCI_INTERRUPT_REG);		pcr._user_config = pcibusRead(tag, PCI_REG_USERCONFIG);		/* Check for PCI-PCI bridges */		if (pcr._base_class == PCI_CLASS_BRIDGE &&		    pcr._sub_class == PCI_SUBCLASS_BRIDGE_PCI) {		    if (pcr._secondary_bus_number > 0) {			pcibuses[pcinumbus++] = pcr._secondary_bus_number;		    }		}		if (idx >= MAX_PCI_DEVICES)		    continue;		if ((pci_devp[idx] = (pciConfigPtr)xalloc(sizeof(pciConfigRec)))		    == (pciConfigPtr)NULL) {		    pciDisableIO(scrnIndex);		    return (pciConfigPtr *)NULL;		}		memcpy(pci_devp[idx++], &pcr, sizeof(pciConfigRec));		pci_devp[idx] = (pciConfigPtr)NULL;		if (xf86Verbose > 1) {		    ErrorF("PCI: Bus 0x%x Card 0x%02x Func 0x%x ID 0x%04x,"			   "0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n",			   pcr._bus, pcr._cardnum, pcr._func, pcr._vendor,			   pcr._device, pcr._rev_id, pcr._base_class,			   pcr._sub_class);		}	    }	}    } while (++pcibusidx < pcinumbus);    pciDisableIO(scrnIndex);    return pci_devp;}