1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014-2022, Linaro Limited
4  * Copyright (c) 2020, Arm Limited
5  */
6 #ifndef __KERNEL_SCALL_H
7 #define __KERNEL_SCALL_H
8 
9 #include <types_ext.h>
10 
11 /*
12  * Generic "pointer to function" type. Actual syscalls take zero or more
13  * arguments and return TEE_Result.
14  */
15 typedef void (*syscall_t)(void);
16 
17 struct thread_scall_regs;
18 
19 /* Helper function for scall_handle_user_ta() and scall_handle_ldelf() */
20 uint32_t scall_do_call(struct thread_scall_regs *regs, syscall_t func);
21 
22 /* Registered as .handle_scall in struct tee_ta_ops for user TAs. */
23 bool scall_handle_user_ta(struct thread_scall_regs *regs);
24 
25 /* Separate syscall handler for calls from ldelf */
26 bool scall_handle_ldelf(struct thread_scall_regs *regs);
27 
28 /*
29  * Called from the assembly functions syscall_sys_return() and
30  * syscall_panic() to update the register values in the struct
31  * thread_scall_regs to return back to TEE Core from an earlier call to
32  * thread_enter_user_mode().
33  */
34 uint32_t scall_sys_return_helper(uint32_t ret, bool panic, uint32_t panic_code,
35 				 struct thread_scall_regs *regs);
36 
37 /* Saves TA panic stack, arch-specific implementation */
38 void scall_save_panic_stack(struct thread_scall_regs *regs);
39 
40 #endif /*__KERNEL_SCALL_H*/
41