aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/riscv64/kernel/main.c5
-rw-r--r--common/debug.c21
-rw-r--r--common/main.c26
-rw-r--r--include/apos/debug.h16
-rw-r--r--include/arch/arch.h4
5 files changed, 39 insertions, 33 deletions
diff --git a/arch/riscv64/kernel/main.c b/arch/riscv64/kernel/main.c
index 9ce256e..245fc9e 100644
--- a/arch/riscv64/kernel/main.c
+++ b/arch/riscv64/kernel/main.c
@@ -1,11 +1,14 @@
#include <apos/utils.h>
+#include <arch/arch.h>
#include <csr.h>
-void arch_setup(void *fdt)
+stat_t setup_arch(void *fdt)
{
UNUSED(fdt);
/* allow supervisor code to touch user pages */
csr_set(CSR_SSTATUS, SSTATUS_SUM);
/* mark that we want to eventually jump to userspace */
csr_clear(CSR_SSTATUS, SSTATUS_SPP);
+
+ return OK;
}
diff --git a/common/debug.c b/common/debug.c
index d34823a..afc04e7 100644
--- a/common/debug.c
+++ b/common/debug.c
@@ -3,10 +3,31 @@
#include <apos/bits.h>
#include <apos/vmem.h>
#include <apos/pmem.h>
+#include <arch/vmem.h>
#include <libfdt.h>
#include <stdarg.h>
#ifdef DEBUG
+static struct dbg_info {
+ pm_t dbg_ptr;
+ enum serial_dev dev;
+} dbg_info = (struct dbg_info){0};
+
+void init_dbg(void *fdt)
+{
+ dbg_info = dbg_from_fdt(fdt);
+}
+
+void setup_dmap_dbg()
+{
+ setup_dbg(dbg_info.dbg_ptr, dbg_info.dev);
+}
+
+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);
+}
/* if there arises a need for more supported serial drivers, I should probably
* try to implement some kind of basic driver subsystem, but this is good enough
diff --git a/common/main.c b/common/main.c
index 3aabc3c..0e33ecc 100644
--- a/common/main.c
+++ b/common/main.c
@@ -7,30 +7,6 @@
#include <arch/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 */
@@ -38,7 +14,7 @@ void __main main(void *fdt)
setup_dmap_dbg();
dbg_fdt(fdt);
- arch_setup(fdt);
+ setup_arch(fdt);
init_pmem(fdt);
struct vm_branch *b = init_vmem(fdt);
diff --git a/include/apos/debug.h b/include/apos/debug.h
index 9aa132f..a9e5d46 100644
--- a/include/apos/debug.h
+++ b/include/apos/debug.h
@@ -3,6 +3,7 @@
#include <apos/attrs.h>
#include <apos/pmem.h>
+#include <arch/vmem.h>
#ifdef DEBUG
enum serial_dev {
@@ -10,13 +11,14 @@ enum serial_dev {
NS16550A,
};
-struct dbg_info {
- pm_t dbg_ptr;
- enum serial_dev dev;
-};
-
void __fmt(1, 2) dbg(const char *fmt, ...);
+
+void init_dbg(void *fdt);
+
+void setup_dmap_dbg();
+void setup_io_dbg(struct vm_branch *b);
void setup_dbg(pm_t pt, enum serial_dev dev);
+
struct dbg_info dbg_from_fdt(void *fdt);
#define COMMON_FORMAT "[%s] %s:%d\n\t"
@@ -32,6 +34,10 @@ struct dbg_info dbg_from_fdt(void *fdt);
#define dbg_init(...)
#define dbg_from_fdt(...)
+#define init_dbg(...)
+#define setup_dmap_dbg(...)
+#define setup_io_dbg(...)
+
#define bug(...)
#define warn(...)
#define info(...)
diff --git a/include/arch/arch.h b/include/arch/arch.h
index 1933555..f684cf0 100644
--- a/include/arch/arch.h
+++ b/include/arch/arch.h
@@ -1,8 +1,8 @@
#ifndef APOS_ARCH_H
#define APOS_ARCH_H
-/* functions that an arch has to provide */
+#include <apos/types.h>
-void arch_setup(void *fdt);
+stat_t setup_arch(void *fdt);
#endif /* APOS_ARCH_H */