73 static inline uint64_t
79 uint64_t vaddr = pt->
vnext;
88 uint64_t pml4te =
PML4E(addr);
89 uint64_t pdpte =
PDPTE(addr);
92 if (pml4t->
entry[pml4te] == 0)
103 uint64_t pml4te =
PML4E(addr);
104 uint64_t pdpte =
PDPTE(addr);
105 uint64_t pde =
PDE(addr);
108 if (pml4t->
entry[pml4te] == 0)
112 if (pdpt->
entry[pdpte] == 0)
123 uint64_t pml4te =
PML4E(addr);
124 uint64_t pdpte =
PDPTE(addr);
125 uint64_t pde =
PDE(addr);
126 uint64_t pte =
PTE(addr);
129 if (pml4t->
entry[pml4te] == 0)
133 if (pdpt->
entry[pdpte] == 0)
137 if (pdt->
entry[pde] == 0)
155 region->addr >= map->last_usable)
158 uint64_t addr = region->addr;
159 uint64_t term = region->addr + region->size;
163 while (addr < term) {
164 uint64_t remain = term - addr;
203 for (uint64_t r = 0; r < map->count; r++)
const pmap_t * pmap()
Return a pointer to the current physical memory map.
Physical memory map describing usable and reserved regions of physical memory.
static void map_region(pagetable_t *pt, const pmap_t *map, const pmapregion_t *region)
Map a region of memory into the kernel page table, using the largest page sizes possible.
static void create_small_page(pagetable_t *pt, uint64_t addr, uint32_t memtype)
Create a 4KiB page entry in the kernel page table.
static uint64_t get_pdflags(uint32_t memtype)
Return flags for large-page leaf entries in level 3 (PDPT) and level 2 (PDT) tables.
String and memory operations.
Kernel physical (and virtual) memory map.
void kmem_init(pagetable_t *pt)
Using the contents of the physical memory map, identity map all physical memory into the kernel's pag...
Marked as uncacheable, usually for I/O.
Reported usable by the BIOS.
Used for ACPI tables or code.
__forceinline void fatal()
uint64_t entry[PAGE_SIZE/sizeof(uint64_t)]
uint64_t proot
Physical address of root page table (PML4T) entry.
#define KMEM_KERNEL_PAGETABLE_SIZE
static uint64_t alloc_page(pagetable_t *pt)
Allocate the next available page in the kernel page table and return its virtual address.
Interrupt handling operations.
x86 CPU-specific function implementations.
#define KMEM_KERNEL_PAGETABLE
Reported (or inferred) to be reserved.
uint64_t vnext
Virtual address to use for table's next page.
void * memzero(void *dst, size_t num)
Fill a region of memory with zeroes.
static uint64_t get_ptflags(uint32_t memtype)
Return flags for entries in level 1 (PT) tables.
uint64_t vterm
Boundary of pages used to store the table.
uint64_t vroot
Virtual address of root page table (PML4T) entry.
static void create_large_page(pagetable_t *pt, uint64_t addr, uint32_t memtype)
Create a 2MiB page entry in the kernel page table.
#define KMEM_KERNEL_PAGETABLE_END
static void create_huge_page(pagetable_t *pt, uint64_t addr, uint32_t memtype)
Create a 1GiB page entry in the kernel page table.
Used for ACPI non-volatile storage.