diff options
author | Ian Moffett <ian@osmora.org> | 2024-07-04 23:44:14 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-07-04 23:48:38 -0400 |
commit | bf9e5005b66c3e1219340837d3c29443dd0fb4e1 (patch) | |
tree | 943c9300224682443e465ae1d47f0ce21981426c | |
parent | 4f9c6864188be29fd80d4e10c6e6da7d80fc5d10 (diff) |
kernel: init_main: Startup PID 1
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/kern/init_main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index a5bdf1c..02e8705 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -32,13 +32,31 @@ #include <sys/sched.h> #include <sys/mount.h> #include <sys/proc.h> +#include <sys/exec.h> +#include <sys/panic.h> #include <dev/cons/cons.h> #include <dev/acpi/acpi.h> #include <machine/cpu.h> #include <vm/vm.h> +#include <string.h> static struct proc proc0; +static void +start_init(void) +{ + struct proc *td = this_td(); + struct execve_args execve_args; + char *argv[] = { "/usr/sbin/init", NULL }; + char *envp[] = { NULL }; + + execve_args.pathname = argv[0]; + execve_args.argv = argv; + execve_args.envp = envp; + if (execve(td, &execve_args) != 0) + panic("Failed to load init\n"); +} + int main(void) { @@ -63,6 +81,10 @@ main(void) sched_init(); mp_bootstrap_aps(&g_bsp_ci); + /* Startup init */ + memset(&proc0, 0, sizeof(proc0.tf)); + fork1(&proc0, 0, start_init, NULL); + /* Nothing left to do... halt */ cpu_reboot(REBOOT_HALT); __builtin_unreachable(); |