[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:
@@ -14,8 +14,12 @@
|
||||
|
||||
extern log::logger &g_logger;
|
||||
|
||||
using namespace obj;
|
||||
|
||||
namespace syscalls {
|
||||
|
||||
using system = class ::system;
|
||||
|
||||
j6_status_t
|
||||
log(const char *message)
|
||||
{
|
||||
@@ -33,7 +37,7 @@ noop()
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
system_get_log(j6_handle_t sys, void *buffer, size_t *buffer_len)
|
||||
system_get_log(system *self, void *buffer, size_t *buffer_len)
|
||||
{
|
||||
// Buffer is marked optional, but we need the length, and if length > 0,
|
||||
// buffer is not optional.
|
||||
@@ -43,25 +47,22 @@ system_get_log(j6_handle_t sys, void *buffer, size_t *buffer_len)
|
||||
size_t orig_size = *buffer_len;
|
||||
*buffer_len = g_logger.get_entry(buffer, *buffer_len);
|
||||
if (!g_logger.has_log())
|
||||
system::get().deassert_signal(j6_signal_system_has_log);
|
||||
self->deassert_signal(j6_signal_system_has_log);
|
||||
|
||||
return (*buffer_len > orig_size) ? j6_err_insufficient : j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
system_bind_irq(j6_handle_t sys, j6_handle_t endp, unsigned irq)
|
||||
system_bind_irq(system *self, endpoint *endp, unsigned irq)
|
||||
{
|
||||
endpoint *e = get_handle<endpoint>(endp);
|
||||
if (!e) return j6_err_invalid_arg;
|
||||
|
||||
if (device_manager::get().bind_irq(irq, e))
|
||||
if (device_manager::get().bind_irq(irq, endp))
|
||||
return j6_status_ok;
|
||||
|
||||
return j6_err_invalid_arg;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
system_map_phys(j6_handle_t handle, j6_handle_t * area, uintptr_t phys, size_t size, uint32_t flags)
|
||||
system_map_phys(system *self, j6_handle_t * area, uintptr_t phys, size_t size, uint32_t flags)
|
||||
{
|
||||
// TODO: check to see if frames are already used? How would that collide with
|
||||
// the bootloader's allocated pages already being marked used?
|
||||
@@ -75,7 +76,7 @@ system_map_phys(j6_handle_t handle, j6_handle_t * area, uintptr_t phys, size_t s
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
system_request_iopl(j6_handle_t handle, unsigned iopl)
|
||||
system_request_iopl(system *self, unsigned iopl)
|
||||
{
|
||||
if (iopl != 0 && iopl != 3)
|
||||
return j6_err_invalid_arg;
|
||||
|
||||
Reference in New Issue
Block a user