File size: 942 Bytes
d086025 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # 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
```sh
go build -o test_pci_walk ./cmd/test_pci_walk
sudo ./test_pci_walk
```
|