Kernel/Userspace: Start initial work on userspace and syscalls

This commit is contained in:
Bananymous
2023-03-13 15:32:46 +02:00
parent af854ec9e1
commit 8b8e3cbbf0
10 changed files with 231 additions and 5 deletions

View File

@@ -0,0 +1,28 @@
#include <BAN/Formatter.h>
#include <kernel/Syscall.h>
#define USERSPACE __attribute__((section(".userspace")))
USERSPACE int syscall(int syscall, void* arg1 = nullptr, void* arg2 = nullptr, void* arg3 = nullptr)
{
int ret;
asm volatile("int $0x80" : "=a"(ret) : "a"(syscall), "b"(arg1), "c"(arg2), "d"(arg3) : "memory");
return ret;
}
USERSPACE void user_putc(char ch)
{
syscall(SYS_PUTC, (void*)(uintptr_t)ch);
}
USERSPACE void print(const char* str)
{
while (*str)
user_putc(*str++);
}
USERSPACE void userspace_entry()
{
BAN::Formatter::println(user_putc, "Hello {}!", "World");
for (;;);
}