reorg: move device-manager-protocol to library/protocol + direct import

device-manager-protocol -> library/protocol/device-manager/. Its consumers
(pci-bus, usb-xhci-bus, the acpi discovery service, device-manager, device-list,
crash-test, and the not-yet-built intel-integrated display sub-driver) import the
module directly instead of through runtime.device_manager_protocol, which is
deleted. runtime.device_manager (the hello client) already imported the module
by name and is unchanged.

zig build + test green; device-manager, driver-restart, device-list, pci-scan pass.
This commit is contained in:
Daniel Samson
2026-07-22 20:59:43 +01:00
parent 07c901c18c
commit 9ef22d6e55
10 changed files with 17 additions and 11 deletions
+7 -1
View File
@@ -400,7 +400,7 @@ pub fn build(b: *std.Build) void {
// The device-manager protocol: hello + (M18.2) tree reports, exposed as its
// own module like the other protocol modules. Imported through the runtime.
const device_manager_protocol_module = b.addModule("device-manager-protocol", .{
.root_source_file = b.path("system/services/device-manager/device-manager-protocol.zig"),
.root_source_file = b.path("library/protocol/device-manager/device-manager-protocol.zig"),
});
runtime_module.addImport("device-manager-protocol", device_manager_protocol_module);
// The block protocol, so runtime.block (the block-device client) can speak it.
@@ -551,6 +551,7 @@ pub fn build(b: *std.Build) void {
const ps2_mouse_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "ps2-mouse", "system/drivers/ps2-bus/mouse.zig");
programModule(ps2_mouse_exe).addImport("input-protocol", input_protocol_module);
const usb_xhci_bus_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "usb-xhci-bus", "system/drivers/usb-xhci-bus/usb-xhci-bus.zig");
programModule(usb_xhci_bus_exe).addImport("device-manager-protocol", device_manager_protocol_module);
// The xHCI bus driver builds chapter-9 requests and decodes descriptors from
// usb-abi, and reports each interface's (class,subclass,protocol) identity via
// usb-ids.packTriple.
@@ -587,13 +588,16 @@ pub fn build(b: *std.Build) void {
const shared_memory_client_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "shared-memory-client", "system/services/shared-memory-client/shared-memory-client.zig");
const fat_test_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "fat-test", "system/services/fat/fat-test.zig");
const pci_bus_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "pci-bus", "system/drivers/pci-bus/pci-bus.zig");
programModule(pci_bus_exe).addImport("device-manager-protocol", device_manager_protocol_module);
// The PCI bus driver decodes each function's class triple to human names in its
// boot log (class/subclass/prog-IF), so pull in the shared pci-class reference.
programModule(pci_bus_exe).addImport("pci-class", pci_class_module);
// A test fixture, not a real driver: hellos to the device manager, then faults —
// what the driver-restart scenario drives the crash-loop cap with.
const crash_test_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "crash-test", "system/services/crash-test/crash-test.zig");
programModule(crash_test_exe).addImport("device-manager-protocol", device_manager_protocol_module);
const device_list_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "device-list", "system/services/device-list/device-list.zig");
programModule(device_list_exe).addImport("device-manager-protocol", device_manager_protocol_module);
// The discovery service: one swappable process per firmware
// (docs/discovery.md), bundled under the neutral ramdisk name
// "discovery" so the device manager never learns which firmware it is on.
@@ -609,9 +613,11 @@ pub fn build(b: *std.Build) void {
};
const discovery_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "discovery", discovery_source);
if (discovery == .acpi) programModule(discovery_exe).addImport("aml", aml_module);
if (discovery == .acpi) programModule(discovery_exe).addImport("device-manager-protocol", device_manager_protocol_module);
const device_manager_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "device-manager", "system/services/device-manager/device-manager.zig");
// Names the xHCI PCI class triple from the shared taxonomy instead of a bare 0x0C0330.
programModule(device_manager_exe).addImport("pci-class", pci_class_module);
programModule(device_manager_exe).addImport("device-manager-protocol", device_manager_protocol_module);
// The manager matches reported USB interfaces by their (class,subclass,protocol)
// triple (usbDriverForIdentity), built from the named usb-ids codes.
programModule(device_manager_exe).addImport("usb-ids", usb_ids_module);
+3 -3
View File
@@ -19,10 +19,10 @@ pub const heap = @import("heap.zig");
pub const ipc = @import("ipc.zig");
pub const start = @import("start.zig");
/// The device-manager protocol: hello + tree reports (docs/device-manager.md).
pub const device_manager_protocol = @import("device-manager-protocol");
/// Client for talking to the device manager (the hello handshake a supervised
/// driver owes at startup). See library/runtime/device-manager.zig.
/// driver owes at startup). See library/runtime/device-manager.zig. The wire
/// protocol itself is the library/protocol/device-manager module, imported
/// directly by drivers and services that speak it.
pub const device_manager = @import("device-manager.zig");
/// The power protocol: events (button, lid, battery) + shutdown (docs/power.md).
@@ -9,7 +9,7 @@ const system = runtime.system;
const ipc = runtime.ipc;
const display_protocol = runtime.display_protocol;
const scanout_protocol = runtime.scanout_protocol;
const device_manager_protocol = runtime.device_manager_protocol;
const device_manager_protocol = @import("device-manager-protocol");
var device_id: u64 = 0;
+1 -1
View File
@@ -12,7 +12,7 @@
const std = @import("std");
const runtime = @import("runtime");
const protocol = runtime.device_manager_protocol;
const protocol = @import("device-manager-protocol");
const device = runtime.device;
const pci_class = @import("pci-class");
+1 -1
View File
@@ -15,7 +15,7 @@
const std = @import("std");
const runtime = @import("runtime");
const protocol = runtime.device_manager_protocol;
const protocol = @import("device-manager-protocol");
const device = runtime.device;
const usb_ids = @import("usb-ids");
const usb_abi = @import("usb-abi");
+1 -1
View File
@@ -15,7 +15,7 @@ const runtime = @import("runtime");
const aml = @import("aml");
const acpi_ids = @import("acpi-ids");
const device = runtime.device;
const protocol = runtime.device_manager_protocol;
const protocol = @import("device-manager-protocol");
const power = runtime.power_protocol;
/// AML opcode/prefix bytes by name (`zero_opcode`, `byte_prefix`, …) — so the `_HID`
/// integer decode names the opcodes instead of bare 0x0A/0x0B/… (docs/coding-standards.md).
+1 -1
View File
@@ -8,7 +8,7 @@
const std = @import("std");
const runtime = @import("runtime");
const protocol = runtime.device_manager_protocol;
const protocol = @import("device-manager-protocol");
pub fn main(init: runtime.process.Init) void {
const argument = init.arguments.get(1) orelse return; // bare: stay silent
+1 -1
View File
@@ -6,7 +6,7 @@
const std = @import("std");
const runtime = @import("runtime");
const protocol = runtime.device_manager_protocol;
const protocol = @import("device-manager-protocol");
fn writeLine(comptime fmt: []const u8, arguments: anytype) void {
var line: [96]u8 = undefined;
@@ -20,7 +20,7 @@ const runtime = @import("runtime");
const acpi_ids = @import("acpi-ids");
const pci_class = @import("pci-class");
const usb_ids = @import("usb-ids");
const protocol = runtime.device_manager_protocol;
const protocol = @import("device-manager-protocol");
const device = runtime.device;
const system = runtime.system;