[edk2-devel] [PATCH 2/2] Platform/SbsaQemu: read GIC base from TF-A

Marcin Juszkiewicz posted 2 patches 1 year, 4 months ago
There is a newer version of this series
[edk2-devel] [PATCH 2/2] Platform/SbsaQemu: read GIC base from TF-A
Posted by Marcin Juszkiewicz 1 year, 4 months ago
Qemu has versioning for sbsa-ref platform. TF-A reads data from provided
DeviceTree and provides as SMC.

This change adds reading GIC base addresses into EDK2.

Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 30 +++++++++++++++++++
 .../SbsaQemuPlatformDxe.inf                   |  4 +++
 2 files changed, 34 insertions(+)

diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index 199766c7014a..1213268519c8 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -25,6 +25,8 @@
 #define SIP_FUNCTION_ID(n) (SIP_FUNCTION   | (n))
 
 #define SIP_SVC_VERSION  SIP_FUNCTION_ID(1)
+#define SIP_SVC_GET_GICD SIP_FUNCTION_ID(2)
+#define SIP_SVC_GET_GICR SIP_FUNCTION_ID(3)
 
 EFI_STATUS
 EFIAPI
@@ -78,5 +80,33 @@ InitializeSbsaQemuPlatformDxe (
 
   DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
 
+  /* If we are on platform version 0.0 then there is no more data for us in DeviceTree */
+  if ((Arg0 == 0) & (Arg1 == 0))
+  {
+    return EFI_SUCCESS;
+  }
+
+  Result = ArmCallSmc0 (SIP_SVC_GET_GICD, &Arg0, NULL, NULL);
+  if (Result == SMC_ARCH_CALL_SUCCESS)
+  {
+        Result = PcdSet64S (PcdGicDistributorBase, Arg0);
+        ASSERT_EFI_ERROR (Result);
+  }
+
+  Arg0 = PcdGet64 (PcdGicDistributorBase);
+
+  DEBUG ((DEBUG_INFO, "GICD base: 0x%x\n", Arg0));
+
+  Result = ArmCallSmc0 (SIP_SVC_GET_GICR, &Arg0, NULL, NULL);
+  if (Result == SMC_ARCH_CALL_SUCCESS)
+  {
+        Result = PcdSet64S (PcdGicRedistributorsBase, Arg0);
+        ASSERT_EFI_ERROR (Result);
+  }
+
+  Arg0 = PcdGet64 (PcdGicRedistributorsBase);
+
+  DEBUG ((DEBUG_INFO, "GICR base: 0x%x\n", Arg0));
+
   return EFI_SUCCESS;
 }
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 1f2c8a9dd6af..545794a8c7ff 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -41,6 +41,10 @@
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
 
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
+
+
 [Depex]
   TRUE
 
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104862): https://edk2.groups.io/g/devel/message/104862
Mute This Topic: https://groups.io/mt/98900381/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 2/2] Platform/SbsaQemu: read GIC base from TF-A
Posted by Rebecca Cran 1 year, 4 months ago
On 5/15/23 04:24, Marcin Juszkiewicz wrote:

> +  /* If we are on platform version 0.0 then there is no more data for us in DeviceTree */
> +  if ((Arg0 == 0) & (Arg1 == 0))
> +  {
> +    return EFI_SUCCESS;
> +  }

Should that be "&&" instead of "&"?


-- 

Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104870): https://edk2.groups.io/g/devel/message/104870
Mute This Topic: https://groups.io/mt/98900381/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 2/2] Platform/SbsaQemu: read GIC base from TF-A
Posted by Marcin Juszkiewicz 1 year, 4 months ago
W dniu 15.05.2023 o 15:14, Rebecca Cran pisze:
> On 5/15/23 04:24, Marcin Juszkiewicz wrote:
> 
>> +  /* If we are on platform version 0.0 then there is no more data for 
>> us in DeviceTree */
>> +  if ((Arg0 == 0) & (Arg1 == 0))
>> +  {
>> +    return EFI_SUCCESS;
>> +  }
> 
> Should that be "&&" instead of "&"?

Ops, yes. Always forgetting does C has "if ( (this) and (that) )" and 
then use wrong &/&& variant.




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