pci_device_cfg_rd*()

Read from the device-specific PCI configuration space registers

Synopsis:

#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);

Arguments:

bdf
The Bus/Device/Function associated with a device.
offset
The offset, in bytes, at which you want to start reading, aligned to the size of the value being read.
val
A pointer to a location where the function can store the value read.

Library:

libpci

Use the -l pci option to qcc to link against this library.

Description:

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().

Note: You should use these functions only if you can't obtain the corresponding information with an existing library or capability module API. Also check the capability module APIs defined in the <pci/cap_*.h> files.

Returns:

PCI_ERR_OK
Success.
PCI_ERR_EINVAL
The offset argument isn't within the device-specific configuration space range (between 0x40 and 0xFF for PCI devices, or between 0x40 and 0xFFF for PCIe devices), or the offset isn't aligned to the size of the requested read operation.

If any error occurs, you should assume that storage you provided contains invalid data.

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes