10#ifndef KERNEl_MM_VMM_H
11#define KERNEl_MM_VMM_H
15#define VMM_TEST_BASE 0xFFFFC00000000000ULL
64uint64_t
vmm_map(uint64_t pml4_phys, uint64_t virtual_address, uint64_t physical_address, uint64_t
flags);
72uint64_t
vmm_unmap(uint64_t pml4_phys, uint64_t virtual_address);
88 asm volatile(
"invlpg (%0)" ::
"r"(virt) :
"memory");
Represents an address space.
uint64_t pml4_phys
physical address of the top-level table
uint64_t region_count
number of regions in the address space
struct vmm_region regions[8]
lazily mapped regions (demand paging)
Represents a virtual memory region.
uint64_t flags
PTE flags to use when a page of the region is mapped.
uint64_t end
one past the last byte (4 KiB aligned)
uint64_t start
first virtual address of the region (4 KiB aligned)
void vmm_init(void)
Initialize the virtual memory manager and the kernel address space.
uint64_t vmm_unmap(uint64_t pml4_phys, uint64_t virtual_address)
Unmaps a virtual address in the given address space.
void vmm_add_region(uint64_t start, uint64_t end, uint64_t flags)
Add a region to the kernel address space.
void invlpg(void *virt)
Invalidate a virtual address in the given address space.
uint64_t get_kernel_pml4_phys(void)
Returns the physical address of the top-level table.
bool vmm_page_fault_handler(uint64_t fault_address, uint64_t error_code)
Handles a page fault in the given address space (demand paging).
uint64_t vmm_map(uint64_t pml4_phys, uint64_t virtual_address, uint64_t physical_address, uint64_t flags)
Maps a virtual address to a physical address in the given address space.