changed debug messages on boot

This commit is contained in:
Lorenzo Torres 2026-04-17 08:47:28 +02:00
parent 62fefbc836
commit a76834b849

View file

@ -14,12 +14,11 @@ pub export fn kmain(hartid: u64, fdt_phys: usize, console_phys: usize, alloc_sta
const console = Console.initAt(@intCast(mem.physToMmioVirt(console_phys))); const console = Console.initAt(@intCast(mem.physToMmioVirt(console_phys)));
debug.init(console); debug.init(console);
debug.print("entered higher-half kernel.\n", .{}); debug.print("booting hydra...\n", .{});
const fdt = Fdt.parse(@ptrFromInt(mem.physToDirectMap(fdt_phys))) catch { const fdt = Fdt.parse(@ptrFromInt(mem.physToDirectMap(fdt_phys))) catch {
@panic("Unable to parse higher-half FDT.\n"); @panic("Unable to parse higher-half FDT.\n");
}; };
debug.print("fdt remapped at 0x{x}.\n", .{mem.physToDirectMap(fdt_phys)});
const root = fdt.root().?; const root = fdt.root().?;
const memory = fdt.memory().?; const memory = fdt.memory().?;
@ -27,19 +26,18 @@ pub export fn kmain(hartid: u64, fdt_phys: usize, console_phys: usize, alloc_sta
const reg = reg_iter.next().?; const reg = reg_iter.next().?;
const detected_memory_end = reg.address + reg.size; const detected_memory_end = reg.address + reg.size;
const memory_end = if (memory_end_hint != 0) @min(detected_memory_end, memory_end_hint) else detected_memory_end; const memory_end = if (memory_end_hint != 0) @min(detected_memory_end, memory_end_hint) else detected_memory_end;
debug.print("detected RAM end at 0x{x}.\n", .{memory_end}); debug.print("detected 0x{x} bytes of memory.\n", .{reg.size});
var buddy: mem.BuddyAllocator = .{}; var buddy: mem.BuddyAllocator = .{};
const alloc_start = mem.physToDirectMap(alloc_start_phys); const alloc_start = mem.physToDirectMap(alloc_start_phys);
buddy.init(@as([*]u8, @ptrFromInt(alloc_start))[0..memory_end - alloc_start_phys]); buddy.init(@as([*]u8, @ptrFromInt(alloc_start))[0..memory_end - alloc_start_phys]);
debug.print("direct map allocator initialized.\n", .{});
const allocator = buddy.allocator(); const allocator = buddy.allocator();
const mmu_type = fdt.mmuType(); const mmu_type = fdt.mmuType();
if (mmu_type != .bare) { if (mmu_type != .bare) {
var table = isa.PageTable.init(allocator) catch { var table = isa.PageTable.init(allocator) catch {
@panic("Unable to allocate higher-half page table.\n"); @panic("unable to allocate higher-half page table.\n");
}; };
const kernel_flags: isa.PageTable.EntryFlags = .{ const kernel_flags: isa.PageTable.EntryFlags = .{
@ -59,7 +57,7 @@ pub export fn kmain(hartid: u64, fdt_phys: usize, console_phys: usize, alloc_sta
mmu_type, mmu_type,
mem.PHYS_MAP_BASE, mem.PHYS_MAP_BASE,
) catch { ) catch {
@panic("Unable to map higher-half kernel image.\n"); @panic("unable to map higher-half kernel image.\n");
}; };
table.mapRange( table.mapRange(
@ -71,7 +69,7 @@ pub export fn kmain(hartid: u64, fdt_phys: usize, console_phys: usize, alloc_sta
mmu_type, mmu_type,
mem.PHYS_MAP_BASE, mem.PHYS_MAP_BASE,
) catch { ) catch {
@panic("Unable to map direct map window.\n"); @panic("unable to map direct map window.\n");
}; };
const console_page = std.mem.alignBackward(u64, @intCast(console_phys), mem.PAGE_SIZE); const console_page = std.mem.alignBackward(u64, @intCast(console_phys), mem.PAGE_SIZE);
@ -83,11 +81,10 @@ pub export fn kmain(hartid: u64, fdt_phys: usize, console_phys: usize, alloc_sta
mmu_type, mmu_type,
mem.PHYS_MAP_BASE, mem.PHYS_MAP_BASE,
) catch { ) catch {
@panic("Unable to map console MMIO.\n"); @panic("unable to map console MMIO.\n");
}; };
table.load(mmu_type, mem.PHYS_MAP_BASE); table.load(mmu_type, mem.PHYS_MAP_BASE);
debug.print("reloaded higher-half kernel page table.\n", .{});
} }
while (true) { while (true) {