FreeBSD/usr.sbin/pciconf/cap.c
/* Find offset of a specific extended capability.  Returns 0 on failure. */
Find offset of a specific extended capability.  Returns 0 on failure.
Find offset of a specific extended capability . Returns 0 on failure .
uint16_t
pcie_find_cap(int fd, struct pci_conf *p, uint16_t id)
{
	uint32_t ecap;
	uint16_t ptr;
	ptr = PCIR_EXTCAP;
	ecap = read_config(fd, &p->pc_sel, ptr, 4);
	if (ecap == 0xffffffff || ecap == 0)
		return (0);
	for (;;) {
		if (PCI_EXTCAP_ID(ecap) == id)
			return (ptr);
		ptr = PCI_EXTCAP_NEXTPTR(ecap);
		if (ptr == 0)
			break;
		ecap = read_config(fd, &p->pc_sel, ptr, 4);
	}
	return (0);
}
uint16_t pcie_find_cap ( int fd , struct pci_conf * p , uint16_t id ) { uint32_t ecap ; uint16_t ptr ; ptr = PCIR_EXTCAP ; ecap = read_config ( fd , & p -> pc_sel , ptr , 4 ) ; if ( ecap == 0xffffffff || ecap == 0 ) return ( 0 ) ; for ( ; ; ) { if ( PCI_EXTCAP_ID ( ecap ) == id ) return ( ptr ) ; ptr = PCI_EXTCAP_NEXTPTR ( ecap ) ; if ( ptr == 0 ) break ; ecap = read_config ( fd , & p -> pc_sel , ptr , 4 ) ; } return ( 0 ) ; }
Find offset of a specific extended capability.
Find offset of a specific extended capability .