Read from the device-specific PCI configuration space registers
#include <pci/pci.h> pci_err_t pci_device_cfg_rd8( pci_bdf_t bdf, uint_t offset, uint8_t *val); pci_err_t pci_device_cfg_rd16( pci_bdf_t bdf, uint_t offset, uint16_t *val); pci_err_t pci_device_cfg_rd32( pci_bdf_t bdf, uint_t offset, uint32_t *val); pci_err_t pci_device_cfg_rd64( pci_bdf_t bdf, uint_t offset, uint64_t *val);
The pci_device_cfg_rd*() functions provide read access to the device-specific PCI configuration space registers starting at offset 0x40 (64). The register contents are returned in the memory that val points to. All functions return a pci_err_t indicating success or failure.
The pci_device_cfg_rd*() functions take a pci_bdf_t parameter as their first argument, so you don't need to attach to the device before reading the specified configuration space register. You can find the pci_bdf_t value for a specific device by calling pci_device_find().
If any error occurs, you should assume that storage you provided contains invalid data.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |