git: ee7cb98d4cd0 - stable/14 - dev/psci: Create macros to simplify calling SMCCC
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 21 Oct 2024 15:05:17 UTC
The branch stable/14 has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=ee7cb98d4cd0b53c3a7a1bd2cda476c1726232fc
commit ee7cb98d4cd0b53c3a7a1bd2cda476c1726232fc
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-10-14 14:33:44 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-10-21 15:03:27 +0000
dev/psci: Create macros to simplify calling SMCCC
When calling into SMCCC functions we often only need a few arguments.
As the current function needs all 8 possible arguments to be set the
unused values will be zero.
Create a macro to pass in the used values, followed by enough zeros,
then the result pointer.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D46986
(cherry picked from commit e4c3536138f4a314dc26331b0a1488faae09aaf4)
---
sys/dev/psci/smccc.h | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/sys/dev/psci/smccc.h b/sys/dev/psci/smccc.h
index 96527f037d78..dd10fb8018ae 100644
--- a/sys/dev/psci/smccc.h
+++ b/sys/dev/psci/smccc.h
@@ -91,6 +91,38 @@ int arm_smccc_smc(register_t, register_t, register_t, register_t, register_t,
int arm_smccc_hvc(register_t, register_t, register_t, register_t, register_t,
register_t, register_t, register_t, struct arm_smccc_res *res);
+#define arm_smccc_invoke_1(func, a0, res) \
+ func(a0, 0, 0, 0, 0, 0, 0, 0, res)
+#define arm_smccc_invoke_2(func, a0, a1, res) \
+ func(a0, a1, 0, 0, 0, 0, 0, 0, res)
+#define arm_smccc_invoke_3(func, a0, a1, a2, res) \
+ func(a0, a1, a2, 0, 0, 0, 0, 0, res)
+#define arm_smccc_invoke_4(func, a0, a1, a2, a3, res) \
+ func(a0, a1, a2, a3, 0, 0, 0, 0, res)
+#define arm_smccc_invoke_5(func, a0, a1, a2, a3, a4, res) \
+ func(a0, a1, a2, a3, a4, 0, 0, 0, res)
+#define arm_smccc_invoke_6(func, a0, a1, a2, a3, a4, a5, res) \
+ func(a0, a1, a2, a3, a4, a5, 0, 0, res)
+#define arm_smccc_invoke_7(func, a0, a1, a2, a3, a4, a5, a6, res) \
+ func(a0, a1, a2, a3, a4, a5, a6, 0, res)
+#define arm_smccc_invoke_8(func, a0, a1, a2, a3, a4, a5, a6, a7, res) \
+ func(a0, a1, a2, a3, a4, a5, a6, a7, res)
+
+#define _arm_smccc_invoke_macro(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) \
+ NAME
+#define _arm_smccc_invoke(func, a0, ...) \
+ _arm_smccc_invoke_macro(__VA_ARGS__, arm_smccc_invoke_8, \
+ arm_smccc_invoke_7, arm_smccc_invoke_6, arm_smccc_invoke_5, \
+ arm_smccc_invoke_4, arm_smccc_invoke_3, arm_smccc_invoke_2, \
+ arm_smccc_invoke_1)(func, a0, __VA_ARGS__)
+
+#define arm_smccc_invoke_hvc(a0, ...) \
+ _arm_smccc_invoke(arm_smccc_hvc, a0, __VA_ARGS__)
+#define arm_smccc_invoke_smc(a0, ...) \
+ _arm_smccc_invoke(arm_smccc_smc, a0, __VA_ARGS__)
+#define arm_smccc_invoke(a0, ...) \
+ _arm_smccc_invoke(psci_callfn, a0, __VA_ARGS__)
+
struct arm_smccc_1_2_regs {
register_t a0;
register_t a1;