[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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user