PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
space.c File Reference
#include <kernel/cpu/ipi.h>
#include <kernel/mem/space.h>
#include <kernel/cpu/cpu.h>
#include <kernel/log/panic.h>
#include <kernel/mem/paging.h>
#include <kernel/mem/pmm.h>
#include <kernel/mem/vmm.h>
#include <kernel/sched/clock.h>
#include <kernel/utils/map.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/math.h>
#include <sys/proc.h>
Include dependency graph for space.c:

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.
 
static void space_tlb_shootdown_ipi_handler (ipi_func_data_t *data)
 
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.
 
uint64_t space_user_page_count (space_t *space)
 Get the number of user pages allocated in the address space.
 

Function Documentation

◆ space_pmm_bitmap_alloc_pages()

static uint64_t space_pmm_bitmap_alloc_pages ( void **  pages,
uint64_t  pageAmount 
)
static

Definition at line 20 of file space.c.

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

◆ space_map_kernel_space_region()

static void space_map_kernel_space_region ( space_t space,
uintptr_t  start,
uintptr_t  end 
)
inlinestatic

Definition at line 38 of file space.c.

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

◆ space_unmap_kernel_space_region()

static void space_unmap_kernel_space_region ( space_t space,
uintptr_t  start,
uintptr_t  end 
)
inlinestatic

Definition at line 53 of file space.c.

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

◆ space_align_region()

static void space_align_region ( void **  virtAddr,
uint64_t length 
)
static

Definition at line 209 of file space.c.

Here is the caller graph for this function:

◆ space_populate_user_region()

static uint64_t space_populate_user_region ( space_t space,
const void *  buffer,
uint64_t  pageAmount 
)
static

Definition at line 216 of file space.c.

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

◆ space_pin_depth_dec()

static void space_pin_depth_dec ( space_t space,
const void *  address,
uint64_t  pageAmount 
)
static

Definition at line 243 of file space.c.

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

◆ space_pin_depth_inc()

static uint64_t space_pin_depth_inc ( space_t space,
const void *  address,
uint64_t  pageAmount 
)
inlinestatic

Definition at line 280 of file space.c.

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

◆ space_find_free_region()

static void * space_find_free_region ( space_t space,
uint64_t  pageAmount 
)
static

Definition at line 507 of file space.c.

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

◆ space_tlb_shootdown_ipi_handler()

static void space_tlb_shootdown_ipi_handler ( ipi_func_data_t data)
static

Definition at line 644 of file space.c.

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

◆ space_update_free_address()

static void space_update_free_address ( space_t space,
uintptr_t  virtAddr,
uint64_t  pageAmount 
)
static

Definition at line 726 of file space.c.

Here is the caller graph for this function: