diff --git a/build.zig b/build.zig index 74c8926..1ad55b0 100644 --- a/build.zig +++ b/build.zig @@ -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); diff --git a/system/services/device-manager/device-manager-protocol.zig b/library/protocol/device-manager/device-manager-protocol.zig similarity index 100% rename from system/services/device-manager/device-manager-protocol.zig rename to library/protocol/device-manager/device-manager-protocol.zig diff --git a/library/runtime/runtime.zig b/library/runtime/runtime.zig index 5476f6e..873ac2c 100644 --- a/library/runtime/runtime.zig +++ b/library/runtime/runtime.zig @@ -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). diff --git a/system/drivers/display/intel-integrated/intel-integrated.zig b/system/drivers/display/intel-integrated/intel-integrated.zig index 33f80e4..6ff23d2 100644 --- a/system/drivers/display/intel-integrated/intel-integrated.zig +++ b/system/drivers/display/intel-integrated/intel-integrated.zig @@ -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; diff --git a/system/drivers/pci-bus/pci-bus.zig b/system/drivers/pci-bus/pci-bus.zig index 5226d88..acfbb9d 100644 --- a/system/drivers/pci-bus/pci-bus.zig +++ b/system/drivers/pci-bus/pci-bus.zig @@ -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"); diff --git a/system/drivers/usb-xhci-bus/usb-xhci-bus.zig b/system/drivers/usb-xhci-bus/usb-xhci-bus.zig index b171f3e..277f954 100644 --- a/system/drivers/usb-xhci-bus/usb-xhci-bus.zig +++ b/system/drivers/usb-xhci-bus/usb-xhci-bus.zig @@ -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"); diff --git a/system/services/acpi/acpi.zig b/system/services/acpi/acpi.zig index f5993b0..7428ee9 100644 --- a/system/services/acpi/acpi.zig +++ b/system/services/acpi/acpi.zig @@ -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). diff --git a/system/services/crash-test/crash-test.zig b/system/services/crash-test/crash-test.zig index 17a0aba..b3f7bf1 100644 --- a/system/services/crash-test/crash-test.zig +++ b/system/services/crash-test/crash-test.zig @@ -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 diff --git a/system/services/device-list/device-list.zig b/system/services/device-list/device-list.zig index 3cef060..2a83eff 100644 --- a/system/services/device-list/device-list.zig +++ b/system/services/device-list/device-list.zig @@ -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; diff --git a/system/services/device-manager/device-manager.zig b/system/services/device-manager/device-manager.zig index fd4c000..8916d3a 100644 --- a/system/services/device-manager/device-manager.zig +++ b/system/services/device-manager/device-manager.zig @@ -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;