Rename the shared contract module danos -> system; QEMU logs to /var/log/system

The shared kernel<->user ABI contract (BootInformation, the SystemCall numbers,
DeviceDescriptor, page_size, ...) is now the `system` module at
system/system.zig, following the convention that a directory's root file takes
the directory's name.

One overlap to note: the runtime's syscall wrappers are already `runtime.system`,
so the single file that uses both the contract and those wrappers
(library/runtime/heap.zig) aliases the wrappers locally as `system_calls`. The
two are distinct (top-level `system` vs `runtime.system`); everywhere else the
contract is just `system`.

Also: the QEMU run's serial capture now lands in the FHS log location,
zig-out/var/log/system/serial0-<timestamp>.log — a stand-in for the kernel's own
logging system, which will eventually write there itself.

Suite 35/35 plus host tests green.
This commit is contained in:
Daniel Samson
2026-07-10 14:09:38 +01:00
parent 3d1de37d0e
commit d19a0ae38d
38 changed files with 202 additions and 198 deletions
+18 -14
View File
@@ -98,8 +98,8 @@ pub fn build(b: *std.Build) void {
// Shared handoff definitions (BootInformation, Framebuffer, ...). No target is set,
// so the module inherits the target of whichever binary imports it — the
// freestanding kernel or the UEFI bootloader.
const danos_module = b.addModule("danos", .{
.root_source_file = b.path("system/danos.zig"),
const system_module = b.addModule("system", .{
.root_source_file = b.path("system/system.zig"),
});
// Kernel tunables (maximum_cpus, stack sizes, tick rate). A dependency-free module of
@@ -115,7 +115,7 @@ pub fn build(b: *std.Build) void {
const architecture_module = b.addModule("architecture", .{
.root_source_file = b.path("system/kernel/architecture/x86_64/cpu.zig"),
.imports = &.{
.{ .name = "danos", .module = danos_module }, // paging uses the shared BootInformation/memory-map types
.{ .name = "system", .module = system_module }, // paging uses the shared BootInformation/memory-map types
.{ .name = "parameters", .module = parameters_module }, // maximum_cpus, ist_stack_size, timer_hz
},
});
@@ -134,7 +134,7 @@ pub fn build(b: *std.Build) void {
const platform_module = b.addModule("platform", .{
.root_source_file = b.path("system/devices/platform.zig"),
.imports = &.{
.{ .name = "danos", .module = danos_module }, // BootInformation (carries the ACPI RSDP)
.{ .name = "system", .module = system_module }, // BootInformation (carries the ACPI RSDP)
.{ .name = "parameters", .module = parameters_module }, // maximum_cpus (the discovery pool)
},
});
@@ -158,7 +158,7 @@ pub fn build(b: *std.Build) void {
const runtime_module = b.addModule("runtime", .{
.root_source_file = b.path("library/runtime/runtime.zig"),
.imports = &.{
.{ .name = "danos", .module = danos_module },
.{ .name = "system", .module = system_module },
.{ .name = "vfs-protocol", .module = vfs_protocol_module },
},
});
@@ -172,7 +172,7 @@ pub fn build(b: *std.Build) void {
.imports = &.{
.{ .name = "runtime", .module = runtime_module },
.{ .name = "vfs-protocol", .module = vfs_protocol_module },
.{ .name = "danos", .module = danos_module },
.{ .name = "system", .module = system_module },
},
});
@@ -212,7 +212,7 @@ pub fn build(b: *std.Build) void {
.stack_check = false, // stack-probe calls have no runtime to land in
.stack_protector = false,
.imports = &.{
.{ .name = "danos", .module = danos_module },
.{ .name = "system", .module = system_module },
.{ .name = "architecture", .module = architecture_module },
.{ .name = "platform", .module = platform_module },
.{ .name = "parameters", .module = parameters_module },
@@ -301,7 +301,7 @@ pub fn build(b: *std.Build) void {
}),
.optimize = optimize,
.imports = &.{
.{ .name = "danos", .module = danos_module },
.{ .name = "system", .module = system_module },
},
}),
});
@@ -372,14 +372,18 @@ pub fn build(b: *std.Build) void {
"-device",
"VGA,edid=on,xres=1280,yres=720",
});
// Always capture the guest's serial0 (the kernel's machine-readable log) to a
// timestamped file under zig-out, so each run leaves its own log behind.
const serial_log = b.fmt("{s}/run-x86-64-serial0-{s}.log", .{ b.install_path, timestamp(b) });
// Capture the guest's serial0 (danos's machine-readable log) to the FHS log
// location, /var/log/system — a stand-in for the kernel's own logging system,
// which will one day write here itself. One timestamped file per run.
const log_dir = b.fmt("{s}/var/log/system", .{b.install_path});
const make_log_dir = b.addSystemCommand(&.{ "mkdir", "-p", log_dir });
const serial_log = b.fmt("{s}/serial0-{s}.log", .{ log_dir, timestamp(b) });
run_efi.addArgs(&.{ "-serial", b.fmt("file:{s}", .{serial_log}) });
// The whole FHS zig-out must be installed before we mount it.
// The whole FHS zig-out must be installed (and the log dir created) before we mount it.
run_efi.step.dependOn(b.getInstallStep());
run_efi.step.dependOn(&make_log_dir.step);
const run_efi_step = b.step("run-x86-64", "Boot the x86-64 kernel in QEMU (UEFI/OVMF); serial0 is logged to zig-out/run-x86-64-serial0-<timestamp>.log");
const run_efi_step = b.step("run-x86-64", "Boot the x86-64 kernel in QEMU (UEFI/OVMF); serial0 is logged to zig-out/var/log/system/serial0-<timestamp>.log");
run_efi_step.dependOn(&run_efi.step);
// const run_cmd = b.addRunArtifact(exe);
@@ -396,7 +400,7 @@ pub fn build(b: *std.Build) void {
// here (compiled for the host rather than inheriting a freestanding target).
const mod_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("system/danos.zig"),
.root_source_file = b.path("system/system.zig"),
.target = target,
.optimize = optimize,
}),