summaryrefslogtreecommitdiff
path: root/sys/kern/init_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r--sys/kern/init_main.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index aa78e8d..4a0f7a8 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -35,14 +35,26 @@
#include <sys/exec.h>
#include <sys/driver.h>
#include <sys/panic.h>
+#include <sys/sysctl.h>
+#include <sys/systm.h>
+#include <dev/acpi/uacpi.h>
#include <dev/cons/cons.h>
#include <dev/acpi/acpi.h>
#include <machine/cpu.h>
#include <machine/cdefs.h>
#include <vm/vm.h>
+#include <vm/stat.h>
#include <string.h>
-static struct proc proc0;
+#define _START_PATH "/usr/sbin/init"
+#if defined(_INSTALL_MEDIA)
+#define _START_ARG "/usr/sbin/install"
+#else
+#define _START_ARG NULL
+#endif /* _INSTALL_MEDIA */
+
+struct proc g_proc0;
+struct proc *g_init;
static void
copyright(void)
@@ -54,19 +66,19 @@ copyright(void)
static void
start_init(void)
{
-#if 0
struct proc *td = this_td();
struct execve_args execve_args;
- char *argv[] = { "/usr/sbin/init", NULL };
+ char *argv[] = { _START_PATH, _START_ARG, NULL };
char *envp[] = { NULL };
+ kprintf("starting init...\n");
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");
-#endif
- for (;;);
+
+ __builtin_unreachable();
}
int
@@ -75,15 +87,15 @@ main(void)
/* Setup serial driver */
serial_init();
+ /* Init the virtual memory subsystem */
+ vm_init();
+
/* Startup the console */
cons_init();
copyright();
kprintf("Starting Hyra/%s v%s: %s\n", HYRA_ARCH, HYRA_VERSION,
HYRA_BUILDDATE);
- /* Init the virtual memory subsystem */
- vm_init();
-
/* Start the ACPI subsystem */
acpi_init();
@@ -93,6 +105,9 @@ main(void)
/* Init the virtual file system */
vfs_init();
+ /* Init vmstats */
+ vm_stat_init();
+
/* Expose the console to devfs */
cons_expose();
@@ -100,14 +115,25 @@ main(void)
md_intoff();
sched_init();
+ memset(&g_proc0, 0, sizeof(g_proc0));
+ sysctl_clearstr(KERN_HOSTNAME);
+
/* Startup pid 1 */
- memset(&proc0, 0, sizeof(proc0.tf));
- fork1(&proc0, 0, start_init, NULL);
+ spawn(&g_proc0, start_init, NULL, 0, &g_init);
+ md_inton();
+
+ uacpi_init();
- /* Load all drivers */
+ /* Load all early drivers */
DRIVERS_INIT();
- /* Bootstrap APs and here we go! */
+ /* Only log to kmsg from here */
+ syslog_silence(true);
+
+ /*
+ * Bootstrap APs, schedule all other drivers
+ * and here we go!
+ */
mp_bootstrap_aps(&g_bsp_ci);
sched_enter();
__builtin_unreachable();