C2: migrate consumers off the runtime shim to direct concern-module imports

Every user binary and the two device-logic library modules (pci, usb) now
`@import` the concern modules directly instead of aliasing through `runtime`:

  runtime.ipc/process/time/service/input/block/display  -> @import("<module>")
  runtime.device / runtime.device_manager               -> @import("driver")
  runtime.fs                                             -> @import("file-system")
  runtime.Thread                                         -> @import("thread").Thread
  runtime.system.{write,writeRecord,klog*}              -> logging.*
  runtime.system.{sleep,timerOnce,wallClock,clock}     -> time.*
  runtime.system.{spawn*,kill,exit,yield,processes,...}-> process.*
  runtime.system.{mmap,munmap,PROT_*}                  -> memory.*
  runtime.dma.* / runtime.shared_memory.* / runtime.allocator -> memory.*

Each consumer keeps its own alias name (e.g. `const device = @import("driver")`),
so call sites are unchanged and there are no collisions with local `driver`
variables. build.zig now injects the concern modules into every user binary via
`default_imports`; pci/usb module import lists were updated to match.

The `runtime` and `system` shims remain for one more step (root.zig still uses
runtime); they are deleted in C5. Nothing but root.zig imports `runtime` now.

Verified: zig build, zig build test, and 17 QEMU cases (smoke, device-manager,
logger, fat-mount, fat-mutations, usb-storage, usb-hid, display-native,
virtio-gpu, input, thread-spawn, thread-mutex, process-kill, shared-memory,
driver-restart, acpi-ps2, pci-scan).
This commit is contained in:
Daniel Samson
2026-07-22 23:28:34 +01:00
parent dded46726b
commit 23bcd77c58
37 changed files with 783 additions and 692 deletions
+10 -9
View File
@@ -11,13 +11,14 @@
//! decoded hardware is a follow-up (see docs/input.md).
const std = @import("std");
const runtime = @import("runtime");
const input = runtime.input;
const system = runtime.system;
const input = @import("input");
const process = @import("process");
const time = @import("time");
const logging = @import("logging");
pub fn main(init: runtime.process.Init) void {
pub fn main(init: process.Init) void {
var source = input.connectSource() orelse {
_ = system.write("input-source: input service unavailable\n");
_ = logging.write("input-source: input service unavailable\n");
return;
};
@@ -26,7 +27,7 @@ pub fn main(init: runtime.process.Init) void {
// classes to exercise the service's per-device routing (the `input` test).
const mode = init.arguments.get(1) orelse "rotate";
if (std.mem.eql(u8, mode, "mouse")) {
_ = system.write("input-source: publishing synthetic mouse motion\n");
_ = logging.write("input-source: publishing synthetic mouse motion\n");
while (true) {
_ = source.publishMouseEvent(.{
.kind = @intFromEnum(input.MouseEventKind.motion),
@@ -37,11 +38,11 @@ pub fn main(init: runtime.process.Init) void {
.scroll_y = 0,
.buttons = 0,
});
system.sleep(20); // ~50 events/sec: moves the cursor briskly
time.sleepMillis(20); // ~50 events/sec: moves the cursor briskly
}
}
_ = system.write("input-source: publishing synthetic input events\n");
_ = logging.write("input-source: publishing synthetic input events\n");
var step: usize = 0;
while (true) : (step +%= 1) {
// Rotate across the device classes so every publish path (and the service's
@@ -51,6 +52,6 @@ pub fn main(init: runtime.process.Init) void {
1 => _ = source.publishMouseEvent(input.syntheticMouseEvent(step)),
else => _ = source.publishJoystickEvent(input.syntheticJoystickEvent(step)),
}
system.sleep(200);
time.sleepMillis(200);
}
}