#include "init.h" #include "hal/memory.h" #include "panic/panic.h" objpath_part_t s_last_untyped = JOVE_OBJDIR_ENTRIES-1; jove_owned_obj_t init_pop_alloc(void) { jove_owned_obj_t *untyped_dir = objdir_trygetlocal(_rootdir_obj, ROOTDIR_UNTYPED_I); if(untyped_dir == 0) { kpanic("Untyped directory is locked!\n"); } int cycles = 0; while(cycles++ < 512) { if(objdir_peeklocal(untyped_dir, s_last_untyped).type != JOVE_OBJ_UNTYPED) { s_last_untyped--; continue; } jove_owned_obj_t frame = { 0 }; jove_owned_obj_t *untyped = objdir_getlocal(untyped_dir, s_last_untyped); if(untyped_split(untyped, &frame, 0x1000) < 0) { kpanic("%s: Failed to split last untyped.\n", __func__); } obj_release(untyped); obj_release(untyped_dir); return frame; } kpanic("%s: Kernel is out of memory!\n", __func__); }