Physical memory map describing usable and reserved regions of physical memory. More...
#include <core.h>
#include <libc/stdlib.h>
#include <libc/string.h>
#include <kernel/mem/kmem.h>
#include <kernel/mem/pmap.h>
Go to the source code of this file.
Functions | |
static void | add_region (uint64_t addr, uint64_t size, enum pmemtype type) |
Add a memory region to the end of the memory map. More... | |
static int | cmp_region (const void *a, const void *b) |
Compare two memory region records and return a sorting integer. More... | |
static void | collapse (pmapregion_t *r, pmapregion_t *term) |
Remove a region from the memory map and shift all subsequent regions down by one. More... | |
static void | insertafter (pmapregion_t *r, pmapregion_t *term) |
Insert a new, uninitialized memory region record after an existing record in the memory map. More... | |
static void | resort (pmapregion_t *r, pmapregion_t *term) |
Re-sort all unsorted region records starting from the requested record. More... | |
static void | collapse_overlaps () |
Find all overlapping memory regions in the memory map and collapse or reorganize them. More... | |
static void | fill_gaps (int32_t type) |
Find missing memory regions in the map, and fill them with entries of the requested type. More... | |
static void | consolidate_neighbors () |
Find adjacent memory entries of the same type and merge them. More... | |
static void | update_last_usable () |
static void | normalize () |
void | pmap_init () |
Initialize the physical memory map using data installed by the BIOS during boot loading. More... | |
const pmap_t * | pmap () |
Return a pointer to the current physical memory map. More... | |
void | pmap_add (uint64_t addr, uint64_t size, enum pmemtype type) |
Add a region of memory to the physical memory map. More... | |
Variables | |
static pmap_t * | map = (pmap_t *)KMEM_TABLE_BIOS |
static bool | initialized = false |
Physical memory map describing usable and reserved regions of physical memory.
Before this code is ever executed, the boot code has filled much of the memory map with memory regions supplied by the BIOS.
Definition in file pmap.c.
|
static |
Add a memory region to the end of the memory map.
Definition at line 26 of file pmap.c.
Referenced by pmap_add(), and pmap_init().
|
static |
Compare two memory region records and return a sorting integer.
Definition at line 39 of file pmap.c.
Referenced by normalize(), and resort().
|
inlinestatic |
Remove a region from the memory map and shift all subsequent regions down by one.
Definition at line 57 of file pmap.c.
Referenced by collapse_overlaps(), and consolidate_neighbors().
|
inlinestatic |
Insert a new, uninitialized memory region record after an existing record in the memory map.
Definition at line 67 of file pmap.c.
Referenced by collapse_overlaps(), and fill_gaps().
|
static |
Re-sort all unsorted region records starting from the requested record.
Definition at line 76 of file pmap.c.
Referenced by collapse_overlaps().
|
static |
Find all overlapping memory regions in the memory map and collapse or reorganize them.
Definition at line 91 of file pmap.c.
Referenced by normalize().
|
static |
Find missing memory regions in the map, and fill them with entries of the requested type.
Definition at line 205 of file pmap.c.
Referenced by normalize().
|
static |
Find adjacent memory entries of the same type and merge them.
Definition at line 245 of file pmap.c.
Referenced by normalize().
|
static |
Definition at line 263 of file pmap.c.
Referenced by normalize().
|
static |
Definition at line 276 of file pmap.c.
Referenced by pmap_add(), and pmap_init().
void pmap_init | ( | ) |
const pmap_t* pmap | ( | ) |
Return a pointer to the current physical memory map.
Definition at line 316 of file pmap.c.
Referenced by kmem_init(), and page_init().
void pmap_add | ( | uint64_t | addr, |
uint64_t | size, | ||
enum pmemtype | type | ||
) |
Add a region of memory to the physical memory map.
[in] | addr | The starting address of the region. |
[in] | size | The size of the region. |
[in] | type | The type of memory to add. |
Definition at line 322 of file pmap.c.
Referenced by acpi_init(), map_table(), and reserve_region().
|
static |
Definition at line 21 of file pmap.c.
Referenced by add_region(), collapse(), collapse_overlaps(), consolidate_neighbors(), fill_gaps(), insertafter(), kmem_init(), normalize(), page_init(), pmap(), and update_last_usable().
|
static |
Definition at line 22 of file pmap.c.
Referenced by pmap_add(), and pmap_init().