moving kernel code to kernel/

This commit is contained in:
2026-07-05 10:19:11 +01:00
parent 7c3cffb337
commit 6f6ccc8bc9
37 changed files with 63 additions and 61 deletions
+7 -7
View File
@@ -45,18 +45,18 @@ pub fn build(b: *std.Build) void {
// 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.
const arch_mod = b.addModule("arch", .{
.root_source_file = b.path("src/arch/x86_64/cpu.zig"),
.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
},
});
// CPU-exception stubs — real assembly, since they need cross-symbol
// jumps/calls that Zig inline asm can't express (see the file's header).
arch_mod.addAssemblyFile(b.path("src/arch/x86_64/isr.s"));
arch_mod.addAssemblyFile(b.path("src/kernel/arch/x86_64/isr.s"));
// Compile-time config the kernel reads as `@import("build_options")`. The
// QEMU test harness sets -Dtest-case=<name> to run one self-test at boot.
const test_case = b.option([]const u8, "test-case", "Kernel self-test case to run at boot (see src/tests.zig)");
const test_case = b.option([]const u8, "test-case", "Kernel self-test case to run at boot (see src/kernel/tests.zig)");
const build_options = b.addOptions();
build_options.addOption(?[]const u8, "test_case", test_case);
const build_options_mod = build_options.createModule();
@@ -72,9 +72,9 @@ pub fn build(b: *std.Build) void {
});
const exe = b.addExecutable(.{
.name = "danos",
.name = "kernel",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.root_source_file = b.path("src/kernel/main.zig"),
.target = kernel_target,
.optimize = optimize,
.code_model = .small, // kernel is linked in the low 2 GiB (see image_base)
@@ -90,7 +90,7 @@ pub fn build(b: *std.Build) void {
},
}),
});
exe.setLinkerScript(b.path("src/arch/x86_64/linker.ld"));
exe.setLinkerScript(b.path("src/kernel/arch/x86_64/linker.ld"));
exe.entry = .{ .symbol_name = "_start" };
// Physical address the bootloader loads the kernel to (identity-mapped under
// UEFI). Overrides Zig's default image base so the linker script's layout is
@@ -153,7 +153,7 @@ pub fn build(b: *std.Build) void {
.dest_dir = .{ .override = .{ .custom = "esp/EFI/BOOT" } },
});
// The bootloader loads the kernel by name from the volume root, so drop the
// kernel ELF at esp/danos.
// kernel ELF at esp/kernel.
const kernel_install = b.addInstallArtifact(exe, .{
.dest_dir = .{ .override = .{ .custom = "esp" } },
});