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 .note.GNU-stack,"",%progbits
11
12        .section .text
13        .balign 4
14        .code 32
15
16        .macro UTEE_SYSCALL name, scn, num_args
17	FUNC \name , :
18        push    {r5-r7,lr}
19UNWIND( .save   {r5-r7,lr})
20#if defined(CFG_SYSCALL_WRAPPERS_MCOUNT) && !defined(__LDELF__)
21	.if \scn != TEE_SCN_RETURN
22	mov	ip, sp
23	push	{r0-r4, fp, ip}
24	add	fp, ip, #16
25	push	{lr}
26	bl	__gnu_mcount_nc
27	pop	{r0-r4, fp, ip}
28	mov	sp, ip
29	.endif
30#endif
31        mov     r7, #(\scn)
32	.if \num_args > TEE_SVC_MAX_ARGS
33	.error "Too many arguments for syscall"
34	.endif
35        .if \num_args <= 4
36        @ No arguments passed on stack
37        mov     r6, #0
38        .else
39        @ Tell number of arguments passed on the stack
40        mov     r6, #(\num_args - 4)
41        @ Point just before the push (4 registers) above on the first argument
42        add     r5, sp, #(4 * 4)
43        .endif
44        svc #0
45        pop     {r5-r7,pc}
46	END_FUNC \name
47        .endm
48
49	FUNC _utee_panic, :
50	push	{r0-r11, lr}
51UNWIND(	.save	{r0-r11, lr})
52	mov	lr, pc
53	push	{lr}
54UNWIND(	.save	{lr})
55	mov	r1, sp
56	bl	__utee_panic
57	/* Not reached */
58	END_FUNC _utee_panic
59
60#include <utee_syscalls_asm.S>
61