diff options
Diffstat (limited to 'proc/init.c')
| -rw-r--r-- | proc/init.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/proc/init.c b/proc/init.c new file mode 100644 index 0000000..65299f4 --- /dev/null +++ b/proc/init.c @@ -0,0 +1,34 @@ +#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__); +} |
