1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2015, Linaro Limited
4 * Copyright (c) 2014, STMicroelectronics International N.V.
5 */
6
7#include <tee_syscall_numbers.h>
8#include <asm.S>
9
10        .section .text
11        .balign 4
12        .code 32
13
14        .macro UTEE_SYSCALL name, scn, num_args
15	FUNC \name , :
16        push    {r5-r7,lr}
17UNWIND( .save   {r5-r7,lr})
18#if defined(CFG_SYSCALL_WRAPPERS_MCOUNT) && !defined(__LDELF__)
19	.if \scn != TEE_SCN_RETURN
20	mov	ip, sp
21	push	{r0-r4, fp, ip}
22	add	fp, ip, #16
23	push	{lr}
24	bl	__gnu_mcount_nc
25	pop	{r0-r4, fp, ip}
26	mov	sp, ip
27	.endif
28#endif
29        mov     r7, #(\scn)
30	.if \num_args > TEE_SVC_MAX_ARGS
31	.error "Too many arguments for syscall"
32	.endif
33        .if \num_args <= 4
34        @ No arguments passed on stack
35        mov     r6, #0
36        .else
37        @ Tell number of arguments passed on the stack
38        mov     r6, #(\num_args - 4)
39        @ Point just before the push (4 registers) above on the first argument
40        add     r5, sp, #(4 * 4)
41        .endif
42        svc #0
43        pop     {r5-r7,pc}
44	END_FUNC \name
45        .endm
46
47	FUNC _utee_panic, :
48	push	{r0-r11, lr}
49UNWIND(	.save	{r0-r11, lr})
50	mov	lr, pc
51	push	{lr}
52UNWIND(	.save	{lr})
53	mov	r1, sp
54	bl	__utee_panic
55	/* Not reached */
56	END_FUNC _utee_panic
57
58#include "utee_syscalls_asm.S"
59