diff options
Diffstat (limited to 'task/init.c')
-rw-r--r-- | task/init.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/task/init.c b/task/init.c new file mode 100644 index 0000000..c4c8bad --- /dev/null +++ b/task/init.c @@ -0,0 +1,22 @@ +#include "commandline.h" +#include "jove.h" +#include "initrd.h" +#include "tasking.h" +#include "arch/elf.h" + +__attribute__((noreturn)) void +kinit(void) +{ + const char *init_filepath = cmdline_get("init"); + if(init_filepath == NULL) + kpanic("init filepath not found in kernel commandline\n"); + + initrd_file_t *init_file = ird_getfile(init_filepath); + if(init_file == NULL) + kpanic("init file not found in initrd [filepath=\"%s\"]\n", init_filepath); + + uintptr_t ip = elf_load(init_file->data, init_file->size); + + kexec((void*)ip, 0, NULL, 0, NULL); + kpanic("Reached end of kinit\n"); +} |