[boot] Set up initial page tables

Set up initial page tables for both the offset-mapped area and the
loaded kernel code and data.

* Got rid of the `loaded_elf` struct - the loader now runs after the
  initial PML4 is created and maps the ELF sections itself.
* Copied in the `page_table` and `page_table_indices` from the kernel,
  still need to clean this up and extract it into shared code.
* Added `page_table_cache` to the kernel args to pass along free pages
  that can be used for initial page tables.

Tags: paging
This commit is contained in:
Justin C. Miller
2020-05-17 22:03:44 -07:00
parent c9722a07f3
commit 4f4a35a7be
8 changed files with 263 additions and 67 deletions

View File

@@ -13,7 +13,6 @@ using mem_type = kernel::args::mem_type;
size_t fixup_pointer_index = 0;
void **fixup_pointers[64];
uint64_t *new_pml4 = 0;
static const wchar_t *memory_type_names[] = {
L"reserved memory type",
@@ -78,19 +77,6 @@ init_pointer_fixup(uefi::boot_services *bs, uefi::runtime_services *rs)
rs,
&event),
L"Error creating memory virtualization event");
// Reserve a page for our replacement PML4, plus some pages for the kernel to use
// as page tables while it gets started.
void *addr = nullptr;
try_or_raise(
bs->allocate_pages(
uefi::allocate_type::any_pages,
table_type,
64,
&addr),
L"Error allocating page table pages.");
new_pml4 = reinterpret_cast<uint64_t*>(addr);
}
void