Conghao97's picture tcftrees's picture
ProgramGen release
d086025
|
Raw History Blame Contribute Delete
942 Bytes

Example Commands

cmd/test_pci_walk

test_pci_walk is the repository's example command-line tool. It uses pkg/hwapi (via hwapi.GetAPI()) and demonstrates the PCI enumeration interface:

  • PCIEnumerateVisibleDevices(cb func(d PCIDevice) (abort bool)) error — walks all PCI devices visible to the host, invoking the callback for each device.
  • Per-device helpers such as PCIReadVendorID, PCIReadDeviceID, and PCIReadConfig8/16/32 read identification and configuration data.

Behavior

  • Input: none (no flags); the walk covers all PCI devices visible on the running system.
  • Output: information about each enumerated PCI device (vendor/device IDs and configuration data, as chosen by the example's callback).
  • Requires elevated privileges (root) on Linux, since PCI configuration space is accessed directly.

Build and run

go build -o test_pci_walk ./cmd/test_pci_walk
sudo ./test_pci_walk