Move to multi arch support and added memory map

This commit is contained in:
2026-07-03 11:11:19 +01:00
parent c2435760c4
commit 628c4f6d57
11 changed files with 423 additions and 41 deletions
+14 -8
View File
@@ -1,5 +1,6 @@
const std = @import("std");
const danos = @import("danos");
const arch = @import("arch");
const console = @import("console.zig");
const BootInfo = danos.BootInfo;
@@ -33,15 +34,20 @@ fn kmain(boot_info: *const BootInfo) noreturn {
con.print(" pitch : {d} bytes\n", .{fb.pitch});
con.print(" format : {s}\n", .{@tagName(fb.format)});
con.print(" framebuffer: 0x{x:0>16}\n", .{fb.base});
// Summarise the physical memory the loader handed us. The array is danos's
// own MemoryRegion, so this is a plain slice — no firmware layout in sight.
const regions = @as([*]const danos.MemoryRegion, @ptrFromInt(boot_info.memory_map.regions))[0..boot_info.memory_map.len];
var usable_pages: u64 = 0;
for (regions) |r| {
if (r.kind == .usable) usable_pages += r.pages;
}
con.print(" mem regions: {d}\n", .{regions.len});
con.print(" usable RAM : {d} MiB\n", .{usable_pages * danos.page_size / (1024 * 1024)});
con.write("\nkernel initialised; nothing left to do, halting.\n");
hang();
}
/// Stop the CPU. `hlt` in a loop parks the core at near-zero power until the
/// next interrupt; we loop because `hlt` returns when one arrives.
fn hang() noreturn {
while (true) asm volatile ("hlt");
arch.halt();
}
/// Freestanding has no OS to receive a panic. Print it to the console (if it is
@@ -55,6 +61,6 @@ pub const panic = std.debug.FullPanic(struct {
con.write(msg);
con.write("\n");
}
hang();
arch.halt();
}
}.panic);