aboutsummaryrefslogtreecommitdiff
path: root/common/dispatch.c
blob: 7fc13cf0ec215cb1d2ee978c6d04c22e77574124 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <apos/uapi.h>
#include <apos/ipi.h>

/**
 * @file dispatch.c
 *
 * Interface between assembly and C for dispatching syscalls/IPIs.
 * In apos, IPIs are a higher level concept and is not expected to be handled by
 * the underlying architecture. Instead, we only require that there is some way
 * to trigger an interrupt in some other core, and check if the interrupt was an
 * IPI or syscall in C.
 */

/**
 * Syscall/IPI handler.
 * If a syscall was triggered, parameters have the meaning they are given.
 * Otherwise, they are meaningless and unused.
 *
 * @param a Syscall number.
 * @param b Argument 0.
 * @param c Argument 1.
 * @param d Argument 2.
 * @param e Argument 3.
 * @param f Argument 4.
 * @return Return value of taken action.
 */
struct sys_ret dispatch(sys_arg_t a, sys_arg_t b, sys_arg_t c,
                        sys_arg_t d, sys_arg_t e, sys_arg_t f)
{
	struct tcb *t = cur_tcb();
	if (clear_ipi(t))
		return handle_ipi(t);

	return handle_syscall(t, a, b, c, d, e, f);
}