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