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/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'kernel/main.c') diff --git a/kernel/main.c b/kernel/main.c index 325f858..07188b9 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -1,12 +1,28 @@ #include +#include +#include +#include +#include + +unsigned long init_stack[THREAD_SIZE / sizeof(unsigned long)]; + +struct task_struct init_task = { .stack = init_stack }; /* * This is the main entry point of the kernel after head.S is done. This * function can (and will) assume that everything has been reset and that we can * start the whole thing. */ -__noreturn __kernel void start_kernel(void) +__noreturn __kernel void start_kernel(uintptr_t *dtb) { + // TODO: disable irqs, etc. + + printk("Welcome to FizzBuzz OS!\n"); + + parse_dtb(dtb); + + // TODO: reenable stuff + for (;;) ; } -- cgit v1.2.3