FreeBSD/sys/dev/pci/pci.c
/*
 * Find the requested extended capability and return the offset in
 * configuration space via the pointer provided.  The function returns
 * 0 on success and an error code otherwise.
 */
Find the requested extended capability and return the offset in
configuration space via the pointer provided.  The function returns
0 on success and an error code otherwise.
Find the requested extended capability and return the offset in configuration space via the pointer provided . The function returns 0 on success and an error code otherwise .
int
pci_find_extcap_method(device_t dev, device_t child, int capability,
    int *capreg)
{
	struct pci_devinfo *dinfo = device_get_ivars(child);
	pcicfgregs *cfg = &dinfo->cfg;
	uint32_t ecap;
	uint16_t ptr;
	if (cfg->pcie.pcie_location == 0)
		return (ENXIO);
	ptr = PCIR_EXTCAP;
	ecap = pci_read_config(child, ptr, 4);
	if (ecap == 0xffffffff || ecap == 0)
		return (ENOENT);
	for (;;) {
		if (PCI_EXTCAP_ID(ecap) == capability) {
			if (capreg != NULL)
				*capreg = ptr;
			return (0);
		}
		ptr = PCI_EXTCAP_NEXTPTR(ecap);
		if (ptr == 0)
			break;
		ecap = pci_read_config(child, ptr, 4);
	}
	return (ENOENT);
}
int pci_find_extcap_method ( device_t dev , device_t child , int capability , int * capreg ) { struct pci_devinfo * dinfo = device_get_ivars ( child ) ; pcicfgregs * cfg = & dinfo -> cfg ; uint32_t ecap ; uint16_t ptr ; if ( cfg -> pcie . pcie_location == 0 ) return ( ENXIO ) ; ptr = PCIR_EXTCAP ; ecap = pci_read_config ( child , ptr , 4 ) ; if ( ecap == 0xffffffff || ecap == 0 ) return ( ENOENT ) ; for ( ; ; ) { if ( PCI_EXTCAP_ID ( ecap ) == capability ) { if ( capreg != NULL ) * capreg = ptr ; return ( 0 ) ; } ptr = PCI_EXTCAP_NEXTPTR ( ecap ) ; if ( ptr == 0 ) break ; ecap = pci_read_config ( child , ptr , 4 ) ; } return ( ENOENT ) ; }
Find the requested extended capability and return the offset in
 configuration space via the pointer provided.
Find the requested extended capability and return the offset in configuration space via the pointer provided .
/* Only supported for PCI-express devices. */