pci_device_cfg_wr*()

Write to the device-specific PCI configuration space registers

Synopsis:

#include <pci/pci.h>

pci_err_t pci_device_cfg_wr8( pci_devhdl_t hdl,
                              uint_t offset,
                              uint8_t val,
                              uint8_t *val_p );

pci_err_t pci_device_cfg_wr16( pci_devhdl_t hdl,
                               uint_t offset,
                               uint16_t val,
                               uint16_t *val_p );

pci_err_t pci_device_cfg_wr32( pci_devhdl_t hdl,
                               uint_t offset,
                               uint32_t val,
                               uint32_t *val_p );

pci_err_t pci_device_cfg_wr64( pci_devhdl_t hdl,
                               uint_t offset,
                               uint64_t val,
                               uint64_t *val_p );

Arguments:

hdl
The handle of the device, obtained by calling pci_device_attach().
offset
The offset at which you want to start writing.
val
The value that you want to write.
val_p
NULL, or a pointer to a location where the function can store the register's value after the writing is done.

Library:

libpci

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

Description:

The pci_device_cfg_wr*() functions provide write access to the device-specific PCI configuration space registers starting at offset 0x40 (64). The value to write is contained in val. If val_p isn't NULL, the location that it points to is set to the contents of the register after the write operation is completed (the register is read after the write). All functions return a pci_err_t indicating success or failure.

The pci_device_cfg_wr*() functions take a pci_devhdl_t parameter as their first argument, and therefore you must successfully attach to the device before you can write the specified configuration space register.

Returns:

PCI_ERR_OK
Success.
PCI_ERR_EINVAL
The following might have occurred:
  • 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 write operation.
  • You didn't successfully attach to the device.
PCI_ERR_ENODEV
The hdl argument doesn't refer to a valid device.

If any error occurs, you should assume that the storage pointed to by a non-NULL val_p contains invalid data.

Classification:

QNX Neutrino

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