fix init: debug prefix

This commit is contained in:
Daniel Samson
2026-07-13 05:23:07 +01:00
parent 77a3ccd33d
commit 1ea48ed5d6
+9 -9
View File
@@ -1,5 +1,5 @@
//! /system/services/init — the first user-space program, PID 1. Built as its own
//! freestanding binary (see build.zig), shipped on the boot volume at /system/services/init,
//! /system/services/system/services/init: — the first user-space program, PID 1. Built as its own
//! freestanding binary (see build.zig), shipped on the boot volume at /system/services/system/services/init:,
//! loaded by the bootloader, and started in ring 3 as a scheduled process by the
//! kernel (system/kernel/process.zig). It links against the shared user runtime
//! library `runtime` and talks to the kernel only through `runtime`'s system_call wrappers.
@@ -13,9 +13,9 @@
const runtime = @import("runtime");
/// The system services init brings up at boot, in order. This is init's policy — the
/// The system services system/services/init: brings up at boot, in order. This is system/services/init:'s policy — the
/// microkernel keeps such choices in user space, not the kernel. Drivers are absent
/// on purpose: the device manager owns those. (A future init reads this from a
/// on purpose: the device manager owns those. (A future system/services/init: reads this from a
/// manifest under /system/services instead of a hardcoded list.)
const boot_services = [_][]const u8{ "vfs", "input", "device-manager" };
@@ -23,26 +23,26 @@ pub fn main() void {
// Prove the heap end to end: allocate through the runtime allocator (which
// mmaps pages from the kernel and carves them with the free list), write into
// that heap buffer (exercising the widened debug_write bounds check), and
// free it. A fault here would kill init before it heartbeats — so the init
// free it. A fault here would kill system/services/init: before it heartbeats — so the system/services/init:
// test doubles as the heap regression test. (C code links the same heap via
// the extern malloc/free symbols; Zig code uses this allocator.)
const gpa = runtime.allocator();
if (gpa.alloc(u8, 64)) |buffer| {
const message = "init: heap ok\n";
const message = "system/services/init:: heap ok\n";
@memcpy(buffer[0..message.len], message);
_ = runtime.system.write(buffer[0..message.len]);
gpa.free(buffer);
} else |_| {}
// Bring up the boot services. Best-effort and silent: each service announces its
// own readiness (`vfs: ready`, ...), and in an isolation test that runs init with
// no initial-ramdisk the spawns simply no-op rather than deranging the heartbeat.
// own readiness (`vfs: ready`, ...), and in an isolation test that runs system/services/init: with
// no system/services/init:ial-ramdisk the spawns simply no-op rather than deranging the heartbeat.
for (boot_services) |service| {
_ = runtime.system.spawn(service);
}
while (true) {
_ = runtime.system.write("init: heartbeat\n");
_ = runtime.system.write("system/services/init:: heartbeat\n");
runtime.system.sleep(1000);
}
}