aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-09-22 17:36:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-09-22 17:36:18 +0300
commitae3905ebeb415e12667777463e36df6e00ca992c (patch)
tree18d1c528a16fafeeb0b2c15d6c54a0077c573f9d
parentba8c7b300fbbf062453ef8858fac0f84dd25a518 (diff)
downloadkmi-ae3905ebeb415e12667777463e36df6e00ca992c.tar.gz
kmi-ae3905ebeb415e12667777463e36df6e00ca992c.zip
add assign syscall skeleton
-rw-r--r--common/uapi/conf.c2
-rw-r--r--common/uapi/dispatch.c1
-rw-r--r--common/uapi/proc.c15
-rw-r--r--include/apos/caps.h3
-rw-r--r--include/apos/syscalls.h5
-rw-r--r--include/apos/uapi.h14
6 files changed, 38 insertions, 2 deletions
diff --git a/common/uapi/conf.c b/common/uapi/conf.c
index bf4b42c..867d182 100644
--- a/common/uapi/conf.c
+++ b/common/uapi/conf.c
@@ -12,6 +12,8 @@
#include <apos/sizes.h>
#include <apos/uapi.h>
+/** \todo stack size should really be set on a per-thread basis, and are the
+ * conf*-syscalls even necessary? */
size_t __thread_stack_size = SZ_2M;
size_t __call_stack_size = SZ_2M;
diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c
index 30b2e2e..6d70cd4 100644
--- a/common/uapi/dispatch.c
+++ b/common/uapi/dispatch.c
@@ -42,6 +42,7 @@ static const sys_t syscall_table[] = {
[SYS_FORK] = sys_fork,
[SYS_EXEC] = sys_exec,
[SYS_SWAP] = sys_swap,
+ [SYS_ASSIGN] = sys_assign,
/* conf */
[SYS_CONF_SET] = sys_conf_set,
diff --git a/common/uapi/proc.c b/common/uapi/proc.c
index 67fe141..a48b7eb 100644
--- a/common/uapi/proc.c
+++ b/common/uapi/proc.c
@@ -89,7 +89,7 @@ SYSCALL_DEFINE2(exec)(sys_arg_t bin, sys_arg_t interp){
*
* @return No?
*/
-SYSCALL_DEFINE0(kill)()
+SYSCALL_DEFINE1(kill)(sys_arg_t tid)
{
return (struct sys_ret){ OK, 0, 0, 0, 0, 0};
}
@@ -110,3 +110,16 @@ SYSCALL_DEFINE1(swap)(sys_arg_t tid){
* be used for message passing? */
return (struct sys_ret){ OK, 0, 0, 0, 0, 0 };
}
+
+/**
+ * Assign syscall handler.
+ *
+ * \todo Implement.
+ * @param tid Thread to assign to \p cpu.
+ * @param cpu Cpu to run \p tid on.
+ * @return \ref OK.
+ */
+SYSCALL_DEFINE2(assign)(sys_arg_t tid, sys_arg_t cpu)
+{
+ return (struct sys_ret){OK, 0, 0, 0, 0, 0};
+}
diff --git a/include/apos/caps.h b/include/apos/caps.h
index e8ef76b..b64b05a 100644
--- a/include/apos/caps.h
+++ b/include/apos/caps.h
@@ -22,6 +22,9 @@ enum {
/** Thread is allowed to force interrupt to callback in other thread. */
CAP_CALL = (1 << 2),
+
+ /** Thread is allowed to assign threads to processors. */
+ CAP_ASSIGN = (1 << 3),
};
/**
diff --git a/include/apos/syscalls.h b/include/apos/syscalls.h
index 1746255..5a3f2eb 100644
--- a/include/apos/syscalls.h
+++ b/include/apos/syscalls.h
@@ -81,7 +81,7 @@ enum {
SYS_IPC_RESP,
/** IPC notify thread, essentially interrupt or signal. */
- SYS_IPC_NOTIFY
+ SYS_IPC_NOTIFY,
/** @} */
/** @name Process management. */
@@ -101,6 +101,9 @@ enum {
/** Switch running process. */
SYS_SWAP,
+ /** Assign thread to cpu. */
+ SYS_ASSIGN,
+
/** @} */
/** @name Kernel management. */
diff --git a/include/apos/uapi.h b/include/apos/uapi.h
index 4fab0ec..8a3deea 100644
--- a/include/apos/uapi.h
+++ b/include/apos/uapi.h
@@ -559,6 +559,20 @@ SYSCALL_DECLARE1(kill, tid);
* @return \ref OK and 0.
*/
SYSCALL_DECLARE1(swap, tid);
+
+/**
+ * Assign syscall.
+ *
+ * Assign \p tid to \p cpu, immediately swaps from whetever was running on \p cpu.
+ *
+ * @param tid Thread to assign to \p cpu.
+ * @param cpu Cpu to run \p tid on.
+ * @param c Unused.
+ * @param d Unused.
+ * @param e Unused.
+ * @return \ref OK and 0.
+ */
+SYSCALL_DECLARE2(assign, tid, cpu);
/** @} */
/** @name Configuration syscalls. */