[kernel] Use constants for known pml4e indices

There were a few lingering bugs due to places where 510/511 were
hard-coded as the kernel-space PML4 entries. These are now constants
defined in kernel_memory.h instead.

Tags: boot memory paging
This commit is contained in:
Justin C. Miller
2020-05-24 22:06:24 -07:00
parent cc9cde9bfe
commit 83b330bf2b
6 changed files with 57 additions and 87 deletions

View File

@@ -28,6 +28,15 @@ namespace memory {
/// Start of the kernel heap
constexpr uintptr_t heap_start = page_offset - kernel_max_heap;
/// First kernel space PML4 entry
constexpr unsigned pml4e_kernel = 256;
/// First offset-mapped space PML4 entry
constexpr unsigned pml4e_offset = 384;
/// Number of page_table entries
constexpr unsigned table_entries = 512;
/// Helper to determine if a physical address can be accessed
/// through the page_offset area.
inline bool page_mappable(uintptr_t a) { return (a & page_offset) == 0; }