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

Marcin Juszkiewicz marcin.juszkiewicz at linaro.org
Tue Jun 6 09:21:25 UTC 2023


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 at linaro.org>
---
 .../SbsaQemuPlatformDxe.inf                    |  5 +++++
 .../Include/IndustryStandard/SbsaQemuSmc.h     |  1 +
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c  | 18 ++++++++++++++++++
 3 files changed, 24 insertions(+)

diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index cb1826979bd6..545794a8c7ff 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -40,6 +40,11 @@ [Pcd]
 
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
+
+
 [Depex]
   TRUE
 
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
index 5a179f69b629..24ae6e390abd 100644
--- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
@@ -9,3 +9,4 @@
 #include <IndustryStandard/ArmStdSmc.h>
 
 #define SIP_SVC_VERSION  SMC_SIP_FUNCTION_ID(1)
+#define SIP_SVC_GET_GIC  SMC_SIP_FUNCTION_ID(100)
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index 515d18564bd0..2c4ee54c3e6b 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -70,5 +70,23 @@ InitializeSbsaQemuPlatformDxe (
   Arg1 = PcdGet32 (PcdPlatformVersionMinor);
 
   DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
+
+  SmcResult = ArmCallSmc0 (SIP_SVC_GET_GIC, &Arg0, &Arg1, NULL);
+  if (SmcResult == SMC_ARCH_CALL_SUCCESS)
+  {
+    Result = PcdSet64S (PcdGicDistributorBase, Arg0);
+    ASSERT_RETURN_ERROR (Result);
+    Result = PcdSet64S (PcdGicRedistributorsBase, Arg1);
+    ASSERT_RETURN_ERROR (Result);
+  }
+
+  Arg0 = PcdGet64 (PcdGicDistributorBase);
+
+  DEBUG ((DEBUG_INFO, "GICD base: 0x%x\n", Arg0));
+
+  Arg0 = PcdGet64 (PcdGicRedistributorsBase);
+
+  DEBUG ((DEBUG_INFO, "GICR base: 0x%x\n", Arg0));
+
   return EFI_SUCCESS;
 }
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105770): https://edk2.groups.io/g/devel/message/105770
Mute This Topic: https://groups.io/mt/99359660/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list