Virtual memory manager.
More...
#include <stdint.h>
Go to the source code of this file.
|
| uint64_t | get_kernel_pml4_phys (void) |
| | Returns the physical address of the top-level table.
|
| void | vmm_init (void) |
| | Initialize the virtual memory manager and the kernel address space.
|
| void | vmm_add_region (uint64_t start, uint64_t end, uint64_t flags) |
| | Add a region to the kernel address space.
|
| 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.
|
| uint64_t | vmm_unmap (uint64_t pml4_phys, uint64_t virtual_address) |
| | Unmaps a virtual address in the given address space.
|
| bool | vmm_page_fault_handler (uint64_t fault_address, uint64_t error_code) |
| | Handles a page fault in the given address space (demand paging).
|
| void | invlpg (void *virt) |
| | Invalidate a virtual address in the given address space.
|
Virtual memory manager.
- Author
- Matheus Boscariol
- Since
- 29/11/2026
- Copyright
- (c) 2026 Matheus Boscariol. Licensed under GNU AGPL-3.0.
Definition in file vmm.h.
◆ VMM_TEST_BASE
| #define VMM_TEST_BASE 0xFFFFC00000000000ULL |
Definition at line 15 of file vmm.h.
◆ get_kernel_pml4_phys()
| uint64_t get_kernel_pml4_phys |
( |
void | | ) |
|
Returns the physical address of the top-level table.
- Returns
- The physical address of the top-level table
Definition at line 19 of file vmm.c.
◆ invlpg()
| void invlpg |
( |
void * | virt | ) |
|
|
inline |
Invalidate a virtual address in the given address space.
- Parameters
-
| virt | The virtual address to invalidate |
Definition at line 86 of file vmm.h.
◆ vmm_add_region()
| void vmm_add_region |
( |
uint64_t | start, |
|
|
uint64_t | end, |
|
|
uint64_t | flags ) |
Add a region to the kernel address space.
- Parameters
-
| start | The starting virtual address of the region (4 KiB aligned) |
| end | The ending virtual address of the region (4 KiB aligned) |
| flags | The PTE flags to use when a page of the region is mapped |
Definition at line 33 of file vmm.c.
◆ vmm_init()
Initialize the virtual memory manager and the kernel address space.
Definition at line 24 of file vmm.c.
◆ vmm_map()
| 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.
- Parameters
-
| pml4_phys | The physical address of the top-level table |
| virtual_address | The virtual address to map |
| physical_address | The physical address to map to |
| flags | The PTE flags to use when a page of the region is mapped |
- Returns
- The virtual address of the mapped page, or UINT64_MAX if mapping failed
Definition at line 47 of file vmm.c.
◆ vmm_page_fault_handler()
| bool vmm_page_fault_handler |
( |
uint64_t | fault_address, |
|
|
uint64_t | error_code ) |
Handles a page fault in the given address space (demand paging).
- Parameters
-
| fault_address | The virtual address that caused the page fault |
| error_code | The error code associated with the page fault |
- Returns
- True if the page fault was handled successfully, false otherwise
Definition at line 163 of file vmm.c.
◆ vmm_unmap()
| uint64_t vmm_unmap |
( |
uint64_t | pml4_phys, |
|
|
uint64_t | virtual_address ) |
Unmaps a virtual address in the given address space.
- Parameters
-
| pml4_phys | The physical address of the top-level table |
| virtual_address | The virtual address to unmap |
- Returns
- The physical address of the unmapped frame, or UINT64_MAX if unmapping failed
Definition at line 116 of file vmm.c.