1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2015, Linaro Limited
4 */
5
6#include <tee_syscall_numbers.h>
7#include <asm.S>
8
9        .section .text
10
11        .macro UTEE_SYSCALL name, scn, num_args
12	FUNC \name , :
13
14	.if \num_args > TEE_SVC_MAX_ARGS || \num_args > 8
15	.error "Too many arguments for syscall"
16	.endif
17#if defined(CFG_SYSCALL_WRAPPERS_MCOUNT) && !defined(__LDELF__)
18	.if \scn != TEE_SCN_RETURN
19	stp	x29, x30, [sp, #-80]!
20	mov	x29, sp
21	stp	x0, x1, [sp, #16]
22	stp	x2, x3, [sp, #32]
23	stp	x4, x5, [sp, #48]
24	stp	x6, x7, [sp, #64]
25	mov	x0, x30
26	bl	_mcount
27	ldp	x0, x1, [sp, #16]
28	ldp	x2, x3, [sp, #32]
29	ldp	x4, x5, [sp, #48]
30	ldp	x6, x7, [sp, #64]
31	ldp	x29, x30, [sp], #80
32	.endif
33#endif
34        mov     x8, #(\scn)
35        svc #0
36        ret
37        END_FUNC \name
38        .endm
39
40	FUNC _utee_panic, :
41	stp	x29, x30, [sp, #-16]!
42	mov	x1, sp
43	bl	__utee_panic
44	/* Not reached */
45	END_FUNC _utee_panic
46
47#include <utee_syscalls_asm.S>
48
49BTI(emit_aarch64_feature_1_and     GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
50