[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:
@@ -14,6 +14,8 @@ public:
|
||||
channel();
|
||||
virtual ~channel();
|
||||
|
||||
static constexpr kobject::type type = kobject::type::channel;
|
||||
|
||||
/// Check if the channel has space for a message to be sent
|
||||
inline bool can_send() const { return check_signal(j6_signal_channel_can_send); }
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ public:
|
||||
endpoint();
|
||||
virtual ~endpoint();
|
||||
|
||||
static constexpr kobject::type type = kobject::type::endpoint;
|
||||
|
||||
/// Close the endpoint, waking all waiting processes with an error
|
||||
void close();
|
||||
|
||||
|
||||
@@ -10,4 +10,6 @@ class event :
|
||||
public:
|
||||
event() :
|
||||
kobject(type::event) {}
|
||||
|
||||
static constexpr kobject::type type = kobject::type::event;
|
||||
};
|
||||
|
||||
@@ -24,6 +24,8 @@ public:
|
||||
/// Destructor.
|
||||
virtual ~process();
|
||||
|
||||
static constexpr kobject::type type = kobject::type::process;
|
||||
|
||||
/// Get the currently executing process.
|
||||
static process & current();
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
/// Destructor
|
||||
virtual ~thread();
|
||||
|
||||
static constexpr kobject::type type = kobject::type::thread;
|
||||
|
||||
/// Get the currently executing thread.
|
||||
static thread & current();
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
vm_area(size_t size, vm_flags flags = vm_flags::none);
|
||||
virtual ~vm_area();
|
||||
|
||||
static constexpr kobject::type type = kobject::type::vma;
|
||||
|
||||
/// Get the current virtual size of the memory area
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user