Skip to content

Commit c2da86f

Browse files
masahir0ytrini
authored andcommitted
ARM: import arm-smccc code from Linux 4.11-rc6
Imports ARM SMC Calling Convention code from Linux 4.11-rc6. The files have been copied as follows: [Linux] [U-Boot] arch/arm/kernel/smccc-call.S -> arch/arm/cpu/armv7/smccc-call.S arch/arm64/kernel/smccc-call.S -> arch/arm/cpu/armv8/smccc-call.S arch/arm/include/asm/opcodes* -> arch/arm/include/asm/opcodes* include/linux/arm-smccc.h -> include/linux/arm-smccc.h Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 84a112a commit c2da86f

File tree

6 files changed

+544
-0
lines changed

6 files changed

+544
-0
lines changed

arch/arm/cpu/armv7/smccc-call.S

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2015, Linaro Limited
3+
*
4+
* This software is licensed under the terms of the GNU General Public
5+
* License version 2, as published by the Free Software Foundation, and
6+
* may be copied, distributed, and modified under those terms.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
*/
14+
#include <linux/linkage.h>
15+
16+
#include <asm/opcodes-sec.h>
17+
#include <asm/opcodes-virt.h>
18+
#include <asm/unwind.h>
19+
20+
/*
21+
* Wrap c macros in asm macros to delay expansion until after the
22+
* SMCCC asm macro is expanded.
23+
*/
24+
.macro SMCCC_SMC
25+
__SMC(0)
26+
.endm
27+
28+
.macro SMCCC_HVC
29+
__HVC(0)
30+
.endm
31+
32+
.macro SMCCC instr
33+
UNWIND( .fnstart)
34+
mov r12, sp
35+
push {r4-r7}
36+
UNWIND( .save {r4-r7})
37+
ldm r12, {r4-r7}
38+
\instr
39+
pop {r4-r7}
40+
ldr r12, [sp, #(4 * 4)]
41+
stm r12, {r0-r3}
42+
bx lr
43+
UNWIND( .fnend)
44+
.endm
45+
46+
/*
47+
* void smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
48+
* unsigned long a3, unsigned long a4, unsigned long a5,
49+
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
50+
* struct arm_smccc_quirk *quirk)
51+
*/
52+
ENTRY(__arm_smccc_smc)
53+
SMCCC SMCCC_SMC
54+
ENDPROC(__arm_smccc_smc)
55+
56+
/*
57+
* void smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
58+
* unsigned long a3, unsigned long a4, unsigned long a5,
59+
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
60+
* struct arm_smccc_quirk *quirk)
61+
*/
62+
ENTRY(__arm_smccc_hvc)
63+
SMCCC SMCCC_HVC
64+
ENDPROC(__arm_smccc_hvc)

arch/arm/cpu/armv8/smccc-call.S

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2015, Linaro Limited
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License Version 2 as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
*
13+
*/
14+
#include <linux/linkage.h>
15+
#include <linux/arm-smccc.h>
16+
#include <asm/asm-offsets.h>
17+
18+
.macro SMCCC instr
19+
.cfi_startproc
20+
\instr #0
21+
ldr x4, [sp]
22+
stp x0, x1, [x4, #ARM_SMCCC_RES_X0_OFFS]
23+
stp x2, x3, [x4, #ARM_SMCCC_RES_X2_OFFS]
24+
ldr x4, [sp, #8]
25+
cbz x4, 1f /* no quirk structure */
26+
ldr x9, [x4, #ARM_SMCCC_QUIRK_ID_OFFS]
27+
cmp x9, #ARM_SMCCC_QUIRK_QCOM_A6
28+
b.ne 1f
29+
str x6, [x4, ARM_SMCCC_QUIRK_STATE_OFFS]
30+
1: ret
31+
.cfi_endproc
32+
.endm
33+
34+
/*
35+
* void arm_smccc_smc(unsigned long a0, unsigned long a1, unsigned long a2,
36+
* unsigned long a3, unsigned long a4, unsigned long a5,
37+
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
38+
* struct arm_smccc_quirk *quirk)
39+
*/
40+
ENTRY(__arm_smccc_smc)
41+
SMCCC smc
42+
ENDPROC(__arm_smccc_smc)
43+
44+
/*
45+
* void arm_smccc_hvc(unsigned long a0, unsigned long a1, unsigned long a2,
46+
* unsigned long a3, unsigned long a4, unsigned long a5,
47+
* unsigned long a6, unsigned long a7, struct arm_smccc_res *res,
48+
* struct arm_smccc_quirk *quirk)
49+
*/
50+
ENTRY(__arm_smccc_hvc)
51+
SMCCC hvc
52+
ENDPROC(__arm_smccc_hvc)

arch/arm/include/asm/opcodes-sec.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* This program is free software; you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License version 2 as
4+
* published by the Free Software Foundation.
5+
*
6+
* This program is distributed in the hope that it will be useful,
7+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9+
* GNU General Public License for more details.
10+
*
11+
* Copyright (C) 2012 ARM Limited
12+
*/
13+
14+
#ifndef __ASM_ARM_OPCODES_SEC_H
15+
#define __ASM_ARM_OPCODES_SEC_H
16+
17+
#include <asm/opcodes.h>
18+
19+
#define __SMC(imm4) __inst_arm_thumb32( \
20+
0xE1600070 | (((imm4) & 0xF) << 0), \
21+
0xF7F08000 | (((imm4) & 0xF) << 16) \
22+
)
23+
24+
#endif /* __ASM_ARM_OPCODES_SEC_H */
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* opcodes-virt.h: Opcode definitions for the ARM virtualization extensions
3+
* Copyright (C) 2012 Linaro Limited
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along
16+
* with this program; if not, write to the Free Software Foundation, Inc.,
17+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*/
19+
#ifndef __ASM_ARM_OPCODES_VIRT_H
20+
#define __ASM_ARM_OPCODES_VIRT_H
21+
22+
#include <asm/opcodes.h>
23+
24+
#define __HVC(imm16) __inst_arm_thumb32( \
25+
0xE1400070 | (((imm16) & 0xFFF0) << 4) | ((imm16) & 0x000F), \
26+
0xF7E08000 | (((imm16) & 0xF000) << 4) | ((imm16) & 0x0FFF) \
27+
)
28+
29+
#define __ERET __inst_arm_thumb32( \
30+
0xE160006E, \
31+
0xF3DE8F00 \
32+
)
33+
34+
#define __MSR_ELR_HYP(regnum) __inst_arm_thumb32( \
35+
0xE12EF300 | regnum, \
36+
0xF3808E30 | (regnum << 16) \
37+
)
38+
39+
#endif /* ! __ASM_ARM_OPCODES_VIRT_H */

0 commit comments

Comments
 (0)