MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / syscall_handler

Function syscall_handler

libcpu/risc-v/common64/syscall_c.c:31–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29typedef rt_ubase_t (*syscallfunc_t)(rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t);
30
31void syscall_handler(struct rt_hw_stack_frame *regs)
32{
33 const char *syscall_name;
34 int syscallid = regs->a7;
35
36 if (syscallid == 0)
37 {
38 LOG_E("syscall id = 0!\n");
39 while (1)
40 ;
41 }
42
43 syscallfunc_t syscallfunc = (syscallfunc_t)lwp_get_sys_api(syscallid);
44
45 if (syscallfunc == RT_NULL)
46 {
47 LOG_E("unsupported syscall!\n");
48 sys_exit_group(-1);
49 }
50
51#if DBG_LVL >= DBG_INFO
52 syscall_name = lwp_get_syscall_name(syscallid);
53#endif
54
55 LOG_I("[0x%lx] %s(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx)", rt_thread_self(), syscall_name,
56 regs->a0, regs->a1, regs->a2, regs->a3, regs->a4, regs->a5, regs->a6);
57 regs->a0 = syscallfunc(regs->a0, regs->a1, regs->a2, regs->a3, regs->a4, regs->a5, regs->a6);
58 regs->a7 = 0;
59 regs->epc += 4; // skip ecall instruction
60 LOG_I("[0x%lx] %s ret: 0x%lx", rt_thread_self(), syscall_name, regs->a0);
61}
62#endif /* RT_USING_SMART */

Callers

nothing calls this directly

Calls 4

lwp_get_sys_apiFunction · 0.85
sys_exit_groupFunction · 0.85
lwp_get_syscall_nameFunction · 0.85
rt_thread_selfFunction · 0.85

Tested by

no test coverage detected