blob: 00664c78facab321049bf7e7dfcdb380d15986d9 [file] [log] [blame]
Thomas Gleixner9c92ab62019-05-29 07:17:56 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Jens Wiklanderb329f952016-01-04 15:42:55 +01002/*
3 * Copyright (c) 2015, Linaro Limited
Jens Wiklanderb329f952016-01-04 15:42:55 +01004 */
5#include <linux/linkage.h>
6
7#include <asm/opcodes-sec.h>
8#include <asm/opcodes-virt.h>
9#include <asm/unwind.h>
10
11 /*
12 * Wrap c macros in asm macros to delay expansion until after the
13 * SMCCC asm macro is expanded.
14 */
15 .macro SMCCC_SMC
16 __SMC(0)
17 .endm
18
19 .macro SMCCC_HVC
20 __HVC(0)
21 .endm
22
23 .macro SMCCC instr
24UNWIND( .fnstart)
25 mov r12, sp
26 push {r4-r7}
27UNWIND( .save {r4-r7})
28 ldm r12, {r4-r7}
29 \instr
30 pop {r4-r7}
31 ldr r12, [sp, #(4 * 4)]
32 stm r12, {r0-r3}
33 bx lr
34UNWIND( .fnend)
35 .endm
36
37/*
38 * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
39 * unsigned long a3, unsigned long a4, unsigned long a5,
Andy Gross680a0872017-02-01 11:28:27 -060040 * unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
41 * struct arm_smccc_quirk *quirk)
Jens Wiklanderb329f952016-01-04 15:42:55 +010042 */
Andy Gross680a0872017-02-01 11:28:27 -060043ENTRY(__arm_smccc_smc)
Jens Wiklanderb329f952016-01-04 15:42:55 +010044 SMCCC SMCCC_SMC
Andy Gross680a0872017-02-01 11:28:27 -060045ENDPROC(__arm_smccc_smc)
Jens Wiklanderb329f952016-01-04 15:42:55 +010046
47/*
48 * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
49 * unsigned long a3, unsigned long a4, unsigned long a5,
Andy Gross680a0872017-02-01 11:28:27 -060050 * unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
51 * struct arm_smccc_quirk *quirk)
Jens Wiklanderb329f952016-01-04 15:42:55 +010052 */
Andy Gross680a0872017-02-01 11:28:27 -060053ENTRY(__arm_smccc_hvc)
Jens Wiklanderb329f952016-01-04 15:42:55 +010054 SMCCC SMCCC_HVC
Andy Gross680a0872017-02-01 11:28:27 -060055ENDPROC(__arm_smccc_hvc)