pci

Probes all PCI devices listed in the sysfs /sys/bus/pci/devices/.

Function Arguments

Name

Type

Description

dir_path

str, None

(optional; default: None) The path used to search for device sysfs data. First all symlinks are resolved, to the the “real” path. Then iteratively search toward parent folder until the remaining path contains the relevent data fields.

Description

This function goes through /sys/bus/pci/devices/ to read attributes of each PCI device listed there. Each result should contain these fields:

  • device_path: Pathname of the sysfs directory.

  • class

  • vendor

  • device

  • revision_id

Examples

Let’s say the Chromebook has two PCI devices. One of which (at /sys/bus/pci/devices/0000:00:00.1) has the attributes:

  • class=0x010203

  • vendor=0x0123

  • device=0x4567

  • revision_id=01

And the other one (at /sys/bus/pci/devices/0000:00:01.1) has the attributes:

  • class=0x020406

  • vendor=0x0246

  • device=0x1357

  • revision_id=01

Then the probe statement:

{
  "eval": "pci"
}

will have the corresponding probed result:

[
  {
    "bus_type": "pci",
    "class": "0x010203",
    "vendor": "0x0123",
    "device": "0x4567",
    "revision_id": "0x01"
  },
  {
    "bus_type": "pci",
    "class": "0x020406",
    "vendor": "0x0246",
    "device": "0x1357",
    "revision_id": "0x01"
  }
]

To verify if the Chromebook has the PCI device which vendor is 0x0246, you can write a probe statement like:

{
  "eval": "pci",
  "expect": {
    "vendor": "0x0246"
  }
}

The corresponding probed result will be empty if and only if there’s no PCI device which vendor is 0x0246 found.

Another use case is that you can ask this function to parse a specific PCI device sysfs directly like

{
  "eval" "pci:/sys/bus/pci/devices/0000:00:01.1"
}