diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-02-06 16:06:53 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-02-08 09:18:57 +0100 |
commit | cdf33e6ecf4ca724d8be64fefbc4896eb8baf046 (patch) | |
tree | ff93b4f5fae059ed5249112193b68e5bc9bc8833 /arch/arm/cpu | |
parent | b94205dc97cf2f794cef89512fb2e7f568def4d5 (diff) | |
download | barebox-cdf33e6ecf4ca724d8be64fefbc4896eb8baf046.tar.gz barebox-cdf33e6ecf4ca724d8be64fefbc4896eb8baf046.tar.xz |
ARM: Add smc call support
Taken from the Kernel: A wrapper to make a smc call from C.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r-- | arch/arm/cpu/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/cpu/smccc-call.S | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile index d8cb1871a6..e542f1741a 100644 --- a/arch/arm/cpu/Makefile +++ b/arch/arm/cpu/Makefile @@ -34,6 +34,8 @@ ifeq ($(CONFIG_MMU),) obj-y += no-mmu.o endif +obj-$(CONFIG_ARM_SECURE_MONITOR) += smccc-call.o + obj-$(CONFIG_CPU_32v4T) += cache-armv4.o pbl-$(CONFIG_CPU_32v4T) += cache-armv4.o obj-$(CONFIG_CPU_32v5) += cache-armv5.o diff --git a/arch/arm/cpu/smccc-call.S b/arch/arm/cpu/smccc-call.S new file mode 100644 index 0000000000..c2781b1ab2 --- /dev/null +++ b/arch/arm/cpu/smccc-call.S @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2015, Linaro Limited + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include <linux/linkage.h> + +#include <asm/unwind.h> + + .arch_extension sec + .arch_extension virt + .arm + + /* + * Wrap c macros in asm macros to delay expansion until after the + * SMCCC asm macro is expanded. + */ + .macro SMCCC_SMC + smc #0 + .endm + + .macro SMCCC_HVC + hvc #0 + .endm + + .macro SMCCC instr +UNWIND( .fnstart) + mov r12, sp + push {r4-r7} +UNWIND( .save {r4-r7}) + ldm r12, {r4-r7} + \instr + pop {r4-r7} + ldr r12, [sp, #(4 * 4)] + stm r12, {r0-r3} + bx lr +UNWIND( .fnend) + .endm + +/* + * void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2, + * unsigned long a3, unsigned long a4, unsigned long a5, + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) + */ +ENTRY(arm_smccc_smc) + SMCCC SMCCC_SMC +ENDPROC(arm_smccc_smc) + +/* + * void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2, + * unsigned long a3, unsigned long a4, unsigned long a5, + * unsigned long a6, unsigned long a7, struct arm_smccc_res *res) + */ +ENTRY(arm_smccc_hvc) + SMCCC SMCCC_HVC +ENDPROC(arm_smccc_hvc) |