summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKun Qin <kuqin@microsoft.com>2024-11-06 15:19:11 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-04-02 16:25:45 +0000
commitc0ecd11e623a662e869f244c7230af9bb0f26e75 (patch)
tree48f290cb90b9054e457c0d9eaf509c32ca15ee04
parent213973e9e5ab361f77fe136a810053244a97f018 (diff)
downloadedk2-c0ecd11e623a662e869f244c7230af9bb0f26e75.zip
edk2-c0ecd11e623a662e869f244c7230af9bb0f26e75.tar.gz
edk2-c0ecd11e623a662e869f244c7230af9bb0f26e75.tar.bz2
ArmPkg: ArmSmcLib: Support all 18 registers
This extends ARM_SMC_ARGS to support all x0-x17 registers use case for FF-A. The ArmCallSmc function is also updated to support 18-register usage. Signed-off-by: Kun Qin <kun.qin@microsoft.com>
-rw-r--r--ArmPkg/Include/Library/ArmSmcLib.h10
-rw-r--r--ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S34
2 files changed, 34 insertions, 10 deletions
diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
index beef017..be2f85a 100644
--- a/ArmPkg/Include/Library/ArmSmcLib.h
+++ b/ArmPkg/Include/Library/ArmSmcLib.h
@@ -23,6 +23,16 @@ typedef struct {
UINTN Arg5;
UINTN Arg6;
UINTN Arg7;
+ UINTN Arg8;
+ UINTN Arg9;
+ UINTN Arg10;
+ UINTN Arg11;
+ UINTN Arg12;
+ UINTN Arg13;
+ UINTN Arg14;
+ UINTN Arg15;
+ UINTN Arg16;
+ UINTN Arg17;
} ARM_SMC_ARGS;
/**
diff --git a/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S b/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
index a4443a4..139bb89 100644
--- a/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
+++ b/ArmPkg/Library/ArmSmcLib/AArch64/ArmSmc.S
@@ -8,10 +8,20 @@
#include <AsmMacroLib.h>
ASM_FUNC(ArmCallSmc)
- // Push x0 on the stack - The stack must always be quad-word aligned
- str x0, [sp, #-16]!
+ // Push frame pointer and return address on the stack
+ stp x29, x30, [sp, #-16]!
+ mov x29, sp
+
+ // x0 is the ARM_SMC_ARGS structure address
+ // x30 is used as a scratch register upon returning from SMC
+ mov x30, x0
// Load the SMC arguments values into the appropriate registers
+ ldp x16, x17, [x0, #128]
+ ldp x14, x15, [x0, #112]
+ ldp x12, x13, [x0, #96]
+ ldp x10, x11, [x0, #80]
+ ldp x8, x9, [x0, #64]
ldp x6, x7, [x0, #48]
ldp x4, x5, [x0, #32]
ldp x2, x3, [x0, #16]
@@ -19,14 +29,18 @@ ASM_FUNC(ArmCallSmc)
smc #0
- // Pop the ARM_SMC_ARGS structure address from the stack into x9
- ldr x9, [sp], #16
-
// Store the SMC returned values into the ARM_SMC_ARGS structure.
- // A SMC call can return up to 4 values - we do not need to store back x4-x7.
- stp x2, x3, [x9, #16]
- stp x0, x1, [x9, #0]
-
- mov x0, x9
+ // A SMC call can return up to 18 values.
+ stp x16, x17, [x30, #128]
+ stp x14, x15, [x30, #112]
+ stp x12, x13, [x30, #96]
+ stp x10, x11, [x30, #80]
+ stp x8, x9, [x30, #64]
+ stp x6, x7, [x30, #48]
+ stp x4, x5, [x30, #32]
+ stp x2, x3, [x30, #16]
+ stp x0, x1, [x30, #0]
+
+ ldp x29, x30, [sp], #16
ret