#include #include #include #include #include #include #include #include #include /* One vm_pg_data_t per NUMA node. */ static vm_pg_data_t *node_data = NULL; kern_status_t vm_bootstrap(const vm_zone_descriptor_t *zones, size_t nr_zones) { int numa_count = 1; /* we're only worrying about UMA systems for now */ node_data = memblock_alloc(sizeof(vm_pg_data_t) * numa_count, 8); /* TODO select which memory model to use automatically, and add a kernel boot parameter to override the choice */ vm_set_memory_model(VM_MODEL_SPARSE); switch (vm_memory_model()) { case VM_MODEL_SPARSE: vm_sparse_init(); break; case VM_MODEL_FLAT: vm_flat_init(); break; default: break; } for (size_t i = 0; i < nr_zones; i++) { vm_zone_init(&node_data->pg_zones[zones[i].zd_id], &zones[i]); } kmalloc_init(); return KERN_OK; } vm_pg_data_t *vm_pg_data_get(vm_node_id_t node) { if (node == 0) { return node_data; } return NULL; }