aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-07-01 23:34:57 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-07-01 23:34:57 +0300
commit7ad9c01dad7b1b46eced8290b8b991383d648188 (patch)
treecd528648af552974b90117efef431659ef5f0cc6 /include
parent9ff67d879b4695e0c9910b7276f3959c005c7b19 (diff)
downloadkmi-7ad9c01dad7b1b46eced8290b8b991383d648188.tar.gz
kmi-7ad9c01dad7b1b46eced8290b8b991383d648188.zip
expand notifications into interrupt handlers
+ Terminology is still a bit poor, and will still have to write documentation + implement ipis properly
Diffstat (limited to 'include')
-rw-r--r--include/kmi/caps.h5
-rw-r--r--include/kmi/notify.h9
-rw-r--r--include/kmi/syscalls.h12
-rw-r--r--include/kmi/tcb.h5
-rw-r--r--include/kmi/uapi.h30
5 files changed, 58 insertions, 3 deletions
diff --git a/include/kmi/caps.h b/include/kmi/caps.h
index 2813634..8af9293 100644
--- a/include/kmi/caps.h
+++ b/include/kmi/caps.h
@@ -26,7 +26,7 @@ enum {
/** Thread is allowed to modify process statuses, create/exec/fork/etc. */
CAP_PROC = (1 << 1),
- /** Thread is allowed to force interrupt to callback in other thread. */
+ /** Thread is allowed to force notification in other thread. */
CAP_CALL = (1 << 2),
/** Thread is allowed to shut down system. */
@@ -37,6 +37,9 @@ enum {
/** Thread is allowed to request to handle IRQs. */
CAP_IRQ = (1 << 5),
+
+ /** Thread is allowed to request notification handler. */
+ CAP_NOTIFICATION = (1 << 6),
};
/**
diff --git a/include/kmi/notify.h b/include/kmi/notify.h
new file mode 100644
index 0000000..0a17654
--- /dev/null
+++ b/include/kmi/notify.h
@@ -0,0 +1,9 @@
+#ifndef KMI_NOTIFY_H
+#define KMI_NOTIFY_H
+
+#include <kmi/tcb.h>
+
+/* Implemented in ipc.c */
+void notify(struct tcb *t);
+
+#endif /* KMI_NOTIFY_H */
diff --git a/include/kmi/syscalls.h b/include/kmi/syscalls.h
index e503709..23fc799 100644
--- a/include/kmi/syscalls.h
+++ b/include/kmi/syscalls.h
@@ -18,7 +18,7 @@
/** enum for now, possibly macros in the future once I get an approximate idea of
* which syscalls are necessary etc. */
-enum {
+enum sys_code {
/**
* @name Misc.
* Implementation in \ref dispatch.c instead of a separate file, as I
@@ -96,6 +96,9 @@ enum {
/** IPC response from server. */
SYS_IPC_RESP,
+ /** IPC return without visible side effects. */
+ SYS_IPC_GHOST,
+
/** IPC notify thread, essentially interrupt or signal. */
SYS_IPC_NOTIFY,
/** @} */
@@ -148,11 +151,18 @@ enum {
/** Request to handle IRQ. */
SYS_IRQ_REQ,
+ /** Request a notification handler. */
+ SYS_REQ_NOTIFICATION,
+
/** @} */
SYS_NUM,
};
+enum sys_user {
+ SYS_USER_NOTIFY,
+};
+
/* function declarations should be somewhere else, this file could be used in
* userspace applications as well */
diff --git a/include/kmi/tcb.h b/include/kmi/tcb.h
index 6614d62..999b6a8 100644
--- a/include/kmi/tcb.h
+++ b/include/kmi/tcb.h
@@ -177,6 +177,11 @@ struct tcb {
/** Cpu currently executing this thread. */
id_t cpu_id;
+ /** In which process to run notifications. Note that this is currently
+ * set in the syscall handlers due to the different rules for inheriting
+ * this id, might change in the future. */
+ id_t notify_id;
+
/** Capabilities of thread. */
capflags_t caps;
diff --git a/include/kmi/uapi.h b/include/kmi/uapi.h
index 5e5f446..1631500 100644
--- a/include/kmi/uapi.h
+++ b/include/kmi/uapi.h
@@ -427,7 +427,8 @@ SYSCALL_DECLARE0(ticks);
*
* @param t Current tcb.
* @param ticks Number of ticks from now.
- * @param mult Number of times to trigger.
+ * @param mult Multiplier for \p ticks if we're on 32bit systems to produce a
+ * combined 64 bit value. Ignored on 64bit systems.
* @param c Unused.
* @param d Unused.
* @param e Unused.
@@ -556,6 +557,16 @@ SYSCALL_DECLARE5(ipc_kick, pid, d0, d1, d2, d3);
SYSCALL_DECLARE4(ipc_resp, d0, d1, d2, d3);
/**
+ * Returns to caller but without changing any visible state. Primarily used when
+ * returning from interrupt handlers, like notifications, timers or external
+ * devices.
+ *
+ * @param r Current tcb.
+ *
+ */
+SYSCALL_DECLARE0(ipc_ghost);
+
+/**
* Notify thread syscall.
*
* @param t Current tcb.
@@ -748,6 +759,22 @@ SYSCALL_DECLARE2(get_cap, tid, off);
SYSCALL_DECLARE3(clear_cap, tid, off, cap);
/**
+ * Set which process to move notifications to for thread.
+ * @todo Should converge on either calling everything irq or notification or
+ * whatever, but mixing both is a bit dumb.
+ *
+ * @param t Current tcb.
+ * @param tid Thread whose notifications should be moved.
+ * @param pid Process that is willing to handle the notifications.
+ * @param c Unused.
+ * @param d Unused.
+ * @param e Unused.
+ *
+ * Returns \ref OK.
+ */
+SYSCALL_DECLARE2(req_notification, tid, pid);
+
+/**
* Power off syscall.
*
* Either shut down or reboot system.
@@ -792,6 +819,7 @@ SYSCALL_DECLARE0(sleep);
* @todo document error codes better.
*/
SYSCALL_DECLARE1(irq_req, id);
+
/** @} */
/**