xref: /optee_os/lib/libutee/arch/riscv/utee_syscalls_rv.S (revision 5d5d7d0b1c038a6836be9f0b38585f5aa6a4dd01)
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2023 Andes Technology Corporation
4 * Copyright  2022  Beijing ESWIN Computing Technology Co., Ltd.
5 */
6
7#include <tee_syscall_numbers.h>
8#include <asm.S>
9
10        .section .text
11
12        .macro UTEE_SYSCALL name, scn, num_args
13	FUNC \name , :
14
15	.if \num_args > TEE_SVC_MAX_ARGS || \num_args > 8
16	.error "Too many arguments for syscall"
17	.endif
18	li	t0, \scn
19	li	t1, \num_args
20	ecall
21	ret
22	END_FUNC \name
23	.endm
24
25	FUNC _utee_panic, :
26	/* The stack pointer is always kept 16-byte aligned */
27	add	sp, sp, -16
28	/* Save return address and frame pointer to stack */
29#if defined(RV32)
30	sw	s0, 8(sp)
31	sw	ra, 12(sp)
32#elif defined(RV64)
33	sd	s0, 0(sp)
34	sd	ra, 8(sp)
35#endif
36	/* Assign a1 as stack pointer for scall_save_panic_stack() */
37	mv	a1, sp
38	/* Use tail call here because we will not return from it */
39	tail	__utee_panic
40	/* Not reached */
41	END_FUNC _utee_panic
42
43#include <utee_syscalls_asm.S>
44