aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/init_main.c22
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();