|
PatchworkOS
|
#include <kernel/mem/pmm.h>#include <kernel/config.h>#include <kernel/log/log.h>#include <kernel/log/panic.h>#include <kernel/mem/pmm_bitmap.h>#include <kernel/mem/pmm_stack.h>#include <kernel/sync/lock.h>#include <boot/boot_info.h>#include <errno.h>#include <sys/math.h>#include <sys/proc.h>Go to the source code of this file.
Macros | |
| #define | PMM_BITMAP_SIZE (CONFIG_PMM_BITMAP_MAX_ADDR / PAGE_SIZE) |
Functions | |
| static bool | pmm_is_efi_mem_available (EFI_MEMORY_TYPE type) |
| static void | pmm_free_unlocked (void *address) |
| static void | pmm_free_pages_unlocked (void *address, uint64_t count) |
| static void | pmm_detect_memory (const boot_memory_map_t *map) |
| static void | pmm_load_memory (const boot_memory_map_t *map) |
| void | pmm_init (const boot_memory_map_t *map) |
| Initializes the Physical Memory Manager. | |
| void * | pmm_alloc (void) |
| Allocates a single physical page. | |
| uint64_t | pmm_alloc_pages (void **addresses, uint64_t count) |
| Allocates multiple physical pages. | |
| void * | pmm_alloc_bitmap (uint64_t count, uintptr_t maxAddr, uint64_t alignment) |
| Allocates a contiguous region of physical pages managed by the bitmap. | |
| void | pmm_free (void *address) |
| Frees a single physical page. | |
| void | pmm_free_pages (void **addresses, uint64_t count) |
| Frees multiple physical pages. | |
| void | pmm_free_region (void *address, uint64_t count) |
| Frees a contiguous region of physical pages. | |
| uint64_t | pmm_total_amount (void) |
| Retrieves the total amount of physical memory managed by the PMM. | |
| uint64_t | pmm_free_amount (void) |
| Retrieves the amount of free physical memory. | |
| uint64_t | pmm_reserved_amount (void) |
| Retrieves the amount of reserved physical memory. | |
Variables | |
| static const char * | efiMemTypeToString [] |
| static pmm_stack_t | stack |
| static pmm_bitmap_t | bitmap |
| static uint64_t | mapBuffer [BITMAP_BITS_TO_QWORDS(PMM_BITMAP_SIZE)] |
| static uint64_t | pageAmount = 0 |
| static lock_t | lock = LOCK_CREATE |
| #define PMM_BITMAP_SIZE (CONFIG_PMM_BITMAP_MAX_ADDR / PAGE_SIZE) |
|
static |
Definition at line 113 of file pmm.c.
References boot_is_mem_ram(), BOOT_MEMORY_MAP_GET_DESCRIPTOR, boot_memory_map_t::length, LOG_INFO, map, and pageAmount.
Referenced by pmm_init().
|
static |
Definition at line 82 of file pmm.c.
References address, bitmap, CONFIG_PMM_BITMAP_MAX_ADDR, count, PAGE_SIZE, PML_HIGHER_TO_LOWER, PML_LOWER_TO_HIGHER, pmm_bitmap_free(), pmm_stack_free(), ROUND_DOWN, and stack.
Referenced by pmm_free_region(), and pmm_load_memory().
|
static |
Definition at line 66 of file pmm.c.
References address, bitmap, CONFIG_PMM_BITMAP_MAX_ADDR, NULL, panic(), PML_LOWER_TO_HIGHER, pmm_bitmap_free(), pmm_stack_free(), and stack.
Referenced by pmm_free(), and pmm_free_pages().
|
static |
|
static |
Definition at line 130 of file pmm.c.
References BOOT_MEMORY_MAP_GET_DESCRIPTOR, efiMemTypeToString, boot_memory_map_t::length, LOG_INFO, map, PAGE_SIZE, pageAmount, pmm_free_amount(), pmm_free_pages_unlocked(), and pmm_is_efi_mem_available().
Referenced by pmm_init().
|
static |
Definition at line 37 of file pmm.c.
Referenced by pmm_alloc_bitmap(), pmm_bitmap_alloc(), pmm_bitmap_free(), pmm_bitmap_init(), pmm_free_amount(), pmm_free_pages_unlocked(), pmm_free_unlocked(), pmm_init(), and pmm_reserved_amount().
|
static |
Definition at line 16 of file pmm.c.
Referenced by pmm_load_memory().
|
static |
Definition at line 44 of file pmm.c.
Referenced by pmm_alloc(), pmm_alloc_bitmap(), pmm_alloc_pages(), pmm_free(), pmm_free_amount(), pmm_free_pages(), pmm_free_region(), pmm_reserved_amount(), and pmm_total_amount().
|
static |
Definition at line 40 of file pmm.c.
Referenced by pmm_init().
|
static |
Definition at line 42 of file pmm.c.
Referenced by _heap_alloc(), _heap_block_new(), page_table_clear(), page_table_collect_callbacks(), page_table_find_unmapped_region(), page_table_is_mapped(), page_table_is_pinned(), page_table_is_unmapped(), page_table_map(), page_table_map_pages(), page_table_set_flags(), page_table_unmap(), pmm_detect_memory(), pmm_load_memory(), pmm_reserved_amount(), pmm_total_amount(), shmem_mmap(), shmem_object_allocate_pages(), space_alloc_callback(), space_find_free_region(), space_mapping_start(), space_pin(), space_pin_depth_dec(), space_pin_depth_inc(), space_pmm_bitmap_alloc_pages(), space_populate_user_region(), space_tlb_shootdown(), space_unpin(), space_update_free_address(), vmm_map_pages(), and vmm_page_table_unmap_with_shootdown().
|
static |
Definition at line 36 of file pmm.c.
Referenced by pmm_alloc(), pmm_alloc_pages(), pmm_free_amount(), pmm_free_pages_unlocked(), pmm_free_unlocked(), pmm_init(), pmm_reserved_amount(), pmm_stack_alloc(), pmm_stack_free(), pmm_stack_init(), qsort(), stack_pointer_deinit(), stack_pointer_deinit_buffer(), stack_pointer_init(), stack_pointer_init_buffer(), stack_pointer_is_in_stack(), stack_pointer_overlaps_guard(), and tss_ist_load().