]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/arm-smccc.h
arm: kernel: Add SMC structure parameter
[mirror_ubuntu-bionic-kernel.git] / include / linux / arm-smccc.h
CommitLineData
98dd64f3
JW
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#ifndef __LINUX_ARM_SMCCC_H
15#define __LINUX_ARM_SMCCC_H
16
17#include <linux/linkage.h>
18#include <linux/types.h>
19
20/*
21 * This file provides common defines for ARM SMC Calling Convention as
22 * specified in
23 * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
24 */
25
26#define ARM_SMCCC_STD_CALL 0
27#define ARM_SMCCC_FAST_CALL 1
28#define ARM_SMCCC_TYPE_SHIFT 31
29
30#define ARM_SMCCC_SMC_32 0
31#define ARM_SMCCC_SMC_64 1
32#define ARM_SMCCC_CALL_CONV_SHIFT 30
33
34#define ARM_SMCCC_OWNER_MASK 0x3F
35#define ARM_SMCCC_OWNER_SHIFT 24
36
37#define ARM_SMCCC_FUNC_MASK 0xFFFF
38
39#define ARM_SMCCC_IS_FAST_CALL(smc_val) \
40 ((smc_val) & (ARM_SMCCC_FAST_CALL << ARM_SMCCC_TYPE_SHIFT))
41#define ARM_SMCCC_IS_64(smc_val) \
42 ((smc_val) & (ARM_SMCCC_SMC_64 << ARM_SMCCC_CALL_CONV_SHIFT))
43#define ARM_SMCCC_FUNC_NUM(smc_val) ((smc_val) & ARM_SMCCC_FUNC_MASK)
44#define ARM_SMCCC_OWNER_NUM(smc_val) \
45 (((smc_val) >> ARM_SMCCC_OWNER_SHIFT) & ARM_SMCCC_OWNER_MASK)
46
47#define ARM_SMCCC_CALL_VAL(type, calling_convention, owner, func_num) \
48 (((type) << ARM_SMCCC_TYPE_SHIFT) | \
49 ((calling_convention) << ARM_SMCCC_CALL_CONV_SHIFT) | \
50 (((owner) & ARM_SMCCC_OWNER_MASK) << ARM_SMCCC_OWNER_SHIFT) | \
51 ((func_num) & ARM_SMCCC_FUNC_MASK))
52
53#define ARM_SMCCC_OWNER_ARCH 0
54#define ARM_SMCCC_OWNER_CPU 1
55#define ARM_SMCCC_OWNER_SIP 2
56#define ARM_SMCCC_OWNER_OEM 3
57#define ARM_SMCCC_OWNER_STANDARD 4
58#define ARM_SMCCC_OWNER_TRUSTED_APP 48
59#define ARM_SMCCC_OWNER_TRUSTED_APP_END 49
60#define ARM_SMCCC_OWNER_TRUSTED_OS 50
61#define ARM_SMCCC_OWNER_TRUSTED_OS_END 63
62
63/**
64 * struct arm_smccc_res - Result from SMC/HVC call
65 * @a0-a3 result values from registers 0 to 3
66 */
67struct arm_smccc_res {
68 unsigned long a0;
69 unsigned long a1;
70 unsigned long a2;
71 unsigned long a3;
72};
73
74/**
680a0873
AG
75 * struct arm_smccc_quirk - Contains quirk information
76 * @id: quirk identification
77 * @state: quirk specific information
78 * @a6: Qualcomm quirk entry for returning post-smc call contents of a6
79 */
80struct arm_smccc_quirk {
81 int id;
82 union {
83 unsigned long a6;
84 } state;
85};
86
87/**
88 * __arm_smccc_smc() - make SMC calls
98dd64f3
JW
89 * @a0-a7: arguments passed in registers 0 to 7
90 * @res: result values from registers 0 to 3
680a0873 91 * @quirk: points to an arm_smccc_quirk, or NULL when no quirks are required.
98dd64f3
JW
92 *
93 * This function is used to make SMC calls following SMC Calling Convention.
94 * The content of the supplied param are copied to registers 0 to 7 prior
95 * to the SMC instruction. The return values are updated with the content
680a0873
AG
96 * from register 0 to 3 on return from the SMC instruction. An optional
97 * quirk structure provides vendor specific behavior.
98dd64f3 98 */
680a0873 99asmlinkage void __arm_smccc_smc(unsigned long a0, unsigned long a1,
98dd64f3
JW
100 unsigned long a2, unsigned long a3, unsigned long a4,
101 unsigned long a5, unsigned long a6, unsigned long a7,
680a0873 102 struct arm_smccc_res *res, struct arm_smccc_quirk *quirk);
98dd64f3
JW
103
104/**
680a0873 105 * __arm_smccc_hvc() - make HVC calls
98dd64f3
JW
106 * @a0-a7: arguments passed in registers 0 to 7
107 * @res: result values from registers 0 to 3
108 *
109 * This function is used to make HVC calls following SMC Calling
110 * Convention. The content of the supplied param are copied to registers 0
111 * to 7 prior to the HVC instruction. The return values are updated with
680a0873
AG
112 * the content from register 0 to 3 on return from the HVC instruction. An
113 * optional quirk structure provides vendor specific behavior.
98dd64f3 114 */
680a0873 115asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1,
98dd64f3
JW
116 unsigned long a2, unsigned long a3, unsigned long a4,
117 unsigned long a5, unsigned long a6, unsigned long a7,
680a0873
AG
118 struct arm_smccc_res *res, struct arm_smccc_quirk *quirk);
119
120#define arm_smccc_smc(...) __arm_smccc_smc(__VA_ARGS__, NULL)
121
122#define arm_smccc_smc_quirk(...) __arm_smccc_smc(__VA_ARGS__)
123
124#define arm_smccc_hvc(...) __arm_smccc_hvc(__VA_ARGS__, NULL)
125
126#define arm_smccc_hvc_quirk(...) __arm_smccc_hvc(__VA_ARGS__)
98dd64f3
JW
127
128#endif /*__LINUX_ARM_SMCCC_H*/