aboutsummaryrefslogtreecommitdiff
path: root/common/uapi
diff options
context:
space:
mode:
Diffstat (limited to 'common/uapi')
-rw-r--r--common/uapi/dispatch.c9
-rw-r--r--common/uapi/ipc.c42
2 files changed, 20 insertions, 31 deletions
diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c
index 27cc001..2cf19fb 100644
--- a/common/uapi/dispatch.c
+++ b/common/uapi/dispatch.c
@@ -10,6 +10,8 @@
#include <apos/debug.h>
#include <apos/uapi.h>
+#include <arch/proc.h>
+
/** Syscall number to syscall handler conversion. */
static const sys_t syscall_table[] = {
/* noop */
@@ -79,10 +81,11 @@ SYSCALL_DEFINE1(putch)(sys_arg_t a){
return SYS_RET1(OK);
}
-struct sys_ret syscall_dispatch(sys_arg_t syscall, sys_arg_t a, sys_arg_t b,
- sys_arg_t c, sys_arg_t d, sys_arg_t e)
+struct sys_ret handle_syscall(struct tcb *t,
+ sys_arg_t syscall, sys_arg_t a, sys_arg_t b,
+ sys_arg_t c, sys_arg_t d, sys_arg_t e)
{
- struct tcb *t = cur_tcb();
+ adjust_syscall(t);
size_t sc = syscall;
if (sc >= ARRAY_SIZE(syscall_table)) {
diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c
index 34f707a..cb53ee3 100644
--- a/common/uapi/ipc.c
+++ b/common/uapi/ipc.c
@@ -8,6 +8,7 @@
#include <apos/uapi.h>
#include <apos/tcb.h>
+#include <apos/ipi.h>
/**
* IPC server notification syscall handler.
@@ -114,36 +115,21 @@ SYSCALL_DEFINE4(ipc_resp)(sys_arg_t d0, sys_arg_t d1, sys_arg_t d2,
* \todo Implement.
*
* @param tid Thread ID to notify.
- * @param swap Whether to swap immediately if possible.
* @return \ref OK and 0.
*/
-SYSCALL_DEFINE2(ipc_notify)(sys_arg_t tid, sys_arg_t swap){
- /** \todo masquerade as kernel call, set from to 0 and set us as
- * notify type, no arguments as that would require too much state
- * handling for my liking. Instead, a server and a client have to agree
- * on some rpc API, and ipc_notify is just used to asynchronously inform
- * the client that it should check the status of its async operations.
- * Arguably slower than directly telling the client which operation was
- * finished, but this would require the kernel to keep track of a notify
- * stack. While not impossible, probably too complex. */
+SYSCALL_DEFINE1(ipc_notify)(sys_arg_t tid){
+ struct tcb *t = get_tcb(tid);
+ if (t->notify_state == NOTIFY_QUEUED)
+ return SYS_RET1(OK);
+
+ if (t->notify_state == NOTIFY_RUNNING) {
+ t->notify_state = NOTIFY_QUEUED;
+ return SYS_RET1(OK);
+ }
+
+ t->notify_state = NOTIFY_QUEUED;
+ if (running(t))
+ send_ipi(t);
- /* Something like
- *
- * struct tcb *t = get_tcb(tid);
- * if (t->notify_state == NOTIFY_QUEUED)
- * return;
- *
- * if (t->notify_state == NOTIFY_RUNNING) {
- * t->notify = NOTIFY_QUEUED;
- * return;
- * }
- *
- * t->notify_state = NOTIFY_QUEUED;
- * if (swap)
- * do_swap(); // clears t->notify when swapped to
- * // if already running in base state, interrupt,
- * otherwise wait for return from rpc. If not running,
- * just queue the interrupt.
- */
return SYS_RET1(OK);
}