61#define VMM_KERNEL_BINARY_MAX PML_HIGHER_HALF_END
62#define VMM_KERNEL_BINARY_MIN \
63 PML_INDEX_TO_ADDR(PML_INDEX_AMOUNT - 1, PML4)
65#define VMM_KERNEL_STACKS_MAX VMM_KERNEL_BINARY_MIN
66#define VMM_KERNEL_STACKS_MIN PML_INDEX_TO_ADDR(PML_INDEX_AMOUNT - 3, PML4)
68#define VMM_KERNEL_HEAP_MAX VMM_KERNEL_STACKS_MIN
69#define VMM_KERNEL_HEAP_MIN PML_INDEX_TO_ADDR(PML_INDEX_AMOUNT - 5, PML4)
71#define VMM_IDENTITY_MAPPED_MAX VMM_KERNEL_HEAP_MIN
72#define VMM_IDENTITY_MAPPED_MIN PML_HIGHER_HALF_START
74#define VMM_USER_SPACE_MAX PML_LOWER_HALF_END
75#define VMM_USER_SPACE_MIN (0x400000)
83#define VMM_IS_PAGE_ALIGNED(addr) (((uintptr_t)(addr) & (PAGE_SIZE - 1)) == 0)
102#define VMM_MAX_SHOOTDOWN_REQUESTS 16
void(* space_callback_func_t)(void *private)
Space callback function.
void vmm_cpu_ctx_init(vmm_cpu_ctx_t *ctx)
Initializes a per-CPU VMM context and performs per-CPU VMM initialization.
void vmm_shootdown_handler(interrupt_frame_t *frame, cpu_t *self)
TLB shootdown interrupt handler.
uint64_t vmm_unmap(space_t *space, void *virtAddr, uint64_t length)
Unmaps virtual memory from a given address space.
uint64_t vmm_protect(space_t *space, void *virtAddr, uint64_t length, pml_flags_t flags)
Changes memory protection flags for a virtual memory region in a given address space.
void vmm_init(const boot_memory_t *memory, const boot_gop_t *gop, const boot_kernel_t *kernel)
Initializes the Virtual Memory Manager.
void * vmm_alloc(space_t *space, void *virtAddr, uint64_t length, pml_flags_t pmlFlags, vmm_alloc_flags_t allocFlags)
Allocates and maps virtual memory in a given address space.
space_t * vmm_get_kernel_space(void)
Retrieves the kernel's address space.
#define VMM_MAX_SHOOTDOWN_REQUESTS
Maximum number of shootdown requests that can be queued per CPU.
void * vmm_map(space_t *space, void *virtAddr, void *physAddr, uint64_t length, pml_flags_t flags, space_callback_func_t func, void *private)
Maps physical memory to virtual memory in a given address space.
void vmm_unmap_bootloader_lower_half(thread_t *bootThread)
Unmaps the lower half of the address space after kernel initialization.
void vmm_map_bootloader_lower_half(thread_t *bootThread)
Maps the lower half of the address space to the boot thread during kernel initialization.
pml_flags_t vmm_prot_to_flags(prot_t prot)
Converts the user space memory protection flags to page table entry flags.
void * vmm_map_pages(space_t *space, void *virtAddr, void **pages, uint64_t pageAmount, pml_flags_t flags, space_callback_func_t func, void *private)
Maps an array of physical pages to virtual memory in a given address space.
vmm_alloc_flags_t
Flags for vmm_alloc().
@ VMM_ALLOC_FAIL_IF_MAPPED
If set and any page is already mapped, fail and set errno to EEXIST.
prot_t
Memory protection flags.
static thread_t bootThread
static uint64_t pageAmount
A entry in a doubly linked list.
A simple ticket lock implementation.
A entry in a page table without a specified address or callback ID.
Virtual address space structure.
Thread of execution structure.
space_t * currentSpace
Will only be accessed by the owner CPU, so no lock.
list_entry_t entry
Used by a space to know which CPUs are using it, protected by the space lock.