[kernel] Pass objects not handles to syscall impls
This commit contains a couple large, interdependent changes: - In preparation for capability checking, the _syscall_verify_* functions now load most handles passed in, and verify that they exist and are of the correct type. Lists and out-handles are not converted to objects. - Also in preparation for capability checking, the internal representation of handles has changed. j6_handle_t is now 32 bits, and a new j6_cap_t (also 32 bits) is added. Handles of a process are now a util::map<j6_handle_t, handle> where handle is a new struct containing the id, capabilities, and object pointer. - The kernel object definition DSL gained a few changes to support auto generating the handle -> object conversion in the _syscall_verify_* functions, mostly knowing the object type, and an optional "cname" attribute on objects where their names differ from C++ code. (Specifically vma/vm_area) - Kernel object code and other code under kernel/objects is now in a new obj:: namespace, because fuck you <cstdlib> for putting "system" in the global namespace. Why even have that header then? - Kernel object types constructed with the construct_handle helper now have a creation_caps static member to declare what capabilities a newly created object's handle should have.
This commit is contained in:
@@ -6,25 +6,24 @@
|
||||
#include "objects/thread.h"
|
||||
#include "syscalls/helpers.h"
|
||||
|
||||
using namespace obj;
|
||||
|
||||
namespace syscalls {
|
||||
|
||||
j6_status_t
|
||||
thread_create(j6_handle_t *handle, j6_handle_t proc, uintptr_t stack_top, uintptr_t entrypoint)
|
||||
thread_create(j6_handle_t *self, process *proc, uintptr_t stack_top, uintptr_t entrypoint)
|
||||
{
|
||||
thread &parent_th = thread::current();
|
||||
process &parent_pr = parent_th.parent();
|
||||
|
||||
process *owner = get_handle<process>(proc);
|
||||
if (!owner) return j6_err_invalid_arg;
|
||||
|
||||
thread *child = owner->create_thread(stack_top);
|
||||
thread *child = proc->create_thread(stack_top);
|
||||
child->add_thunk_user(entrypoint);
|
||||
*handle = child->self_handle();
|
||||
*self = child->self_handle();
|
||||
child->clear_state(thread::state::loading);
|
||||
child->set_state(thread::state::ready);
|
||||
|
||||
log::debug(logs::task, "Thread %llx:%llx spawned new thread %llx:%llx",
|
||||
parent_pr.koid(), parent_th.koid(), owner->koid(), child->koid());
|
||||
parent_pr.koid(), parent_th.koid(), proc->koid(), child->koid());
|
||||
|
||||
return j6_status_ok;
|
||||
}
|
||||
@@ -41,14 +40,10 @@ thread_exit(int32_t status)
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
thread_kill(j6_handle_t handle)
|
||||
thread_kill(thread *self)
|
||||
{
|
||||
thread *th = get_handle<thread>(handle);
|
||||
if (!th)
|
||||
return j6_err_invalid_arg;
|
||||
|
||||
log::debug(logs::task, "Killing thread %llx", th->koid());
|
||||
th->exit(-1);
|
||||
log::debug(logs::task, "Killing thread %llx", self->koid());
|
||||
self->exit(-1);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user