Luna/kernel/src/sys/Syscall.cpp

33 lines
1.3 KiB
C++
Raw Normal View History

2022-09-29 17:17:43 +00:00
#include "sys/Syscall.h"
#include "errno.h"
2022-09-29 17:17:43 +00:00
#include "io/Serial.h"
#include "thread/Scheduler.h"
void Syscall::entry(Context* context)
{
asm volatile("cli");
switch (context->rax)
{
case SYS_exit: // sys_exit
sys_exit(context, (int)context->rdi);
2022-09-29 17:17:43 +00:00
break;
case SYS_yield: // sys_yield
sys_yield(context);
break;
case SYS_sleep: // sys_sleep
sys_sleep(context, context->rdi);
break;
case SYS_write: // sys_write
sys_write(context, (int)context->rdi, context->rsi, (const char*)context->rdx);
2022-09-29 17:17:43 +00:00
break;
2022-10-02 15:01:46 +00:00
case SYS_paint: sys_paint(context, context->rdi, context->rsi, context->rdx, context->r10, context->r8); break;
2022-09-29 18:06:18 +00:00
case SYS_rand: sys_rand(context); break;
case SYS_gettid: sys_gettid(context); break;
2022-10-06 15:13:34 +00:00
case SYS_mmap: sys_mmap(context, (void*)context->rdi, context->rsi, (int)context->rdx); break;
case SYS_munmap: sys_munmap(context, (void*)context->rdi, context->rsi); break;
case SYS_open: sys_open(context, (const char*)context->rdi, (int)context->rsi); break;
case SYS_read: sys_read(context, (int)context->rdi, context->rsi, (char*)context->rdx); break;
case SYS_close: sys_close(context, (int)context->rdi); break;
default: context->rax = -ENOSYS; break;
2022-09-29 17:17:43 +00:00
}
}