aboutsummaryrefslogtreecommitdiff
path: root/common/main.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2021-12-29 23:23:36 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2021-12-29 23:53:06 +0200
commit4f4d9fdc89c27aa3346467a24b621954f4564d3b (patch)
treec4ba4fb583a43b8fb27730b4cdb9b4b1395da91c /common/main.c
parent4e5595a089c815febd7a0d42ab62940bf13f73ac (diff)
downloadkmi-4f4d9fdc89c27aa3346467a24b621954f4564d3b.tar.gz
kmi-4f4d9fdc89c27aa3346467a24b621954f4564d3b.zip
Refactoring
+ Mainly just moving stuff out or arch/riscv/ that should be handled in common/ + Prepared separate process stack/call stack for server callbacks, rest to be implemeted soon ish
Diffstat (limited to 'common/main.c')
-rw-r--r--common/main.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/common/main.c b/common/main.c
new file mode 100644
index 0000000..f91fc22
--- /dev/null
+++ b/common/main.c
@@ -0,0 +1,52 @@
+#include <apos/mem_nodes.h>
+#include <apos/attrs.h>
+#include <apos/proc.h>
+#include <apos/debug.h>
+#include <apos/vmem.h>
+#include <apos/arch.h>
+#include <apos/irq.h>
+#include <libfdt.h>
+
+#ifdef DEBUG
+static struct dbg_info dbg_info = (struct dbg_info){0};
+
+static void init_dbg(void *fdt)
+{
+ dbg_info = dbg_from_fdt(fdt);
+}
+
+static void setup_dmap_dbg()
+{
+ setup_dbg(dbg_info.dbg_ptr, dbg_info.dev);
+}
+
+static void setup_io_dbg(struct vm_branch *b)
+{
+ vm_t io_ptr = setup_kernel_io(b, dbg_info.dbg_ptr);
+ setup_dbg(io_ptr, dbg_info.dev);
+}
+#else
+#define init_dbg(...)
+#define setup_dmap_dbg(...)
+#define setup_io_dbg(...)
+#endif
+
+void __main main(void *fdt)
+{
+ /* dbg uses direct mapping at this point */
+ init_dbg(fdt);
+ setup_dmap_dbg();
+ dbg_fdt(fdt);
+
+ arch_setup(fdt);
+
+ init_pmem(fdt);
+ init_mem_blocks();
+ struct vm_branch *b = init_vmem(fdt);
+
+ /* start up debugging in kernel IO */
+ setup_io_dbg(b);
+
+ init_irq(fdt);
+ init_proc(fdt, b);
+}