PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
vmm.c File Reference
#include <kernel/mem/vmm.h>
#include <kernel/cpu/cpu.h>
#include <kernel/cpu/regs.h>
#include <kernel/cpu/syscall.h>
#include <kernel/init/boot_info.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/mem/paging.h>
#include <kernel/mem/pmm.h>
#include <kernel/mem/space.h>
#include <kernel/proc/process.h>
#include <kernel/sched/sched.h>
#include <kernel/sched/thread.h>
#include <kernel/sync/lock.h>
#include <boot/boot_info.h>
#include <assert.h>
#include <errno.h>
#include <sys/math.h>
#include <sys/proc.h>
Include dependency graph for vmm.c:

Go to the source code of this file.

Functions

static void vmm_cpu_ctx_init_common (vmm_cpu_ctx_t *ctx)
 
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.
 
static void vmm_page_table_unmap_with_shootdown (space_t *space, void *virtAddr, uint64_t pageAmount)
 
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.
 
 SYSCALL_DEFINE (SYS_MUNMAP, void *, void *address, uint64_t length)
 
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.
 
 SYSCALL_DEFINE (SYS_MPROTECT, void *, void *address, uint64_t length, prot_t prot)
 

Variables

static space_t kernelSpace
 

Function Documentation

◆ vmm_cpu_ctx_init_common()

static void vmm_cpu_ctx_init_common ( vmm_cpu_ctx_t ctx)
static

Definition at line 26 of file vmm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vmm_page_table_unmap_with_shootdown()

static void vmm_page_table_unmap_with_shootdown ( space_t space,
void *  virtAddr,
uint64_t  pageAmount 
)
inlinestatic

Definition at line 156 of file vmm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSCALL_DEFINE() [1/2]

SYSCALL_DEFINE ( SYS_MUNMAP  ,
void *  ,
void *  address,
uint64_t  length 
)

Definition at line 382 of file vmm.c.

Here is the call graph for this function:

◆ SYSCALL_DEFINE() [2/2]

SYSCALL_DEFINE ( SYS_MPROTECT  ,
void *  ,
void *  address,
uint64_t  length,
prot_t  prot 
)

Definition at line 440 of file vmm.c.

Here is the call graph for this function:

Variable Documentation

◆ kernelSpace

space_t kernelSpace
static

Definition at line 24 of file vmm.c.