Map HULK virtual address space

This commit is contained in:
Josh Holtrop 2022-03-18 23:04:09 -04:00
parent f27851def9
commit 6beb7da4cd

View File

@ -9,6 +9,8 @@ import hos.memory;
__gshared EFI_SYSTEM_TABLE * st;
__gshared BootInfo bootinfo;
__gshared UINTN memory_map_key;
extern extern(C) __gshared ubyte hulk_start;
extern extern(C) __gshared ubyte hulk_end;
private void wait_key()
{
@ -160,6 +162,18 @@ private void map(ulong source_page, ulong dest_page, PageTableEntry * pt_base)
}
}
private void map_hulk(PageTableEntry * pt_base)
{
ulong virt = HULK_VIRTUAL_START;
ulong phys = cast(ulong)&hulk_start;
while (phys < cast(ulong)&hulk_end)
{
map(virt, phys, pt_base);
virt += 4096u;
phys += 4096u;
}
}
private void build_page_tables()
{
PageTableEntry * pt_base = new_page_table();
@ -173,6 +187,7 @@ private void build_page_tables()
map(page_addr, page_addr, pt_base);
}
}
map_hulk(pt_base);
write_cr3(cast(ulong)pt_base);
}