mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 00:23:30 +00:00
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
30 lines
867 B
Bash
Executable file
30 lines
867 B
Bash
Executable file
#!/bin/sh
|
|
# show_dma_devices.sh - Identify DMA-capable devices on the lab host.
|
|
#
|
|
# Part of Chapter 21 Lab 1. Shows which PCI devices have bus-mastering
|
|
# enabled and are therefore actively using DMA.
|
|
|
|
set -e
|
|
|
|
echo "=== PCI devices with BUSMASTEREN set ==="
|
|
pciconf -lvc | awk '
|
|
/^[^ ]/ { dev = $1 }
|
|
/BUSMASTEREN/ { print dev }
|
|
' | sort -u
|
|
|
|
echo ""
|
|
echo "=== Bounce-buffer subsystem status ==="
|
|
sysctl -a | grep -E '^hw\.busdma\.' || echo "(no hw.busdma sysctls found)"
|
|
|
|
echo ""
|
|
echo "=== myfirst driver DMA state (if loaded) ==="
|
|
if sysctl -a | grep -q '^dev\.myfirst\.'; then
|
|
sysctl dev.myfirst. | grep -E 'dma_' || echo "(no dma_ sysctls; driver may be pre-Chapter-21)"
|
|
else
|
|
echo "(myfirst not loaded)"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Summary ==="
|
|
bm_count=$(pciconf -lvc | grep -c BUSMASTEREN || true)
|
|
echo "Devices with bus-mastering enabled: ${bm_count}"
|