Luna/kernel/src/sys/Syscall.cpp

28 lines
873 B
C++
Raw Normal View History

2022-09-29 17:17:43 +00:00
#include "sys/Syscall.h"
#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);
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, (const char*)context->rdi, context->rsi);
break;
2022-09-29 18:06:18 +00:00
case SYS_paint: sys_paint(context, context->rdi, context->rsi, context->r10, context->r8, context->r9); break;
case SYS_rand: sys_rand(context); break;
case SYS_version: sys_version(context, (char*)context->rdi, context->rsi); break;
case SYS_gettid: sys_gettid(context); break;
2022-09-29 17:17:43 +00:00
default: context->rax = -1; break;
}
}