[kernel] Move bind_irq syscall to new system object

In order to implement capabilities on system resources like IRQs so that
they may be restricted to drivers only, add a new 'system' kobject type,
and move the bind_irq functionality from endpoint to system.

Also fix some stack bugs passing the initial handles to a program.
This commit is contained in:
2020-10-18 20:45:06 -07:00
parent 2ad90dcb5c
commit 8bb9e22218
14 changed files with 80 additions and 28 deletions

View File

@@ -1,8 +1,11 @@
#include "j6/errors.h"
#include "j6/types.h"
#include "device_manager.h"
#include "log.h"
#include "objects/endpoint.h"
#include "objects/thread.h"
#include "syscalls/helpers.h"
namespace syscalls {
@@ -25,4 +28,23 @@ system_noop()
return j6_status_ok;
}
j6_status_t
system_get_log(j6_handle_t sys, j6_handle_t *log)
{
return j6_err_nyi;
}
j6_status_t
system_bind_irq(j6_handle_t sys, j6_handle_t endp, unsigned irq)
{
// TODO: check capabilities on sys handle
endpoint *e = get_handle<endpoint>(endp);
if (!e) return j6_err_invalid_arg;
if (device_manager::get().bind_irq(irq, e))
return j6_status_ok;
return j6_err_invalid_arg;
}
} // namespace syscalls