xref: /openbmc/u-boot/arch/arm/cpu/armv7/smccc-call.S (revision 1a68faac)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (c) 2015, Linaro Limited
4 */
5#include <linux/linkage.h>
6
7#include <asm/opcodes-sec.h>
8#include <asm/opcodes-virt.h>
9
10#ifdef CONFIG_EFI_LOADER
11	.section	.text.efi_runtime
12#endif
13
14#define UNWIND(x...)
15	/*
16	 * Wrap c macros in asm macros to delay expansion until after the
17	 * SMCCC asm macro is expanded.
18	 */
19	.macro SMCCC_SMC
20	__SMC(0)
21	.endm
22
23	.macro SMCCC_HVC
24	__HVC(0)
25	.endm
26
27	.macro SMCCC instr
28UNWIND(	.fnstart)
29	mov	r12, sp
30	push	{r4-r7}
31UNWIND(	.save	{r4-r7})
32	ldm	r12, {r4-r7}
33	\instr
34	pop	{r4-r7}
35	ldr	r12, [sp, #(4 * 4)]
36	stm	r12, {r0-r3}
37	bx	lr
38UNWIND(	.fnend)
39	.endm
40
41/*
42 * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
43 *		  unsigned long a3, unsigned long a4, unsigned long a5,
44 *		  unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
45 *		  struct arm_smccc_quirk *quirk)
46 */
47ENTRY(__arm_smccc_smc)
48	SMCCC SMCCC_SMC
49ENDPROC(__arm_smccc_smc)
50
51/*
52 * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
53 *		  unsigned long a3, unsigned long a4, unsigned long a5,
54 *		  unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
55 *		  struct arm_smccc_quirk *quirk)
56 */
57ENTRY(__arm_smccc_hvc)
58	SMCCC SMCCC_HVC
59ENDPROC(__arm_smccc_hvc)
60