aboutsummaryrefslogtreecommitdiff
path: root/common/uapi
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-07-31 22:24:29 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-07-31 22:24:29 +0300
commit6ad1b899ed93f8bc110cdec7a722c8740f9f8d66 (patch)
tree99fe36028ffc4583c59e77d03bea2ade7a6c5ace /common/uapi
parent3212707a9ab549119ad0ad6441a07fe774c99f3b (diff)
downloadkmi-6ad1b899ed93f8bc110cdec7a722c8740f9f8d66.tar.gz
kmi-6ad1b899ed93f8bc110cdec7a722c8740f9f8d66.zip
start working on irqs
Diffstat (limited to 'common/uapi')
-rw-r--r--common/uapi/dispatch.c1
-rw-r--r--common/uapi/irq.c28
-rw-r--r--common/uapi/proc.c1
3 files changed, 30 insertions, 0 deletions
diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c
index a9caa1e..5b523cc 100644
--- a/common/uapi/dispatch.c
+++ b/common/uapi/dispatch.c
@@ -76,6 +76,7 @@ void handle_syscall(sys_arg_t syscall, sys_arg_t a, sys_arg_t b,
case SYS_GET_CAP: sys_get_cap(t, a, b, c, d, e); break;
case SYS_CLEAR_CAP: sys_clear_cap(t, a, b, c, d, e); break;
case SYS_POWEROFF: sys_poweroff(t, a, b, c, d, e); break;
+ case SYS_IRQ_REQ: sys_irq_req(t, a, b, c, d, e); break;
default:
error("Syscall %zu outside allowed range [0 - %i]\n", syscall,
SYS_NUM - 1);
diff --git a/common/uapi/irq.c b/common/uapi/irq.c
new file mode 100644
index 0000000..3aa040e
--- /dev/null
+++ b/common/uapi/irq.c
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier: copyleft-next-0.3.1 */
+
+/**
+ * @file irq.c
+ * IRQ request syscall handling implementation.
+ */
+
+#include <kmi/uapi.h>
+#include <kmi/irq.h>
+
+/**
+ * Actual IRQ handling request syscall handler.
+ *
+ * @param t Current tcb.
+ * @param id IRQ id to request to handle.
+ *
+ * @return OK on success, non-zero otherwise.
+ */
+SYSCALL_DEFINE1(irq_req)(struct tcb *t, sys_arg_t id)
+{
+ if (!has_cap(t->caps, CAP_IRQ))
+ return_args1(t, ERR_PERM);
+
+ if (!t->callback)
+ return_args1(t, ERR_NF);
+
+ return_args1(t, register_irq(t, id));
+}
diff --git a/common/uapi/proc.c b/common/uapi/proc.c
index 0ec19fb..b6018b8 100644
--- a/common/uapi/proc.c
+++ b/common/uapi/proc.c
@@ -151,6 +151,7 @@ SYSCALL_DEFINE1(kill)(struct tcb *t, sys_arg_t tid)
return_args1(t, ERR_PERM);
/** @todo implement */
+ /** @todo remember to unregister IRQ handlers */
return_args1(t, OK);
}