aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / net / tests / fixtures / dump_qemu_virtio_net_cfg.sh
| 1 | #!/bin/sh |
| 2 | # Re-dump the 256-byte PCI config space of a real QEMU virtio-net-pci device, |
| 3 | # with no guest: QEMU's qtest protocol reads the ECAM window directly while the |
| 4 | # CPU stays paused (-S). Recorded with QEMU 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18), |
| 5 | # machine "virt", device at 00:01.0, highmem ECAM base 0x4010000000. |
| 6 | # transitional: default on the virt root bus (device id 0x1000) |
| 7 | # modern: disable-legacy=on (device id 0x1041) |
| 8 | # Single instance, nice'd; refuses to start if another QEMU runs. |
| 9 | # Usage: sh dump_qemu_virtio_net_cfg.sh transitional|modern > out.cfg |
| 10 | set -eu |
| 11 | case "${1:-}" in |
| 12 | transitional) extra="" ;; |
| 13 | modern) extra=",disable-legacy=on" ;; |
| 14 | *) echo "usage: $0 transitional|modern" >&2; exit 2 ;; |
| 15 | esac |
| 16 | if pgrep -x 'qemu-system-.*' >/dev/null 2>&1 || pgrep -f '^qemu-system' >/dev/null 2>&1; then |
| 17 | echo "another QEMU is running; wait for it" >&2; exit 3 |
| 18 | fi |
| 19 | o=0 |
| 20 | cmds=$(while [ $o -lt 256 ]; do printf 'readl 0x%x\n' $((0x4010008000 + o)); o=$((o + 4)); done) |
| 21 | printf '%s\n' "$cmds" | |
| 22 | timeout 30 nice -n 19 qemu-system-aarch64 -machine virt -accel tcg -S -qtest stdio \ |
| 23 | -display none -nodefaults -netdev user,id=n0 \ |
| 24 | -device "virtio-net-pci,addr=1,netdev=n0$extra" 2>/dev/null | |
| 25 | grep '^OK 0x' | while read -r _ h; do |
| 26 | x=$((h)) |
| 27 | printf "$(printf '\\%03o\\%03o\\%03o\\%03o' $((x & 255)) $((x >> 8 & 255)) $((x >> 16 & 255)) $((x >> 24 & 255)))" |
| 28 | done |