From aaf7355c5ededfcdc877c7f2989fb1ba02dfb848 Mon Sep 17 00:00:00 2001
From: Danny Holman <dholman@gymli.org>
Date: Mon, 27 May 2024 13:53:52 -0500
Subject: libk: create a subset libc for kernel use

Create a subset of the C library for use inside the kernel.

Signed-off-by: Danny Holman <dholman@gymli.org>
---
 kernel/init.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

(limited to 'kernel/init.c')

diff --git a/kernel/init.c b/kernel/init.c
index 98ac05c..d4a3638 100644
--- a/kernel/init.c
+++ b/kernel/init.c
@@ -1,31 +1,35 @@
-#include <kernel/io.h>
+#include <libk/io.h>
+#include <libk/string.h>
+#include <libk/kmalloc.h>
 #include <kernel/sched.h>
-#include <kernel/kmalloc.h>
-#include <kernel/string.h>
+#include <kernel/kthread.h>
+#include <kernel/pci.h>
 #include <kernel/serial.h>
 
 void jump_userspace(void);
 
 char rootfs[1024];
-
-int start_init(int argc, char* argv[]) {
-        while (1);
-        return 0;
-}
+char init_bin[1024];
+int gdbstub = 0;
 
 void process_cmd(char *cmdline) {
         char *token = strtok(cmdline, " ");
         while (token != NULL) {
                 if (strncmp(token, "root=", 5) == 0)
-                        strcpy(rootfs, &token[6]);
+                        strcpy(rootfs, &token[5]);
+                if (strncmp(token, "init=", 5) == 0)
+                        strcpy(init_bin, &token[5]);
+                if (strncmp(token, "gdb", 3) == 0)
+                        gdbstub = 1;
+                token = strtok(NULL, " ");
         }
 }
 
 void kernel_main(char *cmdline) {
-        kmalloc_init();
-        kprintf("Box Kernel version %s\n", VERSION);
+        kprintf("Box kernel version %s\n", VERSION);
+        process_cmd(cmdline);
+
         serial_init();
         sched_init();
-
-        //jump_userspace();
+        //pci_check_buses();
 }
-- 
cgit v1.2.3