#include #include #include #include #include #include #include #include #include /* One struct vm_pg_data per NUMA node. */ static struct vm_pg_data *node_data = NULL; kern_status_t vm_bootstrap(const struct vm_zone_descriptor *zones, size_t nr_zones) { int numa_count = 1; /* we're only worrying about UMA systems for now */ node_data = memblock_alloc(sizeof(struct vm_pg_data) * 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; } struct vm_pg_data *vm_pg_data_get(vm_node_id_t node) { if (node == 0) { return node_data; } return NULL; }