reorg: decouple the microkernel from the device taxonomies

The kernel's only dependency on pci-class and acpi-ids was cosmetic: the
boot-time device-tree dump (DeviceTree.dump) decoded class codes and _HID
strings to human names. That is device decoding — a user-space concern in a
microkernel, and the last thing pinning two userspace taxonomies into the
kernel's compile.

dumpNode now prints raw values (the class tag, the raw _HID string, and the
packed PCI class code as hex); a user-space tool that owns the taxonomies
(the device manager already imports them) can pretty-print when wanted. The
pci-class / acpi-ids imports are dropped from device-model.zig and from the
platform module.

The kernel's sole remaining library/device/ import is now device-abi (pure
data — the device-model types the broker marshals across the syscall
boundary), the one intentional kernel->library crossing.

zig build + test green; smoke, discovery, acpi-parse, acpi-ps2 pass.
This commit is contained in:
Daniel Samson
2026-07-22 20:38:29 +01:00
parent 794a8b5782
commit f86f2987d5
2 changed files with 10 additions and 20 deletions
+10 -18
View File
@@ -13,8 +13,6 @@
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
@@ -189,30 +187,24 @@ fn firstOfClassIn(node: *Device, class: DeviceClass) ?*Device {
fn dumpNode(device: *const Device, depth: usize, emit: *const fn ([]const u8) void) void {
const indent = @min(depth * 2, 40);
// Raw values only. Decoding a _HID or a PCI class code to a human name is a
// user-space concern (the device manager owns those taxonomies); the
// microkernel's boot dump reports the tree structure and the raw ids, and
// does no device decoding of its own.
var buffer: [200]u8 = undefined;
@memset(buffer[0..indent], ' ');
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;
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
std.fmt.bufPrint(buffer[indent..], "{s} [{s}]\n", .{ device.name(), @tagName(device.class) }) catch return;
emit(buffer[0 .. indent + body.len]);
// For a PCI function, decode its class code — the (class / subclass / prog-IF)
// triple that says what it actually is, which the coarse `DeviceClass` can't.
// For a PCI function, print the raw packed class code (base/subclass/prog-IF).
if (device.ids.pci_class) |packed_code| {
const cc = pci_class.ClassCode.unpack(packed_code);
var cbuf: [200]u8 = undefined;
const pad = @min(indent + 2, 42);
@memset(cbuf[0..pad], ' ');
const pif = pci_class.progIfName(cc.base, cc.subclass, cc.prog_if);
const cline = if (pif.len != 0)
std.fmt.bufPrint(cbuf[pad..], "class 0x{x:0>2} ({s}) subclass 0x{x:0>2} ({s}) progif 0x{x:0>2} ({s})\n", .{ cc.base, pci_class.className(cc.base), cc.subclass, pci_class.subclassName(cc.base, cc.subclass), cc.prog_if, pif }) catch return
else
std.fmt.bufPrint(cbuf[pad..], "class 0x{x:0>2} ({s}) subclass 0x{x:0>2} ({s}) progif 0x{x:0>2}\n", .{ cc.base, pci_class.className(cc.base), cc.subclass, pci_class.subclassName(cc.base, cc.subclass), cc.prog_if }) catch return;
const cline = std.fmt.bufPrint(cbuf[pad..], "pci-class 0x{x:0>6}\n", .{packed_code}) catch return;
emit(cbuf[0 .. pad + cline.len]);
}