diff --git a/build.zig b/build.zig index 1db227b..7fd9782 100644 --- a/build.zig +++ b/build.zig @@ -420,11 +420,11 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("library/protocol/scanout/scanout-protocol.zig"), }); - // The power protocol: system power's domain-named surface (docs/power.md). + // The power protocol: system power's domain-named surface (docs/power.md). No runtime + // client speaks it — imported directly by init and the acpi discovery service. const power_protocol_module = b.addModule("power-protocol", .{ - .root_source_file = b.path("system/services/power/protocol.zig"), + .root_source_file = b.path("library/protocol/power/power-protocol.zig"), }); - runtime_module.addImport("power-protocol", power_protocol_module); // Typed volatile MMIO register access + memory-ordering barriers, for drivers on // top of an mmio_map grant. Depends only on `builtin` (arch-conditional barriers); @@ -530,6 +530,7 @@ pub fn build(b: *std.Build) void { // linked into the kernel's user region against the `runtime` runtime library, and // started in ring 3 by the kernel's user-ELF loader. const init_exe = addUserBinary(b, kernel_target, runtime_module, mmio_module, xkeyboard_config_module, acpi_ids_module, "init", "system/services/init/init.zig"); + programModule(init_exe).addImport("power-protocol", power_protocol_module); // init reads the same `serial` flag the kernel does: its liveness heartbeat is a // serial/test-build diagnostic (the QEMU harness's init tests assert on it, and // -Dserial images emit it), so a flashable image runs a purely event-driven PID 1 @@ -618,6 +619,7 @@ 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); + if (discovery == .acpi) programModule(discovery_exe).addImport("power-protocol", power_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); diff --git a/system/services/power/protocol.zig b/library/protocol/power/power-protocol.zig similarity index 100% rename from system/services/power/protocol.zig rename to library/protocol/power/power-protocol.zig diff --git a/library/runtime/runtime.zig b/library/runtime/runtime.zig index effe046..b8336cc 100644 --- a/library/runtime/runtime.zig +++ b/library/runtime/runtime.zig @@ -24,9 +24,6 @@ pub const start = @import("start.zig"); /// 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). -pub const power_protocol = @import("power-protocol"); /// Keyboard-event listening (subscribe/next) and broadcasting (publish), over the input /// service. See library/runtime/input.zig and system/services/input/. pub const input = @import("input.zig"); diff --git a/system/services/acpi/acpi.zig b/system/services/acpi/acpi.zig index 7428ee9..4097573 100644 --- a/system/services/acpi/acpi.zig +++ b/system/services/acpi/acpi.zig @@ -16,7 +16,7 @@ const aml = @import("aml"); const acpi_ids = @import("acpi-ids"); const device = runtime.device; const protocol = @import("device-manager-protocol"); -const power = runtime.power_protocol; +const power = @import("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). const opcodes = aml.opcodes; diff --git a/system/services/init/init.zig b/system/services/init/init.zig index 137b1fe..5082439 100644 --- a/system/services/init/init.zig +++ b/system/services/init/init.zig @@ -19,7 +19,7 @@ const std = @import("std"); const runtime = @import("runtime"); -const power = runtime.power_protocol; +const power = @import("power-protocol"); const build_options = @import("build_options"); /// The system services init brings up at boot, in order, by binary path. This is