PatchworkOS
Loading...
Searching...
No Matches
vmm.h File Reference
#include <kernel/mem/paging_types.h>
#include <kernel/mem/space.h>
#include <kernel/sched/thread.h>
#include <boot/boot_info.h>
#include <sys/list.h>
#include <sys/proc.h>

Go to the source code of this file.

Data Structures

struct  vmm_shootdown_t
 TLB shootdown structure. More...
 
struct  vmm_cpu_ctx_t
 Per-CPU VMM context. More...
 

Macros

#define VMM_KERNEL_BINARY_MAX   PML_HIGHER_HALF_END
 The maximum address for the content of the kernel binary.
 
#define VMM_KERNEL_BINARY_MIN    PML_INDEX_TO_ADDR(PML_INDEX_AMOUNT - 1, PML4)
 The minimum address for the content of the kernel binary./*#end#*‍/.
 
#define VMM_KERNEL_STACKS_MAX   VMM_KERNEL_BINARY_MIN
 The maximum address for kernel stacks.
 
#define VMM_KERNEL_STACKS_MIN   PML_INDEX_TO_ADDR(PML_INDEX_AMOUNT - 3, PML4)
 The minimum address for kernel stacks.
 
#define VMM_KERNEL_HEAP_MAX   VMM_KERNEL_STACKS_MIN
 The maximum address for the kernel heap.
 
#define VMM_KERNEL_HEAP_MIN   PML_INDEX_TO_ADDR(PML_INDEX_AMOUNT - 5, PML4)
 The minimum address for the kernel heap.
 
#define VMM_IDENTITY_MAPPED_MAX   VMM_KERNEL_HEAP_MIN
 The maximum address for the identity mapped physical memory.
 
#define VMM_IDENTITY_MAPPED_MIN   PML_HIGHER_HALF_START
 The minimum address for the identity mapped physical memory.
 
#define VMM_USER_SPACE_MAX   PML_LOWER_HALF_END
 The maximum address for user space.
 
#define VMM_USER_SPACE_MIN   (0x400000)
 The minimum address for user space.
 
#define VMM_IS_PAGE_ALIGNED(addr)   (((uintptr_t)(addr) & (PAGE_SIZE - 1)) == 0)
 Check if an address is page aligned.
 
#define VMM_MAX_SHOOTDOWN_REQUESTS   16
 Maximum number of shootdown requests that can be queued per CPU.
 

Enumerations

enum  vmm_alloc_flags_t {
  VMM_ALLOC_NONE = 0x0 ,
  VMM_ALLOC_FAIL_IF_MAPPED = 0x1
}
 Flags for vmm_alloc(). More...
 

Functions

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_cpu_ctx_init (vmm_cpu_ctx_t *ctx)
 Initializes a per-CPU VMM context and performs per-CPU VMM 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.
 
void vmm_unmap_bootloader_lower_half (thread_t *bootThread)
 Unmaps the lower half of the address space after kernel initialization.
 
space_tvmm_get_kernel_space (void)
 Retrieves the kernel's address space.
 
pml_flags_t vmm_prot_to_flags (prot_t prot)
 Converts the user space memory protection flags to page table entry flags.
 
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.
 
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_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.
 
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_shootdown_handler (interrupt_frame_t *frame, cpu_t *self)
 TLB shootdown interrupt handler.