Files
mango/sandbox/vm/vm_bootstrap.c
Max Wash 0d77d97561 memblock can now self re-allocate its internal buffers
memory allocated by memblock_alloc() can now be limited to a certain region.
2023-01-08 12:13:59 +00:00

35 lines
806 B
C

#include <limits.h>
#include <socks/vm.h>
#include <socks/memblock.h>
#include <stddef.h>
#include <limits.h>
/* One vm_pg_data_t per NUMA node. Right now we're only worrying about a single node */
static vm_pg_data_t node_data = {};
kern_status_t vm_bootstrap(const vm_region_t *mem_map, size_t nr_mem_map_entries)
{
uintptr_t pmap_min = UINTPTR_MAX, pmap_max = 0x0;
for (size_t i = 0; i < nr_mem_map_entries; i++) {
if (mem_map[i].r_base < pmap_min) {
pmap_min = mem_map[i].r_base;
}
if (mem_map[i].r_limit > pmap_max) {
pmap_max = mem_map[i].r_limit;
}
}
memblock_add(pmap_min, pmap_max);
for (size_t i = 0; i < nr_mem_map_entries; i++) {
if (mem_map[i].r_status == VM_REGION_RESERVED) {
memblock_reserve(mem_map[i].r_base, mem_map[i].r_limit);
}
}
return KERN_OK;
}