* [PATCH v2 0/2] ArmPkg: Add SMC helper functions
@ 2021-11-01 22:11 Rebecca Cran
2021-11-01 22:11 ` [PATCH v2 1/2] " Rebecca Cran
2021-11-01 22:11 ` [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions Rebecca Cran
0 siblings, 2 replies; 11+ messages in thread
From: Rebecca Cran @ 2021-11-01 22:11 UTC (permalink / raw)
To: devel, Sami Mujawar, Ard Biesheuvel, Gerd Hoffmann,
Samer El-Haj-Mahmoud, Leif Lindholm
Cc: Rebecca Cran
To reduce the amount of template code, introduce SMC helper
functions. Update ArmSmcPsciResetSystemLib and Universal/Smbios to use
them.
Changes from v1 to v2:
Added a patch to update code to use the new functions.
Rebecca Cran (2):
ArmPkg: Add SMC helper functions
ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions
ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c | 10 +-
ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c | 31 ++---
6 files changed, 297 insertions(+), 27 deletions(-)
create mode 100644 ArmPkg/Library/ArmSmcLib/ArmSmc.c
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-11-01 22:11 [PATCH v2 0/2] ArmPkg: Add SMC helper functions Rebecca Cran
@ 2021-11-01 22:11 ` Rebecca Cran
2021-11-09 1:56 ` Rebecca Cran
2021-12-13 12:31 ` Sami Mujawar
2021-11-01 22:11 ` [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions Rebecca Cran
1 sibling, 2 replies; 11+ messages in thread
From: Rebecca Cran @ 2021-11-01 22:11 UTC (permalink / raw)
To: devel, Sami Mujawar, Ard Biesheuvel, Gerd Hoffmann,
Samer El-Haj-Mahmoud, Leif Lindholm
Cc: Rebecca Cran
Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
arguments.
The functions return up to 3 values.
Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
4 files changed, 283 insertions(+)
diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
index ced60b3c1147..343ae7f40ad2 100644
--- a/ArmPkg/Include/Library/ArmSmcLib.h
+++ b/ArmPkg/Include/Library/ArmSmcLib.h
@@ -1,5 +1,6 @@
/** @file
*
+* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
* Copyright (c) 2012-2014, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -37,4 +38,76 @@ ArmCallSmc (
IN OUT ARM_SMC_ARGS *Args
);
+/** Trigger an SMC call with 3 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Argument/result.
+ @param Arg3 Argument/result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc3 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ IN OUT UINTN *Arg2,
+ IN OUT UINTN *Arg3
+ );
+
+/** Trigger an SMC call with 2 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Argument/result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc2 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ IN OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ );
+
+/** Trigger an SMC call with 1 argument.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc1 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ );
+
+/** Trigger an SMC call with 0 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Result.
+ @param Arg2 Result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc0 (
+ IN UINTN Function,
+ OUT UINTN *Arg1,
+ OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ );
+
#endif // ARM_SMC_LIB_H_
diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
new file mode 100644
index 000000000000..d596003a857e
--- /dev/null
+++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
@@ -0,0 +1,122 @@
+/** @file
+ SMC helper functions.
+
+ Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/ArmSmcLib.h>
+
+/** Triggers an SMC call with 3 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Argument/result.
+ @param Arg3 Argument/result.
+
+ @return The SMC error code.
+**/
+UINTN
+ArmCallSmc3 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ IN OUT UINTN *Arg2,
+ IN OUT UINTN *Arg3
+ )
+{
+ ARM_SMC_ARGS Args;
+ UINTN ErrorCode;
+
+ Args.Arg0 = Function;
+
+ if (Arg1 != NULL) {
+ Args.Arg1 = *Arg1;
+ }
+ if (Arg2 != NULL) {
+ Args.Arg2 = *Arg2;
+ }
+ if (Arg3 != NULL) {
+ Args.Arg3 = *Arg3;
+ }
+
+ ArmCallSmc (&Args);
+
+ ErrorCode = Args.Arg0;
+
+ if (Arg1 != NULL) {
+ *Arg1 = Args.Arg1;
+ }
+ if (Arg2 != NULL) {
+ *Arg2 = Args.Arg2;
+ }
+ if (Arg3 != NULL) {
+ *Arg3 = Args.Arg3;
+ }
+
+ return ErrorCode;
+}
+
+/** Trigger an SMC call with 2 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Argument/result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc2 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ IN OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ )
+{
+ return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
+}
+
+/** Trigger an SMC call with 1 argument.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc1 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ )
+{
+ return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
+}
+
+/** Trigger an SMC call with 0 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Result.
+ @param Arg2 Result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc0 (
+ IN UINTN Function,
+ OUT UINTN *Arg1,
+ OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ )
+{
+ return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
+}
diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
index 4f4b09f4528a..a89f9203fb7e 100644
--- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
+++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
@@ -20,6 +20,9 @@
[Sources.AARCH64]
AArch64/ArmSmc.S
+[Sources]
+ ArmSmc.c
+
[Packages]
MdePkg/MdePkg.dec
ArmPkg/ArmPkg.dec
diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
index 2d79aadaf1fa..ca1b8830a119 100644
--- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
+++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
@@ -1,4 +1,5 @@
//
+// Copyright (c) 2021, NUVIA Inc. All rights reserved.
// Copyright (c) 2016, Linaro Limited. All rights reserved.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -7,6 +8,7 @@
#include <Base.h>
#include <Library/ArmSmcLib.h>
+#include <IndustryStandard/ArmStdSmc.h>
VOID
ArmCallSmc (
@@ -14,3 +16,86 @@ ArmCallSmc (
)
{
}
+
+/** Triggers an SMC call with 3 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Argument/result.
+ @param Arg3 Argument/result.
+
+ @return The SMC error code.
+**/
+UINTN
+ArmCallSmc3 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ IN OUT UINTN *Arg2,
+ IN OUT UINTN *Arg3
+ )
+{
+ return SMC_ARCH_CALL_NOT_SUPPORTED;
+}
+
+/** Trigger an SMC call with 2 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Argument/result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc2 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ IN OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ )
+{
+ return SMC_ARCH_CALL_NOT_SUPPORTED;
+}
+
+/** Trigger an SMC call with 1 argument.
+
+ @param Function The SMC function.
+ @param Arg1 Argument/result.
+ @param Arg2 Result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc1 (
+ IN UINTN Function,
+ IN OUT UINTN *Arg1,
+ OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ )
+{
+ return SMC_ARCH_CALL_NOT_SUPPORTED;
+}
+
+/** Trigger an SMC call with 0 arguments.
+
+ @param Function The SMC function.
+ @param Arg1 Result.
+ @param Arg2 Result.
+ @param Arg3 Result.
+
+ @return The SMC error code.
+
+**/
+UINTN
+ArmCallSmc0 (
+ IN UINTN Function,
+ OUT UINTN *Arg1,
+ OUT UINTN *Arg2,
+ OUT UINTN *Arg3
+ )
+{
+ return SMC_ARCH_CALL_NOT_SUPPORTED;
+}
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions
2021-11-01 22:11 [PATCH v2 0/2] ArmPkg: Add SMC helper functions Rebecca Cran
2021-11-01 22:11 ` [PATCH v2 1/2] " Rebecca Cran
@ 2021-11-01 22:11 ` Rebecca Cran
2021-12-13 12:26 ` Sami Mujawar
1 sibling, 1 reply; 11+ messages in thread
From: Rebecca Cran @ 2021-11-01 22:11 UTC (permalink / raw)
To: devel, Sami Mujawar, Ard Biesheuvel, Gerd Hoffmann,
Samer El-Haj-Mahmoud, Leif Lindholm
Cc: Rebecca Cran
New SMC helper functions have been added to reduce the amount of
template code. Update ArmSmcPsciResetSystemLib and
Smbios/ProcessorSubClassDxe to use them.
Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c | 10 ++-----
ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c | 31 ++++++++------------
2 files changed, 14 insertions(+), 27 deletions(-)
diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
index 8b5ff5c27e44..319f05c9f1e2 100644
--- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
+++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
@@ -31,11 +31,8 @@ ResetCold (
VOID
)
{
- ARM_SMC_ARGS ArmSmcArgs;
-
// Send a PSCI 0.2 SYSTEM_RESET command
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
- ArmCallSmc (&ArmSmcArgs);
+ ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_RESET, NULL, NULL, NULL);
}
/**
@@ -66,11 +63,8 @@ ResetShutdown (
VOID
)
{
- ARM_SMC_ARGS ArmSmcArgs;
-
// Send a PSCI 0.2 SYSTEM_OFF command
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
- ArmCallSmc (&ArmSmcArgs);
+ ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_OFF, NULL, NULL, NULL);
}
/**
diff --git a/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c b/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
index d644cd33d249..c6d41e3984f8 100644
--- a/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
+++ b/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
@@ -88,22 +88,19 @@ HasSmcArm64SocId (
VOID
)
{
- ARM_SMC_ARGS Args;
INT32 SmcCallStatus;
BOOLEAN Arm64SocIdSupported;
+ UINTN SmcParam;
Arm64SocIdSupported = FALSE;
- Args.Arg0 = SMCCC_VERSION;
- ArmCallSmc (&Args);
- SmcCallStatus = (INT32)Args.Arg0;
+ SmcCallStatus = ArmCallSmc0 (SMCCC_VERSION, NULL, NULL, NULL);
if (SmcCallStatus < 0 || (SmcCallStatus >> 16) >= 1) {
- Args.Arg0 = SMCCC_ARCH_FEATURES;
- Args.Arg1 = SMCCC_ARCH_SOC_ID;
- ArmCallSmc (&Args);
+ SmcParam = SMCCC_ARCH_SOC_ID;
+ SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_FEATURES, &SmcParam, NULL, NULL);
- if (Args.Arg0 >= 0) {
+ if (SmcCallStatus >= 0) {
Arm64SocIdSupported = TRUE;
}
}
@@ -125,30 +122,26 @@ SmbiosGetSmcArm64SocId (
OUT INT32 *SocRevision
)
{
- ARM_SMC_ARGS Args;
INT32 SmcCallStatus;
EFI_STATUS Status;
+ UINTN SmcParam;
Status = EFI_SUCCESS;
- Args.Arg0 = SMCCC_ARCH_SOC_ID;
- Args.Arg1 = 0;
- ArmCallSmc (&Args);
- SmcCallStatus = (INT32)Args.Arg0;
+ SmcParam = 0;
+ SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
if (SmcCallStatus >= 0) {
- *Jep106Code = (INT32)Args.Arg0;
+ *Jep106Code = (INT32)SmcParam;
} else {
Status = EFI_UNSUPPORTED;
}
- Args.Arg0 = SMCCC_ARCH_SOC_ID;
- Args.Arg1 = 1;
- ArmCallSmc (&Args);
- SmcCallStatus = (INT32)Args.Arg0;
+ SmcParam = 1;
+ SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
if (SmcCallStatus >= 0) {
- *SocRevision = (INT32)Args.Arg0;
+ *SocRevision = (INT32)SmcParam;
} else {
Status = EFI_UNSUPPORTED;
}
--
2.31.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-11-01 22:11 ` [PATCH v2 1/2] " Rebecca Cran
@ 2021-11-09 1:56 ` Rebecca Cran
2021-11-09 11:57 ` Leif Lindholm
2021-12-13 12:31 ` Sami Mujawar
1 sibling, 1 reply; 11+ messages in thread
From: Rebecca Cran @ 2021-11-09 1:56 UTC (permalink / raw)
To: devel, Sami Mujawar, Ard Biesheuvel, Gerd Hoffmann,
Samer El-Haj-Mahmoud, Leif Lindholm
Could I have some reviews on this please?
--
Rebecca Cran
On 11/1/21 4:11 PM, Rebecca Cran wrote:
> Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
> arguments.
> The functions return up to 3 values.
>
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> ---
> ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
> ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
> ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
> ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
> 4 files changed, 283 insertions(+)
>
> diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
> index ced60b3c1147..343ae7f40ad2 100644
> --- a/ArmPkg/Include/Library/ArmSmcLib.h
> +++ b/ArmPkg/Include/Library/ArmSmcLib.h
> @@ -1,5 +1,6 @@
> /** @file
> *
> +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
> *
> * SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -37,4 +38,76 @@ ArmCallSmc (
> IN OUT ARM_SMC_ARGS *Args
> );
>
> +/** Trigger an SMC call with 3 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Argument/result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc3 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + IN OUT UINTN *Arg3
> + );
> +
> +/** Trigger an SMC call with 2 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc2 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + );
> +
> +/** Trigger an SMC call with 1 argument.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc1 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + );
> +
> +/** Trigger an SMC call with 0 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc0 (
> + IN UINTN Function,
> + OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + );
> +
> #endif // ARM_SMC_LIB_H_
> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> new file mode 100644
> index 000000000000..d596003a857e
> --- /dev/null
> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> @@ -0,0 +1,122 @@
> +/** @file
> + SMC helper functions.
> +
> + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/ArmSmcLib.h>
> +
> +/** Triggers an SMC call with 3 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Argument/result.
> +
> + @return The SMC error code.
> +**/
> +UINTN
> +ArmCallSmc3 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + IN OUT UINTN *Arg3
> + )
> +{
> + ARM_SMC_ARGS Args;
> + UINTN ErrorCode;
> +
> + Args.Arg0 = Function;
> +
> + if (Arg1 != NULL) {
> + Args.Arg1 = *Arg1;
> + }
> + if (Arg2 != NULL) {
> + Args.Arg2 = *Arg2;
> + }
> + if (Arg3 != NULL) {
> + Args.Arg3 = *Arg3;
> + }
> +
> + ArmCallSmc (&Args);
> +
> + ErrorCode = Args.Arg0;
> +
> + if (Arg1 != NULL) {
> + *Arg1 = Args.Arg1;
> + }
> + if (Arg2 != NULL) {
> + *Arg2 = Args.Arg2;
> + }
> + if (Arg3 != NULL) {
> + *Arg3 = Args.Arg3;
> + }
> +
> + return ErrorCode;
> +}
> +
> +/** Trigger an SMC call with 2 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc2 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> +}
> +
> +/** Trigger an SMC call with 1 argument.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc1 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> +}
> +
> +/** Trigger an SMC call with 0 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc0 (
> + IN UINTN Function,
> + OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> +}
> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> index 4f4b09f4528a..a89f9203fb7e 100644
> --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> @@ -20,6 +20,9 @@
> [Sources.AARCH64]
> AArch64/ArmSmc.S
>
> +[Sources]
> + ArmSmc.c
> +
> [Packages]
> MdePkg/MdePkg.dec
> ArmPkg/ArmPkg.dec
> diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> index 2d79aadaf1fa..ca1b8830a119 100644
> --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> @@ -1,4 +1,5 @@
> //
> +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
> // Copyright (c) 2016, Linaro Limited. All rights reserved.
> //
> // SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -7,6 +8,7 @@
>
> #include <Base.h>
> #include <Library/ArmSmcLib.h>
> +#include <IndustryStandard/ArmStdSmc.h>
>
> VOID
> ArmCallSmc (
> @@ -14,3 +16,86 @@ ArmCallSmc (
> )
> {
> }
> +
> +/** Triggers an SMC call with 3 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Argument/result.
> +
> + @return The SMC error code.
> +**/
> +UINTN
> +ArmCallSmc3 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + IN OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
> +
> +/** Trigger an SMC call with 2 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc2 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
> +
> +/** Trigger an SMC call with 1 argument.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc1 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
> +
> +/** Trigger an SMC call with 0 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc0 (
> + IN UINTN Function,
> + OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-11-09 1:56 ` Rebecca Cran
@ 2021-11-09 11:57 ` Leif Lindholm
2021-11-09 12:15 ` Ard Biesheuvel
0 siblings, 1 reply; 11+ messages in thread
From: Leif Lindholm @ 2021-11-09 11:57 UTC (permalink / raw)
To: Rebecca Cran, Ard Biesheuvel
Cc: devel, Sami Mujawar, Gerd Hoffmann, Samer El-Haj-Mahmoud
On Mon, Nov 08, 2021 at 18:56:09 -0700, Rebecca Cran wrote:
> Could I have some reviews on this please?
I'm all for it. It's clunky, but less clunky than the situation
without, and it improves readability at call sites.
Ard had some reservations for v1 not actually adding any users.
Ard - do you like it any better now Rebecca's added some?
/
Leif
> Rebecca Cran
>
>
> On 11/1/21 4:11 PM, Rebecca Cran wrote:
> > Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
> > arguments.
> > The functions return up to 3 values.
> >
> > Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> > ---
> > ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
> > ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
> > ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
> > ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
> > 4 files changed, 283 insertions(+)
> >
> > diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
> > index ced60b3c1147..343ae7f40ad2 100644
> > --- a/ArmPkg/Include/Library/ArmSmcLib.h
> > +++ b/ArmPkg/Include/Library/ArmSmcLib.h
> > @@ -1,5 +1,6 @@
> > /** @file
> > *
> > +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> > * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
> > *
> > * SPDX-License-Identifier: BSD-2-Clause-Patent
> > @@ -37,4 +38,76 @@ ArmCallSmc (
> > IN OUT ARM_SMC_ARGS *Args
> > );
> > +/** Trigger an SMC call with 3 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Argument/result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc3 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + IN OUT UINTN *Arg3
> > + );
> > +
> > +/** Trigger an SMC call with 2 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc2 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + );
> > +
> > +/** Trigger an SMC call with 1 argument.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc1 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + );
> > +
> > +/** Trigger an SMC call with 0 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc0 (
> > + IN UINTN Function,
> > + OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + );
> > +
> > #endif // ARM_SMC_LIB_H_
> > diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> > new file mode 100644
> > index 000000000000..d596003a857e
> > --- /dev/null
> > +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> > @@ -0,0 +1,122 @@
> > +/** @file
> > + SMC helper functions.
> > +
> > + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> > +
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include <Library/ArmSmcLib.h>
> > +
> > +/** Triggers an SMC call with 3 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Argument/result.
> > +
> > + @return The SMC error code.
> > +**/
> > +UINTN
> > +ArmCallSmc3 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + IN OUT UINTN *Arg3
> > + )
> > +{
> > + ARM_SMC_ARGS Args;
> > + UINTN ErrorCode;
> > +
> > + Args.Arg0 = Function;
> > +
> > + if (Arg1 != NULL) {
> > + Args.Arg1 = *Arg1;
> > + }
> > + if (Arg2 != NULL) {
> > + Args.Arg2 = *Arg2;
> > + }
> > + if (Arg3 != NULL) {
> > + Args.Arg3 = *Arg3;
> > + }
> > +
> > + ArmCallSmc (&Args);
> > +
> > + ErrorCode = Args.Arg0;
> > +
> > + if (Arg1 != NULL) {
> > + *Arg1 = Args.Arg1;
> > + }
> > + if (Arg2 != NULL) {
> > + *Arg2 = Args.Arg2;
> > + }
> > + if (Arg3 != NULL) {
> > + *Arg3 = Args.Arg3;
> > + }
> > +
> > + return ErrorCode;
> > +}
> > +
> > +/** Trigger an SMC call with 2 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc2 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > +}
> > +
> > +/** Trigger an SMC call with 1 argument.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc1 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > +}
> > +
> > +/** Trigger an SMC call with 0 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc0 (
> > + IN UINTN Function,
> > + OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > +}
> > diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > index 4f4b09f4528a..a89f9203fb7e 100644
> > --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > @@ -20,6 +20,9 @@
> > [Sources.AARCH64]
> > AArch64/ArmSmc.S
> > +[Sources]
> > + ArmSmc.c
> > +
> > [Packages]
> > MdePkg/MdePkg.dec
> > ArmPkg/ArmPkg.dec
> > diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > index 2d79aadaf1fa..ca1b8830a119 100644
> > --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > @@ -1,4 +1,5 @@
> > //
> > +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
> > // Copyright (c) 2016, Linaro Limited. All rights reserved.
> > //
> > // SPDX-License-Identifier: BSD-2-Clause-Patent
> > @@ -7,6 +8,7 @@
> > #include <Base.h>
> > #include <Library/ArmSmcLib.h>
> > +#include <IndustryStandard/ArmStdSmc.h>
> > VOID
> > ArmCallSmc (
> > @@ -14,3 +16,86 @@ ArmCallSmc (
> > )
> > {
> > }
> > +
> > +/** Triggers an SMC call with 3 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Argument/result.
> > +
> > + @return The SMC error code.
> > +**/
> > +UINTN
> > +ArmCallSmc3 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + IN OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
> > +
> > +/** Trigger an SMC call with 2 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Argument/result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc2 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + IN OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
> > +
> > +/** Trigger an SMC call with 1 argument.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Argument/result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc1 (
> > + IN UINTN Function,
> > + IN OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
> > +
> > +/** Trigger an SMC call with 0 arguments.
> > +
> > + @param Function The SMC function.
> > + @param Arg1 Result.
> > + @param Arg2 Result.
> > + @param Arg3 Result.
> > +
> > + @return The SMC error code.
> > +
> > +**/
> > +UINTN
> > +ArmCallSmc0 (
> > + IN UINTN Function,
> > + OUT UINTN *Arg1,
> > + OUT UINTN *Arg2,
> > + OUT UINTN *Arg3
> > + )
> > +{
> > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > +}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-11-09 11:57 ` Leif Lindholm
@ 2021-11-09 12:15 ` Ard Biesheuvel
2021-12-09 22:54 ` Rebecca Cran
0 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2021-11-09 12:15 UTC (permalink / raw)
To: Leif Lindholm
Cc: Rebecca Cran, Ard Biesheuvel, edk2-devel-groups-io, Sami Mujawar,
Gerd Hoffmann, Samer El-Haj-Mahmoud
On Tue, 9 Nov 2021 at 12:57, Leif Lindholm <leif@nuviainc.com> wrote:
>
> On Mon, Nov 08, 2021 at 18:56:09 -0700, Rebecca Cran wrote:
> > Could I have some reviews on this please?
>
> I'm all for it. It's clunky, but less clunky than the situation
> without, and it improves readability at call sites.
>
> Ard had some reservations for v1 not actually adding any users.
> Ard - do you like it any better now Rebecca's added some?
>
Yeah, this is fine. TBH, I am not going to have time to look into this
in detail again, so if you're both happy, then I am too.
Acked-by: Ard Biesheuvel <ardb@kernel.org>
> > On 11/1/21 4:11 PM, Rebecca Cran wrote:
> > > Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
> > > arguments.
> > > The functions return up to 3 values.
> > >
> > > Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> > > ---
> > > ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
> > > ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
> > > ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
> > > ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
> > > 4 files changed, 283 insertions(+)
> > >
> > > diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
> > > index ced60b3c1147..343ae7f40ad2 100644
> > > --- a/ArmPkg/Include/Library/ArmSmcLib.h
> > > +++ b/ArmPkg/Include/Library/ArmSmcLib.h
> > > @@ -1,5 +1,6 @@
> > > /** @file
> > > *
> > > +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> > > * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
> > > *
> > > * SPDX-License-Identifier: BSD-2-Clause-Patent
> > > @@ -37,4 +38,76 @@ ArmCallSmc (
> > > IN OUT ARM_SMC_ARGS *Args
> > > );
> > > +/** Trigger an SMC call with 3 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Argument/result.
> > > + @param Arg3 Argument/result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc3 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + IN OUT UINTN *Arg2,
> > > + IN OUT UINTN *Arg3
> > > + );
> > > +
> > > +/** Trigger an SMC call with 2 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Argument/result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc2 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + IN OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + );
> > > +
> > > +/** Trigger an SMC call with 1 argument.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc1 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + );
> > > +
> > > +/** Trigger an SMC call with 0 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Result.
> > > + @param Arg2 Result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc0 (
> > > + IN UINTN Function,
> > > + OUT UINTN *Arg1,
> > > + OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + );
> > > +
> > > #endif // ARM_SMC_LIB_H_
> > > diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> > > new file mode 100644
> > > index 000000000000..d596003a857e
> > > --- /dev/null
> > > +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> > > @@ -0,0 +1,122 @@
> > > +/** @file
> > > + SMC helper functions.
> > > +
> > > + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> > > +
> > > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > > +
> > > +**/
> > > +
> > > +#include <Library/ArmSmcLib.h>
> > > +
> > > +/** Triggers an SMC call with 3 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Argument/result.
> > > + @param Arg3 Argument/result.
> > > +
> > > + @return The SMC error code.
> > > +**/
> > > +UINTN
> > > +ArmCallSmc3 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + IN OUT UINTN *Arg2,
> > > + IN OUT UINTN *Arg3
> > > + )
> > > +{
> > > + ARM_SMC_ARGS Args;
> > > + UINTN ErrorCode;
> > > +
> > > + Args.Arg0 = Function;
> > > +
> > > + if (Arg1 != NULL) {
> > > + Args.Arg1 = *Arg1;
> > > + }
> > > + if (Arg2 != NULL) {
> > > + Args.Arg2 = *Arg2;
> > > + }
> > > + if (Arg3 != NULL) {
> > > + Args.Arg3 = *Arg3;
> > > + }
> > > +
> > > + ArmCallSmc (&Args);
> > > +
> > > + ErrorCode = Args.Arg0;
> > > +
> > > + if (Arg1 != NULL) {
> > > + *Arg1 = Args.Arg1;
> > > + }
> > > + if (Arg2 != NULL) {
> > > + *Arg2 = Args.Arg2;
> > > + }
> > > + if (Arg3 != NULL) {
> > > + *Arg3 = Args.Arg3;
> > > + }
> > > +
> > > + return ErrorCode;
> > > +}
> > > +
> > > +/** Trigger an SMC call with 2 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Argument/result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc2 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + IN OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > > +}
> > > +
> > > +/** Trigger an SMC call with 1 argument.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc1 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > > +}
> > > +
> > > +/** Trigger an SMC call with 0 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Result.
> > > + @param Arg2 Result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc0 (
> > > + IN UINTN Function,
> > > + OUT UINTN *Arg1,
> > > + OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> > > +}
> > > diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > > index 4f4b09f4528a..a89f9203fb7e 100644
> > > --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > > +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> > > @@ -20,6 +20,9 @@
> > > [Sources.AARCH64]
> > > AArch64/ArmSmc.S
> > > +[Sources]
> > > + ArmSmc.c
> > > +
> > > [Packages]
> > > MdePkg/MdePkg.dec
> > > ArmPkg/ArmPkg.dec
> > > diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > > index 2d79aadaf1fa..ca1b8830a119 100644
> > > --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > > +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> > > @@ -1,4 +1,5 @@
> > > //
> > > +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
> > > // Copyright (c) 2016, Linaro Limited. All rights reserved.
> > > //
> > > // SPDX-License-Identifier: BSD-2-Clause-Patent
> > > @@ -7,6 +8,7 @@
> > > #include <Base.h>
> > > #include <Library/ArmSmcLib.h>
> > > +#include <IndustryStandard/ArmStdSmc.h>
> > > VOID
> > > ArmCallSmc (
> > > @@ -14,3 +16,86 @@ ArmCallSmc (
> > > )
> > > {
> > > }
> > > +
> > > +/** Triggers an SMC call with 3 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Argument/result.
> > > + @param Arg3 Argument/result.
> > > +
> > > + @return The SMC error code.
> > > +**/
> > > +UINTN
> > > +ArmCallSmc3 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + IN OUT UINTN *Arg2,
> > > + IN OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > > +}
> > > +
> > > +/** Trigger an SMC call with 2 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Argument/result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc2 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + IN OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > > +}
> > > +
> > > +/** Trigger an SMC call with 1 argument.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Argument/result.
> > > + @param Arg2 Result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc1 (
> > > + IN UINTN Function,
> > > + IN OUT UINTN *Arg1,
> > > + OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > > +}
> > > +
> > > +/** Trigger an SMC call with 0 arguments.
> > > +
> > > + @param Function The SMC function.
> > > + @param Arg1 Result.
> > > + @param Arg2 Result.
> > > + @param Arg3 Result.
> > > +
> > > + @return The SMC error code.
> > > +
> > > +**/
> > > +UINTN
> > > +ArmCallSmc0 (
> > > + IN UINTN Function,
> > > + OUT UINTN *Arg1,
> > > + OUT UINTN *Arg2,
> > > + OUT UINTN *Arg3
> > > + )
> > > +{
> > > + return SMC_ARCH_CALL_NOT_SUPPORTED;
> > > +}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-11-09 12:15 ` Ard Biesheuvel
@ 2021-12-09 22:54 ` Rebecca Cran
2021-12-13 11:49 ` Ard Biesheuvel
0 siblings, 1 reply; 11+ messages in thread
From: Rebecca Cran @ 2021-12-09 22:54 UTC (permalink / raw)
To: Ard Biesheuvel, Leif Lindholm
Cc: Ard Biesheuvel, edk2-devel-groups-io, Sami Mujawar, Gerd Hoffmann,
Samer El-Haj-Mahmoud
Now that the edk2 tree is unfrozen, I'd like to get this committed.
Could anyone else review it please, or if it's ready commit it?
Thanks.
Rebecca Cran
On 11/9/21 5:15 AM, Ard Biesheuvel wrote:
> On Tue, 9 Nov 2021 at 12:57, Leif Lindholm <leif@nuviainc.com> wrote:
>> On Mon, Nov 08, 2021 at 18:56:09 -0700, Rebecca Cran wrote:
>>> Could I have some reviews on this please?
>> I'm all for it. It's clunky, but less clunky than the situation
>> without, and it improves readability at call sites.
>>
>> Ard had some reservations for v1 not actually adding any users.
>> Ard - do you like it any better now Rebecca's added some?
>>
> Yeah, this is fine. TBH, I am not going to have time to look into this
> in detail again, so if you're both happy, then I am too.
>
> Acked-by: Ard Biesheuvel <ardb@kernel.org>
>
>
>
>>> On 11/1/21 4:11 PM, Rebecca Cran wrote:
>>>> Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
>>>> arguments.
>>>> The functions return up to 3 values.
>>>>
>>>> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
>>>> ---
>>>> ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
>>>> ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
>>>> ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
>>>> ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
>>>> 4 files changed, 283 insertions(+)
>>>>
>>>> diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
>>>> index ced60b3c1147..343ae7f40ad2 100644
>>>> --- a/ArmPkg/Include/Library/ArmSmcLib.h
>>>> +++ b/ArmPkg/Include/Library/ArmSmcLib.h
>>>> @@ -1,5 +1,6 @@
>>>> /** @file
>>>> *
>>>> +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
>>>> * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
>>>> *
>>>> * SPDX-License-Identifier: BSD-2-Clause-Patent
>>>> @@ -37,4 +38,76 @@ ArmCallSmc (
>>>> IN OUT ARM_SMC_ARGS *Args
>>>> );
>>>> +/** Trigger an SMC call with 3 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Argument/result.
>>>> + @param Arg3 Argument/result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc3 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + IN OUT UINTN *Arg2,
>>>> + IN OUT UINTN *Arg3
>>>> + );
>>>> +
>>>> +/** Trigger an SMC call with 2 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Argument/result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc2 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + IN OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + );
>>>> +
>>>> +/** Trigger an SMC call with 1 argument.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc1 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + );
>>>> +
>>>> +/** Trigger an SMC call with 0 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Result.
>>>> + @param Arg2 Result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc0 (
>>>> + IN UINTN Function,
>>>> + OUT UINTN *Arg1,
>>>> + OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + );
>>>> +
>>>> #endif // ARM_SMC_LIB_H_
>>>> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
>>>> new file mode 100644
>>>> index 000000000000..d596003a857e
>>>> --- /dev/null
>>>> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
>>>> @@ -0,0 +1,122 @@
>>>> +/** @file
>>>> + SMC helper functions.
>>>> +
>>>> + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
>>>> +
>>>> + SPDX-License-Identifier: BSD-2-Clause-Patent
>>>> +
>>>> +**/
>>>> +
>>>> +#include <Library/ArmSmcLib.h>
>>>> +
>>>> +/** Triggers an SMC call with 3 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Argument/result.
>>>> + @param Arg3 Argument/result.
>>>> +
>>>> + @return The SMC error code.
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc3 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + IN OUT UINTN *Arg2,
>>>> + IN OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + ARM_SMC_ARGS Args;
>>>> + UINTN ErrorCode;
>>>> +
>>>> + Args.Arg0 = Function;
>>>> +
>>>> + if (Arg1 != NULL) {
>>>> + Args.Arg1 = *Arg1;
>>>> + }
>>>> + if (Arg2 != NULL) {
>>>> + Args.Arg2 = *Arg2;
>>>> + }
>>>> + if (Arg3 != NULL) {
>>>> + Args.Arg3 = *Arg3;
>>>> + }
>>>> +
>>>> + ArmCallSmc (&Args);
>>>> +
>>>> + ErrorCode = Args.Arg0;
>>>> +
>>>> + if (Arg1 != NULL) {
>>>> + *Arg1 = Args.Arg1;
>>>> + }
>>>> + if (Arg2 != NULL) {
>>>> + *Arg2 = Args.Arg2;
>>>> + }
>>>> + if (Arg3 != NULL) {
>>>> + *Arg3 = Args.Arg3;
>>>> + }
>>>> +
>>>> + return ErrorCode;
>>>> +}
>>>> +
>>>> +/** Trigger an SMC call with 2 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Argument/result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc2 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + IN OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
>>>> +}
>>>> +
>>>> +/** Trigger an SMC call with 1 argument.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc1 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
>>>> +}
>>>> +
>>>> +/** Trigger an SMC call with 0 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Result.
>>>> + @param Arg2 Result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc0 (
>>>> + IN UINTN Function,
>>>> + OUT UINTN *Arg1,
>>>> + OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
>>>> +}
>>>> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
>>>> index 4f4b09f4528a..a89f9203fb7e 100644
>>>> --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
>>>> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
>>>> @@ -20,6 +20,9 @@
>>>> [Sources.AARCH64]
>>>> AArch64/ArmSmc.S
>>>> +[Sources]
>>>> + ArmSmc.c
>>>> +
>>>> [Packages]
>>>> MdePkg/MdePkg.dec
>>>> ArmPkg/ArmPkg.dec
>>>> diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
>>>> index 2d79aadaf1fa..ca1b8830a119 100644
>>>> --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
>>>> +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
>>>> @@ -1,4 +1,5 @@
>>>> //
>>>> +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
>>>> // Copyright (c) 2016, Linaro Limited. All rights reserved.
>>>> //
>>>> // SPDX-License-Identifier: BSD-2-Clause-Patent
>>>> @@ -7,6 +8,7 @@
>>>> #include <Base.h>
>>>> #include <Library/ArmSmcLib.h>
>>>> +#include <IndustryStandard/ArmStdSmc.h>
>>>> VOID
>>>> ArmCallSmc (
>>>> @@ -14,3 +16,86 @@ ArmCallSmc (
>>>> )
>>>> {
>>>> }
>>>> +
>>>> +/** Triggers an SMC call with 3 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Argument/result.
>>>> + @param Arg3 Argument/result.
>>>> +
>>>> + @return The SMC error code.
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc3 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + IN OUT UINTN *Arg2,
>>>> + IN OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>> +}
>>>> +
>>>> +/** Trigger an SMC call with 2 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Argument/result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc2 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + IN OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>> +}
>>>> +
>>>> +/** Trigger an SMC call with 1 argument.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Argument/result.
>>>> + @param Arg2 Result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc1 (
>>>> + IN UINTN Function,
>>>> + IN OUT UINTN *Arg1,
>>>> + OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>> +}
>>>> +
>>>> +/** Trigger an SMC call with 0 arguments.
>>>> +
>>>> + @param Function The SMC function.
>>>> + @param Arg1 Result.
>>>> + @param Arg2 Result.
>>>> + @param Arg3 Result.
>>>> +
>>>> + @return The SMC error code.
>>>> +
>>>> +**/
>>>> +UINTN
>>>> +ArmCallSmc0 (
>>>> + IN UINTN Function,
>>>> + OUT UINTN *Arg1,
>>>> + OUT UINTN *Arg2,
>>>> + OUT UINTN *Arg3
>>>> + )
>>>> +{
>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>> +}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-12-09 22:54 ` Rebecca Cran
@ 2021-12-13 11:49 ` Ard Biesheuvel
2021-12-13 12:26 ` Sami Mujawar
0 siblings, 1 reply; 11+ messages in thread
From: Ard Biesheuvel @ 2021-12-13 11:49 UTC (permalink / raw)
To: Rebecca Cran
Cc: Leif Lindholm, Ard Biesheuvel, edk2-devel-groups-io, Sami Mujawar,
Gerd Hoffmann, Samer El-Haj-Mahmoud
On Thu, 9 Dec 2021 at 23:54, Rebecca Cran <rebecca@nuviainc.com> wrote:
>
> Now that the edk2 tree is unfrozen, I'd like to get this committed.
>
> Could anyone else review it please, or if it's ready commit it?
>
>
I think this is fine to go in, but you'll need to rebase on top of the
uncrustify changes in any case.
Sami, Leif: any comments?
>
> On 11/9/21 5:15 AM, Ard Biesheuvel wrote:
> > On Tue, 9 Nov 2021 at 12:57, Leif Lindholm <leif@nuviainc.com> wrote:
> >> On Mon, Nov 08, 2021 at 18:56:09 -0700, Rebecca Cran wrote:
> >>> Could I have some reviews on this please?
> >> I'm all for it. It's clunky, but less clunky than the situation
> >> without, and it improves readability at call sites.
> >>
> >> Ard had some reservations for v1 not actually adding any users.
> >> Ard - do you like it any better now Rebecca's added some?
> >>
> > Yeah, this is fine. TBH, I am not going to have time to look into this
> > in detail again, so if you're both happy, then I am too.
> >
> > Acked-by: Ard Biesheuvel <ardb@kernel.org>
> >
> >
> >
> >>> On 11/1/21 4:11 PM, Rebecca Cran wrote:
> >>>> Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
> >>>> arguments.
> >>>> The functions return up to 3 values.
> >>>>
> >>>> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> >>>> ---
> >>>> ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
> >>>> ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
> >>>> ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
> >>>> ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
> >>>> 4 files changed, 283 insertions(+)
> >>>>
> >>>> diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
> >>>> index ced60b3c1147..343ae7f40ad2 100644
> >>>> --- a/ArmPkg/Include/Library/ArmSmcLib.h
> >>>> +++ b/ArmPkg/Include/Library/ArmSmcLib.h
> >>>> @@ -1,5 +1,6 @@
> >>>> /** @file
> >>>> *
> >>>> +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> >>>> * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
> >>>> *
> >>>> * SPDX-License-Identifier: BSD-2-Clause-Patent
> >>>> @@ -37,4 +38,76 @@ ArmCallSmc (
> >>>> IN OUT ARM_SMC_ARGS *Args
> >>>> );
> >>>> +/** Trigger an SMC call with 3 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Argument/result.
> >>>> + @param Arg3 Argument/result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc3 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + IN OUT UINTN *Arg2,
> >>>> + IN OUT UINTN *Arg3
> >>>> + );
> >>>> +
> >>>> +/** Trigger an SMC call with 2 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Argument/result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc2 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + IN OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + );
> >>>> +
> >>>> +/** Trigger an SMC call with 1 argument.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc1 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + );
> >>>> +
> >>>> +/** Trigger an SMC call with 0 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Result.
> >>>> + @param Arg2 Result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc0 (
> >>>> + IN UINTN Function,
> >>>> + OUT UINTN *Arg1,
> >>>> + OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + );
> >>>> +
> >>>> #endif // ARM_SMC_LIB_H_
> >>>> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> >>>> new file mode 100644
> >>>> index 000000000000..d596003a857e
> >>>> --- /dev/null
> >>>> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> >>>> @@ -0,0 +1,122 @@
> >>>> +/** @file
> >>>> + SMC helper functions.
> >>>> +
> >>>> + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> >>>> +
> >>>> + SPDX-License-Identifier: BSD-2-Clause-Patent
> >>>> +
> >>>> +**/
> >>>> +
> >>>> +#include <Library/ArmSmcLib.h>
> >>>> +
> >>>> +/** Triggers an SMC call with 3 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Argument/result.
> >>>> + @param Arg3 Argument/result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc3 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + IN OUT UINTN *Arg2,
> >>>> + IN OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + ARM_SMC_ARGS Args;
> >>>> + UINTN ErrorCode;
> >>>> +
> >>>> + Args.Arg0 = Function;
> >>>> +
> >>>> + if (Arg1 != NULL) {
> >>>> + Args.Arg1 = *Arg1;
> >>>> + }
> >>>> + if (Arg2 != NULL) {
> >>>> + Args.Arg2 = *Arg2;
> >>>> + }
> >>>> + if (Arg3 != NULL) {
> >>>> + Args.Arg3 = *Arg3;
> >>>> + }
> >>>> +
> >>>> + ArmCallSmc (&Args);
> >>>> +
> >>>> + ErrorCode = Args.Arg0;
> >>>> +
> >>>> + if (Arg1 != NULL) {
> >>>> + *Arg1 = Args.Arg1;
> >>>> + }
> >>>> + if (Arg2 != NULL) {
> >>>> + *Arg2 = Args.Arg2;
> >>>> + }
> >>>> + if (Arg3 != NULL) {
> >>>> + *Arg3 = Args.Arg3;
> >>>> + }
> >>>> +
> >>>> + return ErrorCode;
> >>>> +}
> >>>> +
> >>>> +/** Trigger an SMC call with 2 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Argument/result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc2 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + IN OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> >>>> +}
> >>>> +
> >>>> +/** Trigger an SMC call with 1 argument.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc1 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> >>>> +}
> >>>> +
> >>>> +/** Trigger an SMC call with 0 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Result.
> >>>> + @param Arg2 Result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc0 (
> >>>> + IN UINTN Function,
> >>>> + OUT UINTN *Arg1,
> >>>> + OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> >>>> +}
> >>>> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> >>>> index 4f4b09f4528a..a89f9203fb7e 100644
> >>>> --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> >>>> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> >>>> @@ -20,6 +20,9 @@
> >>>> [Sources.AARCH64]
> >>>> AArch64/ArmSmc.S
> >>>> +[Sources]
> >>>> + ArmSmc.c
> >>>> +
> >>>> [Packages]
> >>>> MdePkg/MdePkg.dec
> >>>> ArmPkg/ArmPkg.dec
> >>>> diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> >>>> index 2d79aadaf1fa..ca1b8830a119 100644
> >>>> --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> >>>> +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> >>>> @@ -1,4 +1,5 @@
> >>>> //
> >>>> +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
> >>>> // Copyright (c) 2016, Linaro Limited. All rights reserved.
> >>>> //
> >>>> // SPDX-License-Identifier: BSD-2-Clause-Patent
> >>>> @@ -7,6 +8,7 @@
> >>>> #include <Base.h>
> >>>> #include <Library/ArmSmcLib.h>
> >>>> +#include <IndustryStandard/ArmStdSmc.h>
> >>>> VOID
> >>>> ArmCallSmc (
> >>>> @@ -14,3 +16,86 @@ ArmCallSmc (
> >>>> )
> >>>> {
> >>>> }
> >>>> +
> >>>> +/** Triggers an SMC call with 3 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Argument/result.
> >>>> + @param Arg3 Argument/result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc3 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + IN OUT UINTN *Arg2,
> >>>> + IN OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> >>>> +}
> >>>> +
> >>>> +/** Trigger an SMC call with 2 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Argument/result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc2 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + IN OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> >>>> +}
> >>>> +
> >>>> +/** Trigger an SMC call with 1 argument.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Argument/result.
> >>>> + @param Arg2 Result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc1 (
> >>>> + IN UINTN Function,
> >>>> + IN OUT UINTN *Arg1,
> >>>> + OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> >>>> +}
> >>>> +
> >>>> +/** Trigger an SMC call with 0 arguments.
> >>>> +
> >>>> + @param Function The SMC function.
> >>>> + @param Arg1 Result.
> >>>> + @param Arg2 Result.
> >>>> + @param Arg3 Result.
> >>>> +
> >>>> + @return The SMC error code.
> >>>> +
> >>>> +**/
> >>>> +UINTN
> >>>> +ArmCallSmc0 (
> >>>> + IN UINTN Function,
> >>>> + OUT UINTN *Arg1,
> >>>> + OUT UINTN *Arg2,
> >>>> + OUT UINTN *Arg3
> >>>> + )
> >>>> +{
> >>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> >>>> +}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-12-13 11:49 ` Ard Biesheuvel
@ 2021-12-13 12:26 ` Sami Mujawar
0 siblings, 0 replies; 11+ messages in thread
From: Sami Mujawar @ 2021-12-13 12:26 UTC (permalink / raw)
To: Ard Biesheuvel, Rebecca Cran
Cc: Leif Lindholm, Ard Biesheuvel, edk2-devel-groups-io,
Gerd Hoffmann, Samer El-Haj-Mahmoud, nd
Hi Ard,
On 13/12/2021 11:49 AM, Ard Biesheuvel wrote:
> On Thu, 9 Dec 2021 at 23:54, Rebecca Cran <rebecca@nuviainc.com> wrote:
>> Now that the edk2 tree is unfrozen, I'd like to get this committed.
>>
>> Could anyone else review it please, or if it's ready commit it?
>>
>>
> I think this is fine to go in, but you'll need to rebase on top of the
> uncrustify changes in any case.
>
> Sami, Leif: any comments?
I have some minor suggestions, that I will reply back shortly.
Regards,
Sami Mujawar
>
>
>
>> On 11/9/21 5:15 AM, Ard Biesheuvel wrote:
>>> On Tue, 9 Nov 2021 at 12:57, Leif Lindholm <leif@nuviainc.com> wrote:
>>>> On Mon, Nov 08, 2021 at 18:56:09 -0700, Rebecca Cran wrote:
>>>>> Could I have some reviews on this please?
>>>> I'm all for it. It's clunky, but less clunky than the situation
>>>> without, and it improves readability at call sites.
>>>>
>>>> Ard had some reservations for v1 not actually adding any users.
>>>> Ard - do you like it any better now Rebecca's added some?
>>>>
>>> Yeah, this is fine. TBH, I am not going to have time to look into this
>>> in detail again, so if you're both happy, then I am too.
>>>
>>> Acked-by: Ard Biesheuvel <ardb@kernel.org>
>>>
>>>
>>>
>>>>> On 11/1/21 4:11 PM, Rebecca Cran wrote:
>>>>>> Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
>>>>>> arguments.
>>>>>> The functions return up to 3 values.
>>>>>>
>>>>>> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
>>>>>> ---
>>>>>> ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
>>>>>> ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
>>>>>> ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
>>>>>> ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
>>>>>> 4 files changed, 283 insertions(+)
>>>>>>
>>>>>> diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
>>>>>> index ced60b3c1147..343ae7f40ad2 100644
>>>>>> --- a/ArmPkg/Include/Library/ArmSmcLib.h
>>>>>> +++ b/ArmPkg/Include/Library/ArmSmcLib.h
>>>>>> @@ -1,5 +1,6 @@
>>>>>> /** @file
>>>>>> *
>>>>>> +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
>>>>>> * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
>>>>>> *
>>>>>> * SPDX-License-Identifier: BSD-2-Clause-Patent
>>>>>> @@ -37,4 +38,76 @@ ArmCallSmc (
>>>>>> IN OUT ARM_SMC_ARGS *Args
>>>>>> );
>>>>>> +/** Trigger an SMC call with 3 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Argument/result.
>>>>>> + @param Arg3 Argument/result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc3 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + IN OUT UINTN *Arg2,
>>>>>> + IN OUT UINTN *Arg3
>>>>>> + );
>>>>>> +
>>>>>> +/** Trigger an SMC call with 2 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Argument/result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc2 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + IN OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + );
>>>>>> +
>>>>>> +/** Trigger an SMC call with 1 argument.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc1 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + );
>>>>>> +
>>>>>> +/** Trigger an SMC call with 0 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Result.
>>>>>> + @param Arg2 Result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc0 (
>>>>>> + IN UINTN Function,
>>>>>> + OUT UINTN *Arg1,
>>>>>> + OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + );
>>>>>> +
>>>>>> #endif // ARM_SMC_LIB_H_
>>>>>> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
>>>>>> new file mode 100644
>>>>>> index 000000000000..d596003a857e
>>>>>> --- /dev/null
>>>>>> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
>>>>>> @@ -0,0 +1,122 @@
>>>>>> +/** @file
>>>>>> + SMC helper functions.
>>>>>> +
>>>>>> + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
>>>>>> +
>>>>>> + SPDX-License-Identifier: BSD-2-Clause-Patent
>>>>>> +
>>>>>> +**/
>>>>>> +
>>>>>> +#include <Library/ArmSmcLib.h>
>>>>>> +
>>>>>> +/** Triggers an SMC call with 3 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Argument/result.
>>>>>> + @param Arg3 Argument/result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc3 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + IN OUT UINTN *Arg2,
>>>>>> + IN OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + ARM_SMC_ARGS Args;
>>>>>> + UINTN ErrorCode;
>>>>>> +
>>>>>> + Args.Arg0 = Function;
>>>>>> +
>>>>>> + if (Arg1 != NULL) {
>>>>>> + Args.Arg1 = *Arg1;
>>>>>> + }
>>>>>> + if (Arg2 != NULL) {
>>>>>> + Args.Arg2 = *Arg2;
>>>>>> + }
>>>>>> + if (Arg3 != NULL) {
>>>>>> + Args.Arg3 = *Arg3;
>>>>>> + }
>>>>>> +
>>>>>> + ArmCallSmc (&Args);
>>>>>> +
>>>>>> + ErrorCode = Args.Arg0;
>>>>>> +
>>>>>> + if (Arg1 != NULL) {
>>>>>> + *Arg1 = Args.Arg1;
>>>>>> + }
>>>>>> + if (Arg2 != NULL) {
>>>>>> + *Arg2 = Args.Arg2;
>>>>>> + }
>>>>>> + if (Arg3 != NULL) {
>>>>>> + *Arg3 = Args.Arg3;
>>>>>> + }
>>>>>> +
>>>>>> + return ErrorCode;
>>>>>> +}
>>>>>> +
>>>>>> +/** Trigger an SMC call with 2 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Argument/result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc2 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + IN OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
>>>>>> +}
>>>>>> +
>>>>>> +/** Trigger an SMC call with 1 argument.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc1 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
>>>>>> +}
>>>>>> +
>>>>>> +/** Trigger an SMC call with 0 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Result.
>>>>>> + @param Arg2 Result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc0 (
>>>>>> + IN UINTN Function,
>>>>>> + OUT UINTN *Arg1,
>>>>>> + OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
>>>>>> +}
>>>>>> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
>>>>>> index 4f4b09f4528a..a89f9203fb7e 100644
>>>>>> --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
>>>>>> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
>>>>>> @@ -20,6 +20,9 @@
>>>>>> [Sources.AARCH64]
>>>>>> AArch64/ArmSmc.S
>>>>>> +[Sources]
>>>>>> + ArmSmc.c
>>>>>> +
>>>>>> [Packages]
>>>>>> MdePkg/MdePkg.dec
>>>>>> ArmPkg/ArmPkg.dec
>>>>>> diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
>>>>>> index 2d79aadaf1fa..ca1b8830a119 100644
>>>>>> --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
>>>>>> +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
>>>>>> @@ -1,4 +1,5 @@
>>>>>> //
>>>>>> +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
>>>>>> // Copyright (c) 2016, Linaro Limited. All rights reserved.
>>>>>> //
>>>>>> // SPDX-License-Identifier: BSD-2-Clause-Patent
>>>>>> @@ -7,6 +8,7 @@
>>>>>> #include <Base.h>
>>>>>> #include <Library/ArmSmcLib.h>
>>>>>> +#include <IndustryStandard/ArmStdSmc.h>
>>>>>> VOID
>>>>>> ArmCallSmc (
>>>>>> @@ -14,3 +16,86 @@ ArmCallSmc (
>>>>>> )
>>>>>> {
>>>>>> }
>>>>>> +
>>>>>> +/** Triggers an SMC call with 3 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Argument/result.
>>>>>> + @param Arg3 Argument/result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc3 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + IN OUT UINTN *Arg2,
>>>>>> + IN OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>>>> +}
>>>>>> +
>>>>>> +/** Trigger an SMC call with 2 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Argument/result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc2 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + IN OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>>>> +}
>>>>>> +
>>>>>> +/** Trigger an SMC call with 1 argument.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Argument/result.
>>>>>> + @param Arg2 Result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc1 (
>>>>>> + IN UINTN Function,
>>>>>> + IN OUT UINTN *Arg1,
>>>>>> + OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>>>> +}
>>>>>> +
>>>>>> +/** Trigger an SMC call with 0 arguments.
>>>>>> +
>>>>>> + @param Function The SMC function.
>>>>>> + @param Arg1 Result.
>>>>>> + @param Arg2 Result.
>>>>>> + @param Arg3 Result.
>>>>>> +
>>>>>> + @return The SMC error code.
>>>>>> +
>>>>>> +**/
>>>>>> +UINTN
>>>>>> +ArmCallSmc0 (
>>>>>> + IN UINTN Function,
>>>>>> + OUT UINTN *Arg1,
>>>>>> + OUT UINTN *Arg2,
>>>>>> + OUT UINTN *Arg3
>>>>>> + )
>>>>>> +{
>>>>>> + return SMC_ARCH_CALL_NOT_SUPPORTED;
>>>>>> +}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions
2021-11-01 22:11 ` [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions Rebecca Cran
@ 2021-12-13 12:26 ` Sami Mujawar
0 siblings, 0 replies; 11+ messages in thread
From: Sami Mujawar @ 2021-12-13 12:26 UTC (permalink / raw)
To: Rebecca Cran, devel, Ard Biesheuvel, Gerd Hoffmann,
Samer El-Haj-Mahmoud, Leif Lindholm, nd
Hi Rebecca,
Thank you for this patch.
I believe the patch subject line needs to be updated to "...
ArmCallSmc0/1/2/3 ...". Other than that, this patch looks good to me.
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Regards,
Sami Mujawar
On 01/11/2021 10:11 PM, Rebecca Cran wrote:
> New SMC helper functions have been added to reduce the amount of
> template code. Update ArmSmcPsciResetSystemLib and
> Smbios/ProcessorSubClassDxe to use them.
>
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> ---
> ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c | 10 ++-----
> ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c | 31 ++++++++------------
> 2 files changed, 14 insertions(+), 27 deletions(-)
>
> diff --git a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
> index 8b5ff5c27e44..319f05c9f1e2 100644
> --- a/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
> +++ b/ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.c
> @@ -31,11 +31,8 @@ ResetCold (
> VOID
> )
> {
> - ARM_SMC_ARGS ArmSmcArgs;
> -
> // Send a PSCI 0.2 SYSTEM_RESET command
> - ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
> - ArmCallSmc (&ArmSmcArgs);
> + ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_RESET, NULL, NULL, NULL);
> }
>
> /**
> @@ -66,11 +63,8 @@ ResetShutdown (
> VOID
> )
> {
> - ARM_SMC_ARGS ArmSmcArgs;
> -
> // Send a PSCI 0.2 SYSTEM_OFF command
> - ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
> - ArmCallSmc (&ArmSmcArgs);
> + ArmCallSmc0 (ARM_SMC_ID_PSCI_SYSTEM_OFF, NULL, NULL, NULL);
> }
>
> /**
> diff --git a/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c b/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
> index d644cd33d249..c6d41e3984f8 100644
> --- a/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
> +++ b/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
> @@ -88,22 +88,19 @@ HasSmcArm64SocId (
> VOID
> )
> {
> - ARM_SMC_ARGS Args;
> INT32 SmcCallStatus;
> BOOLEAN Arm64SocIdSupported;
> + UINTN SmcParam;
>
> Arm64SocIdSupported = FALSE;
>
> - Args.Arg0 = SMCCC_VERSION;
> - ArmCallSmc (&Args);
> - SmcCallStatus = (INT32)Args.Arg0;
> + SmcCallStatus = ArmCallSmc0 (SMCCC_VERSION, NULL, NULL, NULL);
>
> if (SmcCallStatus < 0 || (SmcCallStatus >> 16) >= 1) {
> - Args.Arg0 = SMCCC_ARCH_FEATURES;
> - Args.Arg1 = SMCCC_ARCH_SOC_ID;
> - ArmCallSmc (&Args);
> + SmcParam = SMCCC_ARCH_SOC_ID;
> + SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_FEATURES, &SmcParam, NULL, NULL);
>
> - if (Args.Arg0 >= 0) {
> + if (SmcCallStatus >= 0) {
> Arm64SocIdSupported = TRUE;
> }
> }
> @@ -125,30 +122,26 @@ SmbiosGetSmcArm64SocId (
> OUT INT32 *SocRevision
> )
> {
> - ARM_SMC_ARGS Args;
> INT32 SmcCallStatus;
> EFI_STATUS Status;
> + UINTN SmcParam;
>
> Status = EFI_SUCCESS;
>
> - Args.Arg0 = SMCCC_ARCH_SOC_ID;
> - Args.Arg1 = 0;
> - ArmCallSmc (&Args);
> - SmcCallStatus = (INT32)Args.Arg0;
> + SmcParam = 0;
> + SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
>
> if (SmcCallStatus >= 0) {
> - *Jep106Code = (INT32)Args.Arg0;
> + *Jep106Code = (INT32)SmcParam;
> } else {
> Status = EFI_UNSUPPORTED;
> }
>
> - Args.Arg0 = SMCCC_ARCH_SOC_ID;
> - Args.Arg1 = 1;
> - ArmCallSmc (&Args);
> - SmcCallStatus = (INT32)Args.Arg0;
> + SmcParam = 1;
> + SmcCallStatus = ArmCallSmc1 (SMCCC_ARCH_SOC_ID, &SmcParam, NULL, NULL);
>
> if (SmcCallStatus >= 0) {
> - *SocRevision = (INT32)Args.Arg0;
> + *SocRevision = (INT32)SmcParam;
> } else {
> Status = EFI_UNSUPPORTED;
> }
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/2] ArmPkg: Add SMC helper functions
2021-11-01 22:11 ` [PATCH v2 1/2] " Rebecca Cran
2021-11-09 1:56 ` Rebecca Cran
@ 2021-12-13 12:31 ` Sami Mujawar
1 sibling, 0 replies; 11+ messages in thread
From: Sami Mujawar @ 2021-12-13 12:31 UTC (permalink / raw)
To: Rebecca Cran, devel, Ard Biesheuvel, Gerd Hoffmann,
Samer El-Haj-Mahmoud, Leif Lindholm, nd
Hi Rebecca,
Thank you for this patch series.
The patch series does not apply on top of latest master, which I believe
is due to the Uncrustify changes.
I have some minor suggestions marked inline as [SAMI].
Otherwise this patch looks good to me.
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Regards,
Sami Mujawar
On 01/11/2021 10:11 PM, Rebecca Cran wrote:
> Add functions ArmCallSmc0/1/2/3 to do SMC calls with 0, 1, 2 or 3
> arguments.
> The functions return up to 3 values.
>
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> ---
> ArmPkg/Include/Library/ArmSmcLib.h | 73 ++++++++++++
> ArmPkg/Library/ArmSmcLib/ArmSmc.c | 122 ++++++++++++++++++++
> ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf | 3 +
> ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c | 85 ++++++++++++++
> 4 files changed, 283 insertions(+)
>
> diff --git a/ArmPkg/Include/Library/ArmSmcLib.h b/ArmPkg/Include/Library/ArmSmcLib.h
> index ced60b3c1147..343ae7f40ad2 100644
> --- a/ArmPkg/Include/Library/ArmSmcLib.h
> +++ b/ArmPkg/Include/Library/ArmSmcLib.h
> @@ -1,5 +1,6 @@
> /** @file
> *
> +* Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> * Copyright (c) 2012-2014, ARM Limited. All rights reserved.
> *
> * SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -37,4 +38,76 @@ ArmCallSmc (
> IN OUT ARM_SMC_ARGS *Args
> );
>
> +/** Trigger an SMC call with 3 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Argument/result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc3 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + IN OUT UINTN *Arg3
> + );
> +
> +/** Trigger an SMC call with 2 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc2 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + );
> +
> +/** Trigger an SMC call with 1 argument.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc1 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + );
> +
> +/** Trigger an SMC call with 0 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc0 (
> + IN UINTN Function,
> + OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + );
> +
> #endif // ARM_SMC_LIB_H_
> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmc.c b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> new file mode 100644
> index 000000000000..d596003a857e
> --- /dev/null
> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmc.c
> @@ -0,0 +1,122 @@
> +/** @file
> + SMC helper functions.
> +
> + Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/ArmSmcLib.h>
> +
> +/** Triggers an SMC call with 3 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
[SAMI] It may be good to document that these parameters are optional. I
believe the OPTIONAL tag can be used in the function prototype as well.
Similar comment for other functions as well.
> + @param Arg2 Argument/result.
> + @param Arg3 Argument/result.
> +
> + @return The SMC error code.
> +**/
> +UINTN
> +ArmCallSmc3 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + IN OUT UINTN *Arg3
> + )
> +{
> + ARM_SMC_ARGS Args;
> + UINTN ErrorCode;
> +
> + Args.Arg0 = Function;
[SAMI] I think it would be good to zero initialise Args before use.
> +
> + if (Arg1 != NULL) {
> + Args.Arg1 = *Arg1;
> + }
> + if (Arg2 != NULL) {
> + Args.Arg2 = *Arg2;
> + }
> + if (Arg3 != NULL) {
> + Args.Arg3 = *Arg3;
> + }
> +
> + ArmCallSmc (&Args);
> +
> + ErrorCode = Args.Arg0;
> +
> + if (Arg1 != NULL) {
> + *Arg1 = Args.Arg1;
> + }
> + if (Arg2 != NULL) {
> + *Arg2 = Args.Arg2;
> + }
> + if (Arg3 != NULL) {
> + *Arg3 = Args.Arg3;
> + }
> +
> + return ErrorCode;
> +}
> +
> +/** Trigger an SMC call with 2 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc2 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> +}
> +
> +/** Trigger an SMC call with 1 argument.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc1 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> +}
> +
> +/** Trigger an SMC call with 0 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc0 (
> + IN UINTN Function,
> + OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return ArmCallSmc3 (Function, Arg1, Arg2, Arg3);
> +}
> diff --git a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> index 4f4b09f4528a..a89f9203fb7e 100644
> --- a/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> +++ b/ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
> @@ -20,6 +20,9 @@
> [Sources.AARCH64]
> AArch64/ArmSmc.S
>
> +[Sources]
> + ArmSmc.c
> +
> [Packages]
> MdePkg/MdePkg.dec
> ArmPkg/ArmPkg.dec
> diff --git a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> index 2d79aadaf1fa..ca1b8830a119 100644
> --- a/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> +++ b/ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.c
> @@ -1,4 +1,5 @@
> //
> +// Copyright (c) 2021, NUVIA Inc. All rights reserved.
> // Copyright (c) 2016, Linaro Limited. All rights reserved.
> //
> // SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -7,6 +8,7 @@
>
> #include <Base.h>
> #include <Library/ArmSmcLib.h>
> +#include <IndustryStandard/ArmStdSmc.h>
>
> VOID
> ArmCallSmc (
> @@ -14,3 +16,86 @@ ArmCallSmc (
> )
> {
> }
> +
> +/** Triggers an SMC call with 3 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Argument/result.
> +
> + @return The SMC error code.
> +**/
> +UINTN
> +ArmCallSmc3 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + IN OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
> +
> +/** Trigger an SMC call with 2 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Argument/result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc2 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + IN OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
> +
> +/** Trigger an SMC call with 1 argument.
> +
> + @param Function The SMC function.
> + @param Arg1 Argument/result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc1 (
> + IN UINTN Function,
> + IN OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
> +
> +/** Trigger an SMC call with 0 arguments.
> +
> + @param Function The SMC function.
> + @param Arg1 Result.
> + @param Arg2 Result.
> + @param Arg3 Result.
> +
> + @return The SMC error code.
> +
> +**/
> +UINTN
> +ArmCallSmc0 (
> + IN UINTN Function,
> + OUT UINTN *Arg1,
> + OUT UINTN *Arg2,
> + OUT UINTN *Arg3
> + )
> +{
> + return SMC_ARCH_CALL_NOT_SUPPORTED;
> +}
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-12-13 12:31 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-01 22:11 [PATCH v2 0/2] ArmPkg: Add SMC helper functions Rebecca Cran
2021-11-01 22:11 ` [PATCH v2 1/2] " Rebecca Cran
2021-11-09 1:56 ` Rebecca Cran
2021-11-09 11:57 ` Leif Lindholm
2021-11-09 12:15 ` Ard Biesheuvel
2021-12-09 22:54 ` Rebecca Cran
2021-12-13 11:49 ` Ard Biesheuvel
2021-12-13 12:26 ` Sami Mujawar
2021-12-13 12:31 ` Sami Mujawar
2021-11-01 22:11 ` [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions Rebecca Cran
2021-12-13 12:26 ` Sami Mujawar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox