|
PatchworkOS
|
#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_t * | vmm_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 |
| SYSCALL_DEFINE | ( | SYS_MPROTECT | , |
| uint64_t | , | ||
| void * | address, | ||
| uint64_t | length, | ||
| prot_t | prot | ||
| ) |
Definition at line 445 of file vmm.c.
References address, ERR, PML_USER, sched_process(), process_t::space, space_check_access(), vmm_prot_to_flags(), and vmm_protect().
| 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().
|
static |
Definition at line 26 of file vmm.c.
References assert, space_t::cpus, cr3_read(), CR4_PAGE_GLOBAL_ENABLE, cr4_read(), cr4_write(), vmm_cpu_ctx_t::currentSpace, vmm_cpu_ctx_t::entry, kernelSpace, list_entry_init(), list_push(), space_t::lock, vmm_cpu_ctx_t::lock, lock_acquire(), lock_init(), lock_release(), space_t::pageTable, page_table_t::pml4, PML_ENSURE_LOWER_HALF, and vmm_cpu_ctx_t::shootdownCount.
Referenced by vmm_cpu_ctx_init(), and vmm_init().
|
inlinestatic |
Definition at line 161 of file vmm.c.
References page_table_clear(), page_table_unmap(), pageAmount, space_t::pageTable, and space_tlb_shootdown().
Referenced by vmm_alloc(), vmm_map(), vmm_map_pages(), and vmm_unmap().
|
static |
Definition at line 24 of file vmm.c.
Referenced by space_map_kernel_space_region(), vmm_cpu_ctx_init_common(), vmm_get_kernel_space(), vmm_init(), vmm_map_bootloader_lower_half(), and vmm_unmap_bootloader_lower_half().