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
@@ -4,11 +4,11 @@
//! is visible through the mapping — proving the two processes share the same physical pages
//! (not a copy). On success it prints `shared-memory: shared 4096 bytes ok`, the test's marker.
const runtime = @import("runtime");
const system = runtime.system;
const shared_memory = runtime.shared_memory;
const ipc = runtime.ipc;
const ipc = @import("ipc");
const service = @import("service");
const memory = @import("memory");
const logging = @import("logging");
const pattern_len = 4096;
/// The pattern the client writes — must match shared-memory-client.zig.
@@ -21,24 +21,24 @@ fn onMessage(message: []const u8, reply: []u8, sender: u32, capability: ?ipc.Han
_ = reply;
_ = sender;
const cap = capability orelse {
_ = system.write("shared-memory: shared FAILED (no capability)\n");
_ = logging.write("shared-memory: shared FAILED (no capability)\n");
return 0;
};
const ptr = shared_memory.map(cap) orelse {
_ = system.write("shared-memory: shared FAILED (map)\n");
const ptr = memory.sharedMap(cap) orelse {
_ = logging.write("shared-memory: shared FAILED (map)\n");
return 0;
};
var i: usize = 0;
while (i < pattern_len) : (i += 1) {
if (ptr[i] != expected(i)) {
_ = system.write("shared-memory: shared FAILED (mismatch)\n");
_ = logging.write("shared-memory: shared FAILED (mismatch)\n");
return 0;
}
}
_ = system.write("shared-memory: shared 4096 bytes ok\n");
_ = logging.write("shared-memory: shared 4096 bytes ok\n");
return 0; // empty reply — the client only needs the round trip to unblock
}
pub fn main() void {
runtime.service.run(64, .{ .service = .shared_memory_test, .on_message = onMessage });
service.run(64, .{ .service = .shared_memory_test, .on_message = onMessage });
}