FDD-book/examples/part-04/ch18-writing-pci-driver/labs/pci_dump_config.sh
Edson Brandi 6e6dac94fe Add book companion files under examples/
Organize companion code and materials by book part:

  part-01/      Foundations
  part-02/      Kernel & driver fundamentals
  part-03/      Character & block devices
  part-04/      Networking & storage
  part-05/      Buses & advanced topics
  part-06/      Debugging & performance
  part-07/      Real-world drivers
  appendices/   Supplementary material
  README.md     Overview and build instructions
2026-04-25 16:51:00 +00:00

23 lines
537 B
Bash
Executable file

#!/bin/sh
#
# pci_dump_config.sh -- dump the first 64 bytes of PCI configuration
# space for the named device in a readable 4-byte-per-row format.
#
# Usage: ./pci_dump_config.sh <selector>
#
# Example: ./pci_dump_config.sh myfirst0
# ./pci_dump_config.sh pci0:0:4:0
set -eu
SEL="${1:-myfirst0}"
printf 'PCI configuration space for %s:\n' "$SEL"
printf 'offset value\n'
off=0
while [ "$off" -lt 64 ]; do
printf '0x%02x %s\n' "$off" \
"$(pciconf -r "$SEL" "${off}:4" | tr -d ' \n')"
off=$((off + 4))
done