PatchworkOS  c9fea19
A non-POSIX operating system.
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>
Include dependency graph for vmm.h:
This graph shows which files directly or indirectly include this file:

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_OVERWRITE = 0 << 0 , VMM_ALLOC_FAIL_IF_MAPPED = 1 << 0 }
 Flags for vmm_alloc(). More...
 

Functions

void vmm_init (void)
 Initializes the Virtual Memory Manager.
 
void vmm_kernel_space_load (void)
 Loads the kernel's address space into the current CPU.
 
void vmm_cpu_ctx_init (vmm_cpu_ctx_t *ctx)
 Initializes a per-CPU VMM context and performs per-CPU VMM initialization.
 
space_tvmm_kernel_space_get (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.
 
void * vmm_unmap (space_t *space, void *virtAddr, uint64_t length)
 Unmaps virtual memory from a given address space.
 
void * 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.