diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-11-09 16:27:23 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2022-11-09 17:27:11 +0200 |
| commit | a3e45d5dcaf1bf3a9e684b5fcc301413ec994a9b (patch) | |
| tree | ae319c8f389e7ca39bbdd4b114655f8604563305 /include/apos | |
| parent | 2b5533aefef026fe7bada314ebdb2651b809979a (diff) | |
| download | kmi-a3e45d5dcaf1bf3a9e684b5fcc301413ec994a9b.tar.gz kmi-a3e45d5dcaf1bf3a9e684b5fcc301413ec994a9b.zip | |
add basic IPI structure
Diffstat (limited to 'include/apos')
| -rw-r--r-- | include/apos/ipi.h | 37 | ||||
| -rw-r--r-- | include/apos/tcb.h | 19 | ||||
| -rw-r--r-- | include/apos/uapi.h | 10 |
3 files changed, 62 insertions, 4 deletions
diff --git a/include/apos/ipi.h b/include/apos/ipi.h new file mode 100644 index 0000000..c895d58 --- /dev/null +++ b/include/apos/ipi.h @@ -0,0 +1,37 @@ +#ifndef APOS_IPI_H +#define APOS_IPI_H + +/** + * @file ipi.h + * + * IPI function definitions. + */ + +#include <apos/types.h> +#include <apos/uapi.h> +#include <apos/tcb.h> + +/** + * Clear potential IPI in \p t, and return its value. + * + * @param t \ref tcb to clear possible IPI status of. + * @return \ref true if \p was interrupted by IPI, \ref false otherwise. + */ +bool clear_ipi(struct tcb *t); + +/** + * Send IPI to \p t. Assumes \c running(t). + * + * @param t \ref tcb to send IPI to. + */ +void send_ipi(struct tcb *t); + +/** + * Handle IPI. + * + * @param t Thread who was interrupted by IPI. + * @return Possible arguments to IPI. + */ +struct sys_ret handle_ipi(struct tcb *t); + +#endif /* APOS_IPI_H */ diff --git a/include/apos/tcb.h b/include/apos/tcb.h index b92cd10..0368957 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -146,6 +146,9 @@ struct tcb { /** Notifcation state of thread. */ enum tcb_notify notify_state; + + /** Whether thread has gotten an IPI */ + bool ipi; }; /** @@ -266,6 +269,14 @@ stat_t detach_proc(struct tcb *r, struct tcb *t); struct tcb *cur_tcb(); /** + * Get thread currently running on cpu \p cpu_id. + * + * @param cpu_id CPU whose currently running thread to get. + * @return \ref tcb running on cpu. + */ +struct tcb *cpu_tcb(id_t cpu_id); + +/** * Get currently executing process. * * @return Effective process \ref tcb. @@ -337,4 +348,12 @@ stat_t alloc_stacks(struct tcb *t); */ void set_return(struct tcb *t, vm_t r); +/** + * Check whether \p t is currently running on some cpu. + * + * @param t \ref tcb to check. + * @return \c true if it is running, \c false otherwise. + */ +bool running(struct tcb *t); + #endif /* APOS_TCB_H */ diff --git a/include/apos/uapi.h b/include/apos/uapi.h index 084c1fa..83de7eb 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -500,13 +500,13 @@ SYSCALL_DECLARE4(ipc_resp, d0, d1, d2, d3); * Notify thread syscall. * * @param tid Thread ID to notify. - * @param swap Whether to immediately swap. + * @param b Unused. * @param c Unused. * @param d Unused. * @param e Unused. * @return \ref OK and 0. */ -SYSCALL_DECLARE2(ipc_notify, tid, swap); +SYSCALL_DECLARE1(ipc_notify, tid); /** @} */ /** @name Process handling syscalls. */ @@ -683,6 +683,7 @@ SYSCALL_DECLARE1(poweroff, type); /** * Dispatch to correct syscall handler. * + * @param t Thread to do syscall on. * @param syscall Syscall number. * @param a Syscall argument 0. * @param b Syscall argument 1. @@ -691,8 +692,9 @@ SYSCALL_DECLARE1(poweroff, type); * @param e Syscall argument 4. * @return Whatever the specified syscall returns. */ -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); /** \todo Should I add variable names as well, to make the documentation a bit * more readable? */ |
