1/* SPDX-License-Identifier: BSD-2-Clause */ 2/* 3 * Copyright 2022-2023 NXP 4 */ 5#include "tee_syscall_numbers.h" 6#include "trace_levels.h" 7#include <asm.S> 8#include <generated/asm-defines.h> 9#include <kernel/thread.h> 10#include <riscv.h> 11#include <riscv_macros.S> 12#include <tee_api_defines.h> 13 14/* 15 * uint32_t scall_do_call(struct thread_scall_regs *regs, syscall_t func); 16 * 17 * Called from scall_handle_user_ta() 18 */ 19FUNC scall_do_call , : 20 addi sp, sp, -16 21 22 /* Save scall regs to t0 */ 23 mv t0, a0 24 25 /* Save func to t1 */ 26 mv t1, a1 27 28 /* Push return address to stack */ 29 store_xregs sp, 0, 1 30 31 /* Load arguments to function */ 32 load_xregs a0, THREAD_SCALL_REG_A0, 10, 17 33 34 /* Call the syscall function */ 35 jalr t1 36 37 /* Pop return address from stack */ 38 load_xregs sp, 0, 1 39 40 addi sp, sp, 16 41 ret 42END_FUNC scall_do_call 43 44/* 45 * void syscall_sys_return(uint32_t ret); 46 */ 47FUNC syscall_sys_return , : 48 li a1, 0 /* panic = false */ 49 li a2, 0 /* panic_code = 0 */ 50 mv a3, t0 /* pointer to struct thread_scall_regs */ 51 j scall_sys_return_helper 52END_FUNC syscall_sys_return 53 54/* 55 * void syscall_panic(uint32_t code); 56 */ 57FUNC syscall_panic , : 58 li a1, 1 /* panic = true */ 59 mv a2, a0 /* code */ 60 li a0, TEE_ERROR_TARGET_DEAD 61 mv a3, t0 /* pointer to struct thread_scall_regs */ 62 j scall_sys_return_helper 63END_FUNC syscall_panic 64