Kernel: Add a clock() system call
This commit is contained in:
parent
3a9dddaa57
commit
62a2bcf2ff
@ -17,6 +17,7 @@
|
||||
#define SYS_exec 12
|
||||
#define SYS_fcntl 13
|
||||
#define SYS_mprotect 14
|
||||
#define SYS_clock 15
|
||||
|
||||
namespace Syscall
|
||||
{
|
||||
@ -39,4 +40,5 @@ void sys_close(Context* context, int fd);
|
||||
void sys_seek(Context* context, int fd, long offset, int whence);
|
||||
void sys_exec(Context* context, const char* pathname);
|
||||
void sys_fcntl(Context* context, int fd, int command, uintptr_t arg);
|
||||
void sys_mprotect(Context* context, void* address, size_t size, int prot);
|
||||
void sys_mprotect(Context* context, void* address, size_t size, int prot);
|
||||
void sys_clock(Context* context);
|
@ -26,6 +26,7 @@ void Syscall::entry(Context* context)
|
||||
case SYS_exec: sys_exec(context, (const char*)context->rdi); break;
|
||||
case SYS_fcntl: sys_fcntl(context, (int)context->rdi, (int)context->rsi, context->rdx); break;
|
||||
case SYS_mprotect: sys_mprotect(context, (void*)context->rdi, context->rsi, (int)context->rdx); break;
|
||||
case SYS_clock: sys_clock(context); break;
|
||||
default: context->rax = -ENOSYS; break;
|
||||
}
|
||||
VMM::exit_syscall_context();
|
||||
|
9
kernel/src/sys/clock.cpp
Normal file
9
kernel/src/sys/clock.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include "interrupts/Context.h"
|
||||
#include "thread/Scheduler.h"
|
||||
|
||||
void sys_clock(Context* context)
|
||||
{
|
||||
Task* current_task = Scheduler::current_task();
|
||||
context->rax = (long)current_task->cpu_time;
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue
Block a user