Read information from the common PCI configuration space registers


#include <pci/pci.h>

pci_err_t pci_device_read_ccode( pci_bdf_t bdf, pci_ccode_t *ccode );

pci_err_t pci_device_read_clsize( pci_bdf_t bdf, pci_clsize_t *cache_linesz );

pci_err_t pci_device_read_cmd( pci_bdf_t bdf, pci_cmd_t *cmd);

pci_err_t pci_device_read_did( pci_bdf_t bdf, pci_did_t *did);

pci_err_t pci_device_read_hdrType( pci_bdf_t bdf, pci_hdrType_t *hdrType);

pci_err_t pci_device_read_latency( pci_bdf_t bdf, pci_latency_t *latency);

pci_err_t pci_device_read_revid( pci_bdf_t bdf, pci_revid_t *revid);

pci_err_t pci_device_read_ssid( pci_bdf_t bdf, pci_ssid_t *ssid);

pci_err_t pci_device_read_ssvid( pci_bdf_t bdf, pci_ssvid_t *ssvid);

pci_err_t pci_device_read_status( pci_bdf_t bdf, pci_stat_t *status);

pci_err_t pci_device_read_vid( pci_bdf_t bdf, pci_vid_t *vid);


The Bus/Device/Function associated with a device.
Additional argument
A pointer to a location where the function can store the information read.



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


The pci_device_read_*() functions provide read access to the common PCI configuration space registers identified by their names. The register contents are returned in the provided storage.

Register Description Data type
CCODE Class and subclass code; see pci_device_find() pci_ccode_t
CLSIZE Cache line size pci_clsize_t
CMD Command: a bitmask of features that can be individually enabled and disabled pci_cmd_t
DID Device ID pci_did_t
HDRTYPE Header type, which indicates the layout of the remaining header data pci_hdrType_t
LATENCY Latency timer pci_latency_t
REVID Revision ID pci_revid_t
SSID Subsystem ID pci_ssid_t
SSVID Subsystem vendor ID pci_ssvid_t
STATUS Status information for PCI bus-related events pci_stat_t
VID Vendor ID pci_vid_t

All functions return a pci_err_t indicating success or failure. If the call is successful, the storage that you provided contains the requested value. If any error occurs, you should assume that this storage contains invalid data.

You don't need to attach to the device before using a pci_device_read_*() function that takes a pci_bdf_t parameter as its first argument to read a configuration space register. You can find the pci_bdf_t value for a specific device by calling pci_device_find().


PCI_ERR_OK on success; any other value indicates that an error occurred (you can use pci_strerror() to get the associated description).


QNX Neutrino

Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

pci_device_write_cmd(), pci_device_write_status()