From 7f6b234625a53d2ceb9ec80dc0172aac1cedb358 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 22 Nov 2024 23:00:46 +0100 Subject: Enable exception handling from user mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows us to actually catch system calls and start to run user space programs. That being said, the whole thing is still pretty brittle, and the scheduler is not quite there yet. Signed-off-by: Miquel Sabaté Solà --- include/fbos/compiler.h | 3 +++ include/fbos/printk.h | 3 +++ include/fbos/sched.h | 10 ++++++++++ 3 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/fbos/compiler.h b/include/fbos/compiler.h index 95596dd..67f3194 100644 --- a/include/fbos/compiler.h +++ b/include/fbos/compiler.h @@ -6,6 +6,9 @@ */ #define __noreturn __attribute__((__noreturn__)) +#ifndef __always_inline +#define __always_inline __attribute__((__always_inline__)) inline +#endif #define __s_interrupt __attribute__((interrupt("supervisor"))) #define __aligned(x) __attribute__((aligned(x))) diff --git a/include/fbos/printk.h b/include/fbos/printk.h index 6b32555..5a12d7c 100644 --- a/include/fbos/printk.h +++ b/include/fbos/printk.h @@ -1,6 +1,8 @@ #ifndef __FBOS_PRINTK_H_ #define __FBOS_PRINTK_H_ +#include + /* * This file might be pulled from user space tests. Hence, define alternatives * for this functions from glibc. @@ -9,6 +11,7 @@ #ifdef __KERNEL__ extern void die(const char *const message); extern void printk(const char *const message); +extern void write(const char *const message, size_t n); #else #include #include diff --git a/include/fbos/sched.h b/include/fbos/sched.h index 6a59756..c2a4b19 100644 --- a/include/fbos/sched.h +++ b/include/fbos/sched.h @@ -3,6 +3,7 @@ #include +// All the possible IDs for the tasks on this kernel. enum task_id { TASK_UNKNOWN = -1, TASK_INIT = 0, @@ -11,12 +12,21 @@ enum task_id { TASK_FIZZBUZZ = 3, }; +// TODO: if we only care about the absolute address, it can be further +// simplified. struct task_struct { void *stack; const void *addr; uint64_t entry_offset; }; +// Tasks available on this kernel. extern struct task_struct tasks[4]; +// Identifier for the next task to be run. +extern int next_task; + +// Bring the machine to idle mode. +__noreturn __kernel void idle(void); + #endif // __FBOS_SCHED_H_ -- cgit v1.2.3