PatchworkOS
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/smp.h>
#include <kernel/cpu/syscalls.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>

Go to the source code of this file.

Functions

static void vmm_cpu_ctx_init_common (vmm_cpu_ctx_t *ctx)
 
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.
 
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.
 
uint64_t vmm_unmap (space_t *space, void *virtAddr, uint64_t length)
 Unmaps virtual memory from a given address space.
 
 SYSCALL_DEFINE (SYS_MUNMAP, uint64_t, void *address, uint64_t length)
 
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.
 
 SYSCALL_DEFINE (SYS_MPROTECT, uint64_t, void *address, uint64_t length, prot_t prot)
 
void vmm_shootdown_handler (interrupt_frame_t *frame, cpu_t *self)
 TLB shootdown interrupt handler.
 

Variables

static space_t kernelSpace
 

Function Documentation

◆ SYSCALL_DEFINE() [1/2]

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

◆ SYSCALL_DEFINE() [2/2]

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

Definition at line 387 of file vmm.c.

References address, EFAULT, ERR, errno, sched_process(), process_t::space, space_check_access(), and vmm_unmap().

◆ vmm_cpu_ctx_init_common()

◆ vmm_page_table_unmap_with_shootdown()

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

Variable Documentation

◆ kernelSpace