aboutsummaryrefslogtreecommitdiff
path: root/src/uapi/irq.c
blob: 9bd8ec1a415b17100c3da1d62fa1af11f7714aa7 (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
36
37
38
39
40
41
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
/* Copyright 2023, Kim Kuparinen < kimi.h.kuparinen@gmail.com > */

/**
 * @file irq.c
 * IRQ request syscall handling implementation.
 */

#include <kmi/uapi.h>
#include <kmi/irq.h>

/**
 * Actual IRQ handling request syscall handler.
 *
 * @param t Current tcb.
 *
 * @return OK on success, non-zero otherwise.
 */
SYSCALL_DEFINE1(irq_req)(struct tcb *t, sys_arg_t id)
{
	if (!has_cap(t->caps, CAP_IRQ))
		return_args1(t, ERR_PERM);

	if (!t->callback)
		return_args1(t, ERR_NF);

	return_args1(t, register_irq(t, id));
}

SYSCALL_DEFINE2(req_notification)(struct tcb *t, sys_arg_t tid, sys_arg_t pid)
{
	if (!has_cap(t->caps, CAP_NOTIFICATION))
		return_args1(t, ERR_PERM);

	struct tcb *r = get_tcb(tid);
	if (!r)
		return_args1(t, ERR_INVAL);

	t->notify_id = pid;
	return_args1(t, OK);
}