xref: /optee_os/lib/libutee/arch/arm/utee_syscalls_a32.S (revision a83aec29b778db0b01b3e74ff69122f930bed050)
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2015, Linaro Limited
4 * Copyright (c) 2014, STMicroelectronics International N.V.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#include <tee_syscall_numbers.h>
31#include <asm.S>
32
33#if defined(CFG_UNWIND)
34#define UNWIND(...)	__VA_ARGS__
35#else
36#define UNWIND(...)
37#endif
38
39        .section .text
40        .balign 4
41        .code 32
42
43        .macro UTEE_SYSCALL name, scn, num_args
44	FUNC \name , :
45
46UNWIND( .fnstart)
47        push    {r5-r7,lr}
48UNWIND( .save   {r5-r7,lr})
49        mov     r7, #(\scn)
50	.if \num_args > TEE_SVC_MAX_ARGS
51	.error "Too many arguments for syscall"
52	.endif
53        .if \num_args <= 4
54        @ No arguments passed on stack
55        mov     r6, #0
56        .else
57        @ Tell number of arguments passed on the stack
58        mov     r6, #(\num_args - 4)
59        @ Point just before the push (4 registers) above on the first argument
60        add     r5, sp, #(4 * 4)
61        .endif
62        svc #0
63        pop     {r5-r7,pc}
64UNWIND( .fnend)
65	END_FUNC \name
66        .endm
67
68	FUNC utee_panic, :
69UNWIND( .fnstart)
70	push	{r0-r11, lr}
71UNWIND(	.save	{r0-r11, lr})
72	mov	lr, pc
73	push	{lr}
74UNWIND(	.save	{lr})
75	mov	r1, sp
76	bl	__utee_panic
77	/* Not reached */
78UNWIND( .fnend)
79	END_FUNC utee_panic
80
81#include "utee_syscalls_asm.S"
82