Enable or disable a capability
#include <pci/pci.h> pci_err_t pci_device_cfg_cap_disable( pci_devhdl_t hdl, pci_reqType_t reqType, pci_cap_t cap); pci_err_t pci_device_cfg_cap_enable( pci_devhdl_t hdl, pci_reqType_t reqType, pci_cap_t cap);
These functions enable or disable the capability identified by cap for the device identified by hdl. You must have already attached to the device by successfully calling pci_device_attach(). You can obtain the device capability by calling pci_device_read_cap().
After calling pci_device_read_cap() and before calling pci_device_cfg_cap_enable(), you might be able to modify the capability, using capability-specific APIs. See the specific capability module for details.
The reqType argument indicates the desired level of compliance to the request:
When you're: | Use: |
---|---|
Enabling a capability | pci_reqType_e_MANDATORY, pci_reqType_e_ADVISORY, or pci_reqType_e_UNSPECIFIED |
Disabling a capability | pci_reqType_e_UNSPECIFIED, unless the specific capability module specifies otherwise |
For example, if you're enabling the MSI or MSI-X capability, you can select the desired number of IRQs to use by calling the capability-specific APIs for MSI or MSI-X. When you're enabling the capability for the device:
For an explanation of the difference between pci_reqType_e_ADVISORY and pci_reqType_e_UNSPECIFIED, see Capability ID 0x5 (MSI) and Capability ID 0x11 (MSI-X) in the Capability Modules and APIs appendix.
These functions can also return any of the errors documented for the specific capability being enabled or disabled.
The following internal errors are specifically related to internal resource availability and use, and are atypical:
If any error occurs, the capability for the device isn't changed.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |