|
PatchworkOS
|
#include <kernel/mem/space.h>#include <kernel/cpu/cpu.h>#include <kernel/cpu/smp.h>#include <kernel/log/panic.h>#include <kernel/mem/paging.h>#include <kernel/mem/pmm.h>#include <kernel/mem/vmm.h>#include <assert.h>#include <errno.h>#include <stdlib.h>#include <string.h>#include <sys/math.h>#include <sys/proc.h>Go to the source code of this file.
Functions | |
| static uint64_t | space_pmm_bitmap_alloc_pages (void **pages, uint64_t pageAmount) |
| static void | space_map_kernel_space_region (space_t *space, uintptr_t start, uintptr_t end) |
| static void | space_unmap_kernel_space_region (space_t *space, uintptr_t start, uintptr_t end) |
| uint64_t | space_init (space_t *space, uintptr_t startAddress, uintptr_t endAddress, space_flags_t flags) |
| Initializes a virtual address space. | |
| void | space_deinit (space_t *space) |
| Deinitializes a virtual address space. | |
| void | space_load (space_t *space) |
| Loads a virtual address space. | |
| static void | space_align_region (void **virtAddr, uint64_t *length) |
| static uint64_t | space_populate_user_region (space_t *space, const void *buffer, uint64_t pageAmount) |
| static void | space_pin_depth_dec (space_t *space, const void *address, uint64_t pageAmount) |
| static uint64_t | space_pin_depth_inc (space_t *space, const void *address, uint64_t pageAmount) |
| uint64_t | space_pin (space_t *space, const void *buffer, uint64_t length, stack_pointer_t *userStack) |
| Pins pages within a region of the address space. | |
| uint64_t | space_pin_terminated (space_t *space, const void *address, const void *terminator, uint8_t objectSize, uint64_t maxCount, stack_pointer_t *userStack) |
| Pins a region of memory terminated by a terminator value. | |
| void | space_unpin (space_t *space, const void *address, uint64_t length) |
Unpins pages in a region previously pinned with space_pin() or space_pin_string(). | |
| uint64_t | space_check_access (space_t *space, const void *addr, uint64_t length) |
| Checks if a virtual memory region is within the allowed address range of the space. | |
| static void * | space_find_free_region (space_t *space, uint64_t pageAmount) |
| uint64_t | space_mapping_start (space_t *space, space_mapping_t *mapping, void *virtAddr, void *physAddr, uint64_t length, pml_flags_t flags) |
| Prepare for changes to the address space mappings. | |
| pml_callback_id_t | space_alloc_callback (space_t *space, uint64_t pageAmount, space_callback_func_t func, void *private) |
| Allocate a callback. | |
| void | space_free_callback (space_t *space, pml_callback_id_t callbackId) |
| Free a callback. | |
| void | space_tlb_shootdown (space_t *space, void *virtAddr, uint64_t pageAmount) |
| Performs a TLB shootdown for a region of the address space, and wait for acknowledgements. | |
| static void | space_update_free_address (space_t *space, uintptr_t virtAddr, uint64_t pageAmount) |
| void * | space_mapping_end (space_t *space, space_mapping_t *mapping, errno_t err) |
| Performs cleanup after changes to the address space mappings. | |
| bool | space_is_mapped (space_t *space, const void *virtAddr, uint64_t length) |
| Checks if a virtual memory region is fully mapped. | |
|
static |
Definition at line 211 of file space.c.
References PAGE_SIZE, and ROUND_DOWN.
Referenced by space_is_mapped(), space_mapping_start(), space_pin(), and space_unpin().
Definition at line 503 of file space.c.
References assert, space_t::endAddress, ERR, space_t::freeAddress, NULL, PAGE_SIZE, page_table_find_unmapped_region(), page_table_is_unmapped(), pageAmount, space_t::pageTable, and space_t::startAddress.
Referenced by space_mapping_start().
|
inlinestatic |
Definition at line 36 of file space.c.
References assert, pml_t::entries, kernelSpace, NULL, pml_entry_t::owned, space_t::pageTable, PML4, page_table_t::pml4, PML_ADDR_TO_INDEX, start(), and vmm_get_kernel_space().
Referenced by space_init().
|
static |
Definition at line 247 of file space.c.
References address, CONTAINER_OF, page_table_traverse_t::entry, ERR, free(), map_get(), map_key_uint64(), map_remove(), NULL, PAGE_SIZE, page_table_traverse(), PAGE_TABLE_TRAVERSE_CREATE, pageAmount, space_t::pageTable, space_pinned_page_t::pinCount, pml_entry_t::pinned, space_t::pinnedPages, PML_NONE, pml_entry_t::present, and ROUND_DOWN.
Referenced by space_pin_terminated(), and space_unpin().
|
inlinestatic |
Definition at line 284 of file space.c.
References address, CONTAINER_OF, page_table_traverse_t::entry, ERR, free(), malloc(), map_entry_init(), map_get(), map_insert(), map_key_uint64(), space_pinned_page_t::mapEntry, NULL, PAGE_SIZE, page_table_traverse(), PAGE_TABLE_TRAVERSE_CREATE, pageAmount, space_t::pageTable, space_pinned_page_t::pinCount, pml_entry_t::pinned, space_t::pinnedPages, PML_NONE, pml_entry_t::present, and ROUND_DOWN.
Referenced by space_pin(), and space_pin_terminated().
Definition at line 18 of file space.c.
References ERR, NULL, pageAmount, pmm_alloc_bitmap(), pmm_free(), and UINT32_MAX.
Referenced by space_init().
|
static |
Definition at line 218 of file space.c.
References buffer, EFAULT, ENOMEM, ERR, errno, NULL, PAGE_SIZE, page_table_is_mapped(), page_table_map(), pageAmount, space_t::pageTable, PML_CALLBACK_NONE, PML_OWNED, PML_PRESENT, PML_USER, PML_WRITE, pmm_alloc(), and pmm_free().
Referenced by space_pin(), and space_pin_terminated().
|
inlinestatic |
Definition at line 51 of file space.c.
References pml_t::entries, space_t::pageTable, PML4, page_table_t::pml4, PML_ADDR_TO_INDEX, pml_entry_t::raw, and start().
Referenced by space_deinit().
|
static |
Definition at line 717 of file space.c.
References space_t::freeAddress, NULL, PAGE_SIZE, and pageAmount.
Referenced by space_mapping_end().