Get the ID of the nth capability that a device supports
#include <pci/pci.h> pci_err_t pci_device_read_capid( pci_bdf_t bdf, pci_capid_t *capid, uint_t idx );
You can use pci_device_read_capid() and pci_device_find_capid() to identify which capabilities the device identified by bdf supports. The pci_device_read_capid() function obtains the capability ID for the nth capability (specified by idx and starting at 0) that the device identified by bdf supports.
The purpose of this function is to obtain the capability index for a capability that the software wishes to enable for the device. You'll use this index when you call pci_device_read_cap().
You can use pci_device_read_capid() to easily loop with an incrementing idx value and obtain the pci_capid_t at that index. If *capid is for a desired capability, you can then read the capability with pci_device_read_cap() and the current idx value.
If any error occurs, you should consider the contents of *capid to be invalid data.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |