OpenBSD manual page server

Manual Page Search Parameters

PCI_CONF_READ(9) Kernel Developer's Manual PCI_CONF_READ(9)

pci_make_tag, pci_decompose_tag, pci_conf_read, pci_conf_writePCI config space manipulation functions

#include <alpha/pci/pci_machdep.h>
#include <i386/pci/pci_machdep.h>
#include <powerpc/pci/pci_machdep.h>
#include <sgi/pci/pci_machdep.h>
#include <machine/pci_machdep.h>

pci_make_tag(pci_chipset_tag_t pc, int bus, int dev, int func);

pci_decompose_tag(pci_chipset_tag_t pc, pcitag_t tag, int *busp, int *devp, int *funcp);

pci_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg);

pci_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t val);

These functions provide a way to access PCI configuration space.

The following types are defined in the machine dependent include file <pci_machdep.h>.

a PCI chipset descriptor;
a PCI device tag;
a PCI register datum.

In order to access PCI configuration space, a device tag shall be made using pci_make_tag given the PCI chipset tag pc and the device specification in a tuple of bus, device, function. The PCI tag composition is a PCI chipset dependent operation although often as simple as a shift and logical OR combination.

The pci_decompose_tag provides a reverse operation. Once a tag is composed, it is possible to perform configuration space read and write with pci_conf_read and pci_conf_write, respectively. Access to PCI configuration space is only provided for whole pcireg_t items, which is usually a 32-bit integer. Access to non-existent PCI devices do not (or should not) generate any kinds of faults or interruptions and thus allow for an easy device scanning by cycling through all possible device and function numbers for a given bus.

Below is an overview of defined PCI configuration space registers for devices:

Vendor (lower word) and Product (higher word) identification (see /sys/dev/pci/pcidevs for a comprehensive list).
Commands and Status register.
PCI device's class and subclass IDs. See /sys/dev/pci/pcireg.h for PCI_CLASS_* and PCI_SUBCLASS_* definitions.
Specify (low byte to high): cache line size, PCI latency timer, header type, and BIST.
0x10 - 0x28
Base address registers for I/O and memory space mapped registers.
CardBus CIS register.
Similar to 0x00 register's definitions for a subsystem identification.
A pointer to the capabilities list. Each item is an offset in the configuration space itself.
Interrupt line and pin numbers.

cardbus(4), pci(4), pci_intr_map(9)

These functions first appeared in OpenBSD 1.2.

February 15, 2015 OpenBSD-6.9