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