syscall: task: implement thread_self
This commit is contained in:
@@ -10,6 +10,7 @@ static const virt_addr_t syscall_table[] = {
|
||||
SYSCALL_TABLE_ENTRY(TASK_CREATE, task_create),
|
||||
SYSCALL_TABLE_ENTRY(TASK_CREATE_THREAD, task_create_thread),
|
||||
SYSCALL_TABLE_ENTRY(TASK_GET_ADDRESS_SPACE, task_get_address_space),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_SELF, thread_self),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_START, thread_start),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_EXIT, thread_exit),
|
||||
SYSCALL_TABLE_ENTRY(THREAD_CONFIG_GET, thread_config_get),
|
||||
|
||||
@@ -262,6 +262,37 @@ kern_status_t sys_task_get_address_space(
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
kern_status_t sys_thread_self(kern_handle_t *out)
|
||||
{
|
||||
struct task *self = current_task();
|
||||
if (!validate_access_w(self, out, sizeof *out)) {
|
||||
return KERN_MEMORY_FAULT;
|
||||
}
|
||||
|
||||
struct thread *self_thread = current_thread();
|
||||
|
||||
unsigned long flags;
|
||||
task_lock_irqsave(self, &flags);
|
||||
|
||||
struct handle *handle_slot = NULL;
|
||||
kern_handle_t handle;
|
||||
kern_status_t status = handle_table_alloc_handle(
|
||||
self->t_handles,
|
||||
&handle_slot,
|
||||
&handle);
|
||||
task_unlock_irqrestore(self, flags);
|
||||
|
||||
if (status != KERN_OK) {
|
||||
return status;
|
||||
}
|
||||
|
||||
object_add_handle(&self_thread->tr_base);
|
||||
handle_slot->h_object = &self_thread->tr_base;
|
||||
|
||||
*out = handle;
|
||||
return KERN_OK;
|
||||
}
|
||||
|
||||
kern_status_t sys_thread_start(kern_handle_t thread_handle)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
Reference in New Issue
Block a user