BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / 4760662b4aefcc8d41b04e8920f71583846594b1

// Related

Nucleus

Barry Start userspace 4760662 (3 years, 2 months ago)
diff --git a/Makefile b/Makefile
index cb163ac..5d47233 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,10 @@ clean:
 	@touch $(PRODUCT)
 	@rm $(PRODUCT)
 
+install: $(PRODUCT)
+	$(info INSTALL $^)
+	@install -Dm 755 $(PRODUCT) -t ${SYSROOT}/boot/
+
 $(PRODUCT): $(OBJS)
 	$(info LD $@)
 	@$(LD) -o $@ $^ $(LFLAGS)
diff --git a/kernel/main.c b/kernel/main.c
index 7d37563..aa2373a 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -6,6 +6,9 @@
 
 #include <stdint.h>
 #include <string.h>
+#include <unistd.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
 #include <nucleus/panic.h>
 #include <nucleus/memory.h>
 #include <nucleus/task.h>
@@ -15,6 +18,7 @@
 #include "acpi/acpi.h"
 
 extern char _bss[], _end[];
+void page_fault_handler(struct InterruptFrame *frame, uint32_t err);
 
 /* Per-CPU Setup */
 void
@@ -70,5 +74,18 @@ kmain(struct MultibootInfo *mbinfo)
 	init_acpi(ebda);
 	init_pci();
 
-	panic("End of kernel!");
+	/* Enable userspace page-fault handler */
+	register_exception(14, page_fault_handler);
+
+	/* Mount drive */
+	mkdir("root", 0);
+	mount("/dev/hd0", "/root", "ext2fs", MS_RDONLY, NULL);
+	chroot("/root");
+	chdir("/");
+	mount("devfs", "/dev", "devfs", 0, NULL);
+
+	/* Start init */
+	char *argv[] = { "init", NULL };
+	execve("/bin/init", argv, NULL);
+	panic("Could not run init");
 }