syscall: add task_self, task_get_address_space, and vm_region_kill

This commit is contained in:
2026-02-23 18:43:49 +00:00
parent fd1bc0ad5f
commit 5f0654430d
8 changed files with 533 additions and 28 deletions

View File

@@ -14,6 +14,35 @@ extern kern_status_t sys_task_exit(int status)
return KERN_UNIMPLEMENTED;
}
kern_status_t sys_task_self(kern_handle_t *out)
{
struct task *self = current_task();
if (!validate_access_w(self, out, sizeof *out)) {
return KERN_MEMORY_FAULT;
}
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->t_base);
handle_slot->h_object = &self->t_base;
*out = handle;
return KERN_OK;
}
kern_status_t sys_task_create(
kern_handle_t parent_handle,
const char *name,
@@ -175,6 +204,57 @@ kern_status_t sys_task_create_thread(
return KERN_OK;
}
kern_status_t sys_task_get_address_space(
kern_handle_t task_handle,
kern_handle_t *out)
{
struct task *self = current_task();
if (!validate_access_w(self, out, sizeof *out)) {
return KERN_MEMORY_FAULT;
}
unsigned long flags;
task_lock_irqsave(self, &flags);
struct handle *handle_slot = NULL;
kern_handle_t handle;
struct object *task_obj = NULL;
handle_flags_t handle_flags = 0;
kern_status_t status = task_resolve_handle(
self,
task_handle,
&task_obj,
&handle_flags);
if (status != KERN_OK) {
task_unlock_irqrestore(self, flags);
return status;
}
status = handle_table_alloc_handle(
self->t_handles,
&handle_slot,
&handle);
if (status != KERN_OK) {
task_unlock_irqrestore(self, flags);
return status;
}
struct task *task = task_cast(task_obj);
if (!task) {
handle_table_free_handle(self->t_handles, handle);
task_unlock_irqrestore(self, flags);
return KERN_INVALID_ARGUMENT;
}
handle_slot->h_object = &task->t_address_space->vr_base;
object_add_handle(&task->t_address_space->vr_base);
task_unlock_irqrestore(self, flags);
*out = handle;
return KERN_OK;
}
kern_status_t sys_thread_start(kern_handle_t thread_handle)
{
unsigned long flags;