[kernel] Add syscall helpers

Added the syscalls/helpers.h file to templatize common kobject syscall
operations. Also moved most syscall implementations to using
process::current() and thread::current() instead of asking the
scheduler.
This commit is contained in:
2020-09-23 00:22:15 -07:00
parent 6780ab1b67
commit d4283731e4
12 changed files with 96 additions and 126 deletions

View File

@@ -3,7 +3,6 @@
#include "log.h"
#include "objects/process.h"
#include "objects/thread.h"
#include "scheduler.h"
namespace syscalls {
@@ -11,14 +10,10 @@ namespace syscalls {
j6_status_t
process_koid(j6_koid_t *koid)
{
if (koid == nullptr) {
if (koid == nullptr)
return j6_err_invalid_arg;
}
TCB *tcb = scheduler::get().current();
process &p = thread::from_tcb(tcb)->parent();
*koid = p.koid();
*koid = process::current().koid();
return j6_status_ok;
}
@@ -26,8 +21,7 @@ j6_status_t
process_exit(int64_t status)
{
auto &s = scheduler::get();
TCB *tcb = s.current();
process &p = thread::from_tcb(tcb)->parent();
process &p = process::current();
log::debug(logs::syscall, "Process %llx exiting with code %d", p.koid(), status);