xref: /optee_os/lib/libutee/arch/arm/utee_syscalls_a32.S (revision 827be46c173f31c57006af70ca3a15a5b1a7fba3)
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
17UNWIND( .fnstart)
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}
46UNWIND( .fnend)
47	END_FUNC \name
48        .endm
49
50	FUNC _utee_panic, :
51UNWIND( .fnstart)
52	push	{r0-r11, lr}
53UNWIND(	.save	{r0-r11, lr})
54	mov	lr, pc
55	push	{lr}
56UNWIND(	.save	{lr})
57	mov	r1, sp
58	bl	__utee_panic
59	/* Not reached */
60UNWIND( .fnend)
61	END_FUNC _utee_panic
62
63#include "utee_syscalls_asm.S"
64