From 52a4afca71aee5c150c6c63e7c1a510501fce6f3 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 19 Nov 2024 14:55:32 +0100 Subject: Setup the stack for an init task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bootstrap an init task which holds at least the initial stack that is to be used when setting up the registers (such as `sp` and `tp`). In order to guarantee that the stack and the rest of the registers are set up correctly, this commit also provides a raw implementation of a `printk` function. Moreover, this commit also adds an argument that must be passed to `start_kernel`, which is the pointer to the embedded `fdt` blob. This argument will be used by later work so to fetch, at least, the base address for the initial ram disk. This was also used to test that the stack was working as expected. Signed-off-by: Miquel Sabaté Solà --- kernel/printk.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 kernel/printk.c (limited to 'kernel/printk.c') diff --git a/kernel/printk.c b/kernel/printk.c new file mode 100644 index 0000000..c0eedd9 --- /dev/null +++ b/kernel/printk.c @@ -0,0 +1,23 @@ +#include +#include +#include + +void __noreturn __kernel die(const char *const message) +{ + if (message) { + printk(message); + } + + for (;;) + ; +} + +void __kernel printk(const char *const message) +{ + size_t len = strlen(message); + if (!len) { + return; + } + + sbi_ecall2(DBCN_EXT, DBCN_WRITE, len, (unsigned long)message); +} -- cgit v1.2.3