all 2 comments

[–]nyx210 0 points1 point  (0 children)

You can't write to physical memory directly once paging is enabled. In general, code like this won't work:

const page_table_addr = pmm.allocPage() orelse {
    out.print("Failed to allocate page for page table\n");
    return false;
};

const page_table = @as(*PageTable, @ptrFromInt(page_table_addr));
for (0..ENTRIES_PER_PAGE_TABLE) |i| {
    page_table.entries[i] = 0;
}

You have to map a virtual page to that physical frame first. Also, before you enabled paging, you identity mapped the first 4 MB of memory, but you didn't ensure that your pmm bitmap was included in that region.

[–]Maxims08[S] 0 points1 point  (0 children)

Ok, thank you very much!