summaryrefslogtreecommitdiffstats
path: root/task/init.c
blob: c4c8bad209635e5f27a092f13d32d6611d14df6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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");
}