gather kernel tunables into config.zig

max_cpus, max_tasks, kernel/IST stack sizes, and timer_hz move from scattered constants into one config module. root.zig goes back to being just the boot contract. Values unchanged; any can become a -D build option later.
This commit is contained in:
Daniel Samson
2026-07-08 16:26:36 +01:00
parent 1b47de5058
commit 7501bd1703
9 changed files with 56 additions and 21 deletions
+10
View File
@@ -61,6 +61,13 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/root.zig"),
});
// Kernel tunables (max_cpus, stack sizes, tick rate). A dependency-free module of
// compile-time constants, imported wherever a knob is read; keeps the trade-offs
// in one place instead of scattered across the tree. See src/config.zig.
const config_mod = b.addModule("config", .{
.root_source_file = b.path("src/config.zig"),
});
// Architecture-specific kernel code (CPU ops, entry, later GDT/IDT/paging).
// The generic kernel imports this as "arch" and never names x86_64, so a new
// architecture is a matter of pointing this module at a different directory.
@@ -68,6 +75,7 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/kernel/arch/x86_64/cpu.zig"),
.imports = &.{
.{ .name = "danos", .module = mod }, // paging uses the shared BootInfo/memory-map types
.{ .name = "config", .module = config_mod }, // max_cpus, ist_stack_size, timer_hz
},
});
// CPU-exception stubs — real assembly, since they need cross-symbol
@@ -86,6 +94,7 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/device/platform.zig"),
.imports = &.{
.{ .name = "danos", .module = mod }, // BootInfo (carries the ACPI RSDP)
.{ .name = "config", .module = config_mod }, // max_cpus (the discovery pool)
},
});
@@ -122,6 +131,7 @@ pub fn build(b: *std.Build) void {
.{ .name = "danos", .module = mod },
.{ .name = "arch", .module = arch_mod },
.{ .name = "platform", .module = platform_mod },
.{ .name = "config", .module = config_mod },
.{ .name = "build_options", .module = build_options_mod },
},
}),