diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-22 23:00:46 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-11-22 23:00:46 +0100 |
| commit | 7f6b234625a53d2ceb9ec80dc0172aac1cedb358 (patch) | |
| tree | 4fe10fcbe2d5e90a0e673259dc895f48a76e06cd /include | |
| parent | 224ed7b13ceadd05d27e61d3a0fdd34beb0c7745 (diff) | |
| download | fbos-7f6b234625a53d2ceb9ec80dc0172aac1cedb358.tar.gz fbos-7f6b234625a53d2ceb9ec80dc0172aac1cedb358.zip | |
Enable exception handling from user mode
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à <mikisabate@gmail.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/fbos/compiler.h | 3 | ||||
| -rw-r--r-- | include/fbos/printk.h | 3 | ||||
| -rw-r--r-- | include/fbos/sched.h | 10 |
3 files changed, 16 insertions, 0 deletions
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 <fbos/compiler.h> + /* * 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 <stdio.h> #include <stdlib.h> 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 <fbos/compiler.h> +// 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_ |
