[edk2-devel] [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions

Rebecca Cran posted 2 patches 4 years, 3 months ago
There is a newer version of this series
[edk2-devel] [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions
Posted by Rebecca Cran 4 years, 3 months ago
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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83064): https://edk2.groups.io/g/devel/message/83064
Mute This Topic: https://groups.io/mt/86753698/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 2/2] ArmPkg: Update SMC calls to use the new ArmCallSmc1/2/3/4 functions
Posted by Sami Mujawar 4 years, 1 month ago
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.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84704): https://edk2.groups.io/g/devel/message/84704
Mute This Topic: https://groups.io/mt/86753698/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-