aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/core/kmain.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/core/kmain.c')
-rw-r--r--src/kernel/core/kmain.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/kernel/core/kmain.c b/src/kernel/core/kmain.c
index 34438aa..5572ac4 100644
--- a/src/kernel/core/kmain.c
+++ b/src/kernel/core/kmain.c
@@ -15,6 +15,8 @@
#include <vfs.h>
#include <nullfs.h>
+#include <process.h>
+#include <elf.h>
#include <slab_alloc.h>
#include <hashtbl.h>
@@ -333,6 +335,23 @@ void kernel_init_stage2(void* data) {
test_cmdline(mbd, devfs);
+ fs_handle_t *init_bin = fs_open(devfs, "/mod/init.bin", FM_READ | FM_MMAP);
+ if (init_bin == 0) PANIC("No init.bin module provided!");
+ if (!is_elf(init_bin)) PANIC("init.bin is not valid ELF32 binary");
+
+ process_t *init_p = new_process(0);
+ ASSERT(init_p != 0);
+
+ bool add_devfs_ok = proc_add_fs(init_p, devfs, "dev");
+ ASSERT(add_devfs_ok);
+
+ proc_entry_t *e = elf_load(init_bin, init_p);
+ if (e == 0) PANIC("Could not load ELF file init.bin");
+
+ unref_file(init_bin);
+
+ start_process(init_p, e);
+
//TODO :
// - (OK) populate devfs with information regarding kernel command line & modules
// - create user process with init module provided on command line