diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-17 18:10:33 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-17 18:12:05 -0400 |
commit | cf5672399eedbfc231fbf650e9bfb944f34e87a2 (patch) | |
tree | f77f240463e12a9b1625a1387e346c72e1041bae | |
parent | 3e83b2f9be4f2446e5284a55ab996a083b521b0b (diff) |
kern: init: Load /usr/sbin/init after boot
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | src/sys/os/os_init.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sys/os/os_init.c b/src/sys/os/os_init.c index 3772229..f244a75 100644 --- a/src/sys/os/os_init.c +++ b/src/sys/os/os_init.c @@ -1,14 +1,17 @@ #include <sys/cdefs.h> #include <sys/panic.h> #include <sys/syslog.h> +#include <sys/proc.h> #include <sys/cpuvar.h> #include <os/sched.h> +#include <os/elfload.h> #include <acpi/acpi.h> #include <io/cons/cons.h> #include <vm/vm.h> #include <logo.h> struct pcore g_bsp; +struct proc g_rootproc; static void boot_print(void) @@ -23,6 +26,9 @@ boot_print(void) __dead void main(void) { + struct loaded_elf elf; + struct pcore *core; + int error; acpi_early_init(); @@ -37,6 +43,17 @@ main(void) bsp_ap_startup(); sched_init(); + core = this_core(); + proc_init(&g_rootproc, 0); + core->curproc = &g_rootproc; + + error = elf_load("/usr/bin/init", &g_rootproc, &elf); + if (error < 0) { + panic("could not load init\n"); + } + + md_set_ip(&g_rootproc, elf.entrypoint); + md_proc_kick(&g_rootproc); panic("end of kernel reached\n"); for (;;); } |