diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2024-03-11 21:30:31 -0400 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2024-03-11 21:30:31 -0400 |
commit | d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d (patch) | |
tree | 8f0b5cd8aad31089131785dc6e37b659490f9955 /usr/umode.c | |
download | jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.tar.gz jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.tar.bz2 jove-kernel-d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d.zip |
usermode capable kernel with logging syscall
Diffstat (limited to 'usr/umode.c')
-rw-r--r-- | usr/umode.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/usr/umode.c b/usr/umode.c new file mode 100644 index 0000000..4ef5306 --- /dev/null +++ b/usr/umode.c @@ -0,0 +1,31 @@ +#include "umode.h" +#include "elf.h" +#include "boot/cmdline.h" +#include "lib/jove.h" +#include "ird/initrd.h" +#include "mem/memory.h" + +void +umode_setup(void) +{ + extern void syscall_setup_syscall(void); + syscall_setup_syscall(); + + const char *init_path = cmdline_get("init"); + if(init_path == NULL) + kpanic("Missing path to init ELF file / binary\n"); + + struct InitrdFile *init_file = ird_getfile(init_path); + if(init_file == NULL) + kpanic("Missing init file %s in initrd\n", init_path); + + void (*entry_point)(void) = elf_load(init_file->data, init_file->size); + if(entry_point == NULL) + kpanic("Init file %s is incorrectly formatted (want ELF64)\n", init_path); + + void *user_stack = (void*)(0x00007FFFFFFFFFFF); + mem_ensure_range((uintptr_t)user_stack & ~0xFFF, (uintptr_t)user_stack, true, true); + + klogf("User entry point %#016X\n", entry_point); + umode_enter(entry_point, user_stack); +} |