Luna/kernel/src/sys/Syscall.cpp
apio fd8a0175d9
All checks were successful
continuous-integration/drone/push Build is passing
Add a syscall infrastructure (our baby program can print to the console now!)
2023-01-05 22:39:56 +01:00

19 lines
449 B
C++

#include "sys/Syscall.h"
#include <luna/SystemError.h>
syscall_func_t syscalls[] = {
#undef __enumerate
#define __enumerate(name) sys_##name,
enumerate_syscalls(__enumerate)
#undef __enumerate
};
i64 invoke_syscall(Registers* regs, SyscallArgs args, u64 syscall)
{
if (syscall >= Syscalls::__count) { return -ENOSYS; }
auto rc = syscalls[syscall](regs, args);
if (rc.has_error()) return -rc.error();
return (i64)rc.value();
}