[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

@@ -2,22 +2,22 @@
/// Definitions for loading the kernel into memory
#pragma once
#include <uefi/boot_services.h>
#include "kernel_args.h"
namespace boot {
namespace loader {
/// Structure to hold information about loaded binary image.
struct loaded_elf
{
void *data; ///< Start of the kernel in memory
uintptr_t vaddr; ///< Virtual address to map to
uintptr_t entrypoint; ///< (Virtual) address of the kernel entrypoint
};
/// Parse and load an ELF file in memory into a loaded image.
/// \arg data The start of the ELF file in memory
/// \arg size The size of the ELF file in memory
/// \returns A `loaded_elf` structure defining the loaded image
loaded_elf load(const void *data, size_t size, uefi::boot_services *bs);
/// \arg args The kernel args, used for modifying page tables
/// \returns A descriptor defining the loaded image
kernel::entrypoint load(
const void *data, size_t size,
kernel::args::header *args,
uefi::boot_services *bs);
} // namespace loader
} // namespace boot