MOS Source Code
Loading...
Searching...
No Matches
ksyscall_entry.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
6#include "mos/tasks/signal.h"
7
9#include <mos/syscall/table.h>
10#include <mos/types.h>
11#include <mos_stdio.h>
12
13reg_t ksyscall_enter(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5, reg_t arg6)
14{
15 const pf_point_t ev = profile_enter();
16 const reg_t ret = dispatch_syscall(number, arg1, arg2, arg3, arg4, arg5, arg6);
17 profile_leave(ev, "syscall.%lu.%s", number, syscall_names[number]);
18
19 if (IS_ERR_VALUE(ret))
20 {
21 // handle -EFAULT by sending SIGSEGV to the current thread
22 if (ret == (reg_t) -EFAULT)
24 }
25
26 MOS_ASSERT_X(current_thread->state == THREAD_STATE_RUNNING, "thread %pt is not in 'running' state", (void *) current_thread);
27 return ret;
28}
#define MOS_ASSERT_X(cond, msg,...)
Definition assert.h:15
should_inline reg_t dispatch_syscall(const reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5, reg_t arg6)
Definition dispatcher.h:23
long signal_send_to_thread(thread_t *target, signal_t signal)
Send a signal to a thread.
Definition signal.c:92
reg_t ksyscall_enter(reg_t number, reg_t arg1, reg_t arg2, reg_t arg3, reg_t arg4, reg_t arg5, reg_t arg6)
#define IS_ERR_VALUE(x)
Definition mos_global.h:126
#define current_thread
Definition platform.h:30
@ THREAD_STATE_RUNNING
thread is currently running
Definition platform.h:64
#define profile_enter()
Definition profiling.h:33
u64 pf_point_t
Definition profiling.h:8
#define profile_leave(p,...)
Definition profiling.h:35
static const char * syscall_names[]
Definition table.h:20
uintn reg_t
Definition types.h:51