[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

@@ -2,31 +2,26 @@
#include "j6/types.h"
#include "log.h"
#include "scheduler.h"
#include "objects/thread.h"
namespace syscalls {
j6_status_t
system_log(const char *message)
{
if (message == nullptr) {
if (message == nullptr)
return j6_err_invalid_arg;
}
auto &s = scheduler::get();
TCB *tcb = s.current();
thread *th = thread::from_tcb(tcb);
log::info(logs::syscall, "Message[%llx]: %s", th->koid(), message);
thread &th = thread::current();
log::info(logs::syscall, "Message[%llx]: %s", th.koid(), message);
return j6_status_ok;
}
j6_status_t
system_noop()
{
auto &s = scheduler::get();
TCB *tcb = s.current();
thread *th = thread::from_tcb(tcb);
log::debug(logs::syscall, "Thread %llx called noop syscall.", th->koid());
thread &th = thread::current();
log::debug(logs::syscall, "Thread %llx called noop syscall.", th.koid());
return j6_status_ok;
}