implemented paging with Sv57
This commit is contained in:
parent
4341e1dce2
commit
31a0fd5202
4 changed files with 125 additions and 7 deletions
15
src/main.zig
15
src/main.zig
|
|
@ -40,11 +40,6 @@ export fn kmain(hartid: u64, fdt_ptr: *const anyopaque) callconv(.c) noreturn {
|
|||
|
||||
debug.print("booting hydra...\n", .{});
|
||||
|
||||
var reservations = fdt.memoryReservations();
|
||||
|
||||
while (reservations.next()) |reservation| {
|
||||
debug.print("0x{x}:0x{x}\n", .{reservation.address, reservation.size});
|
||||
}
|
||||
const memory = fdt.memory().?;
|
||||
var reg_iter = Fdt.parseReg(memory.getProperty("reg").?.data, root.addressCells(), root.sizeCells());
|
||||
const reg = reg_iter.next().?;
|
||||
|
|
@ -55,7 +50,15 @@ export fn kmain(hartid: u64, fdt_ptr: *const anyopaque) callconv(.c) noreturn {
|
|||
debug.print("memory allocator initialized.\n", .{});
|
||||
|
||||
const allocator = buddy.allocator();
|
||||
_ = allocator;
|
||||
|
||||
var table = isa.PageTable.init(allocator) catch { @panic("Unable to create page table.\n"); };
|
||||
table.identityMap(allocator, memory_end) catch {};
|
||||
table.map(allocator, @intFromPtr(console.mmio), @intFromPtr(console.mmio), .{.read = 1, .write = 1, .execute = 1}) catch {};
|
||||
isa.write_satp(.{
|
||||
.ppn = @as(u44, @intCast(@intFromPtr(table) >> 12)),
|
||||
.mode = .sv57,
|
||||
});
|
||||
debug.print("loaded kernel page table.\n", .{});
|
||||
|
||||
while (true) {
|
||||
asm volatile ("wfi");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue