From c3ea570bae8f7daeac8e0614a958e983fcf9940e Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 22 Aug 2024 14:57:14 +0300 Subject: add ipc_notify testcase, remove ipc_ghost + A bit easier to implement just ignoring the ipc_resp() arguments than try to enforce that a notification is exited from by ipc_ghost(), especially in cases where the root process has been killed. --- include/kmi/attrs.h | 1 + include/kmi/notify.h | 4 ++-- include/kmi/syscalls.h | 7 ++----- include/kmi/tcb.h | 2 +- include/kmi/uapi.h | 26 ++++++++------------------ 5 files changed, 14 insertions(+), 26 deletions(-) (limited to 'include') diff --git a/include/kmi/attrs.h b/include/kmi/attrs.h index 56aca34..9038690 100644 --- a/include/kmi/attrs.h +++ b/include/kmi/attrs.h @@ -50,6 +50,7 @@ /** Don't inline function. */ #define __noinline __attribute__((noinline)) +/** Always inline function. */ #define __inline inline __attribute__((always_inline)) /** Function should not return. */ diff --git a/include/kmi/notify.h b/include/kmi/notify.h index c0c5d8b..4e5b8b6 100644 --- a/include/kmi/notify.h +++ b/include/kmi/notify.h @@ -14,8 +14,8 @@ #include /** - * Try to send a notification to a thread. Sets up a new rpc call, should be - * returned from with \ref ipc_ghost() to restore register state. + * Try to send a notification to a thread. Sets up a new rpc call and sets + * notify flag of the frame to true. * * If the thread is idle, immediately swap to it. * diff --git a/include/kmi/syscalls.h b/include/kmi/syscalls.h index e3d5dad..28e7505 100644 --- a/include/kmi/syscalls.h +++ b/include/kmi/syscalls.h @@ -102,11 +102,8 @@ enum sys_code { /** IPC response from server. */ SYS_IPC_RESP, - /** IPC return without visible side effects. */ - SYS_IPC_GHOST, - /** Notify thread, essentially interrupt or signal. */ - SYS_NOTIFY, + SYS_IPC_NOTIFY, /** @} */ /** @name Process management. */ @@ -191,7 +188,7 @@ enum sys_user { /** Which notifications have arrived. */ enum notify_flag { - /** A signal (\ref sys_notify()). */ + /** A signal (\ref sys_ipc_notify()). */ NOTIFY_SIGNAL = (1 << 0), /** A timer has expired. */ diff --git a/include/kmi/tcb.h b/include/kmi/tcb.h index a3f119b..6cc63b5 100644 --- a/include/kmi/tcb.h +++ b/include/kmi/tcb.h @@ -115,7 +115,7 @@ struct tcb { /** Memory mapping data. Only relevant in root thread. */ struct uvmem uvmem; - /** Address of callback function in servers. */ + /** Address of callback function. */ vm_t callback; /** Address of this thread's stack base. */ diff --git a/include/kmi/uapi.h b/include/kmi/uapi.h index 95c7000..6e5f865 100644 --- a/include/kmi/uapi.h +++ b/include/kmi/uapi.h @@ -552,7 +552,13 @@ SYSCALL_DECLARE5(ipc_tail, pid, d0, d1, d2, d3); SYSCALL_DECLARE5(ipc_kick, pid, d0, d1, d2, d3); /** - * Response syscall. + * Response syscall. If the current rpc frame is a notification frame, the + * arguments will be ignored, turned out to be easier to implement than try to + * enforce an ipc_ghost(), especially in cases where the root process has + * already been killed. Generally this shouldn't be an issue, as the + * notification handler is always aware of when it's being called to handle a + * notification, and can tailor its ipc_resp() to return zero arguments or + * whatever. * * @param t Current tcb. * @param d0 First response argument. @@ -565,22 +571,6 @@ 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 t Current tcb. - * @param a Unused. - * @param b Unused. - * @param c Unused. - * @param d Unused. - * @param e Unused. - * - * Return OK. - */ -SYSCALL_DECLARE0(ipc_ghost); - /** * Notify thread syscall. * @@ -593,7 +583,7 @@ SYSCALL_DECLARE0(ipc_ghost); * * Returns \ref OK and 0. */ -SYSCALL_DECLARE1(notify, tid); +SYSCALL_DECLARE1(ipc_notify, tid); /** @} */ /** @name Process handling syscalls. */ -- cgit v1.3