Decode ACPI _HID names in device discovery

The flat analog of pci-class for acpi_device nodes. ACPI has no class/subclass/prog-IF
taxonomy — a device's identity is its _HID string itself (PNP0303 *is* "PS/2
keyboard") — so this is a plain id -> name registry, not a hierarchical decoder.

New system/devices/acpi-ids.zig (module `acpi-ids`): the common standard PnP/ACPI
hardware IDs; vendor-specific ids (QEMU0002, etc.) have no registry name and print the
raw HID. Shared reference data like pci-class. The dump now names each _HID:

    KBD_ [acpi_device] hid=PNP0303 (PS/2 Keyboard)
    COM1 [acpi_device] hid=PNP0501 (16550A-compatible Serial Port)
    RTC_ [acpi_device] hid=PNP0B00 (Real-Time Clock (RTC))
    LNKA [acpi_device] hid=PNP0C0F (PCI Interrupt Link Device)
    FWCF [acpi_device] hid=QEMU0002          (vendor-specific: raw HID)

Host test covers known ids and the unknown/empty fallthrough. Suite 41/41 plus host
tests.
This commit is contained in:
Daniel Samson
2026-07-10 21:44:44 +01:00
parent d702d2e9ae
commit 2ab0d129a2
3 changed files with 84 additions and 3 deletions
+9 -3
View File
@@ -14,6 +14,7 @@
const std = @import("std");
const device_abi = @import("device-abi");
const pci_class = @import("pci-class");
const acpi_ids = @import("acpi-ids");
/// The hardware primitives a discovery backend needs but can't express portably.
/// The kernel injects an implementation (the architecture VMM + port I/O), so the device
@@ -190,9 +191,14 @@ fn dumpNode(device: *const Device, depth: usize, emit: *const fn ([]const u8) vo
var buffer: [200]u8 = undefined;
@memset(buffer[0..indent], ' ');
const body = if (device.hid_len != 0)
std.fmt.bufPrint(buffer[indent..], "{s} [{s}] hid={s}\n", .{ device.name(), @tagName(device.class), device.hid() }) catch return
else
const body = if (device.hid_len != 0) blk: {
// Decode the _HID to a human name when it's a known standard PnP/ACPI id.
const desc = acpi_ids.description(device.hid());
break :blk if (desc.len != 0)
std.fmt.bufPrint(buffer[indent..], "{s} [{s}] hid={s} ({s})\n", .{ device.name(), @tagName(device.class), device.hid(), desc }) catch return
else
std.fmt.bufPrint(buffer[indent..], "{s} [{s}] hid={s}\n", .{ device.name(), @tagName(device.class), device.hid() }) catch return;
} else
std.fmt.bufPrint(buffer[indent..], "{s} [{s}]\n", .{ device.name(), @tagName(device.class) }) catch return;
emit(buffer[0 .. indent + body.len]);