public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] Platform/SbsaQemu: read platform version
@ 2023-05-10 15:08 Marcin Juszkiewicz
  2023-05-10 15:21 ` [edk2-devel] " Ard Biesheuvel
  2023-05-10 15:26 ` Rebecca Cran
  0 siblings, 2 replies; 10+ messages in thread
From: Marcin Juszkiewicz @ 2023-05-10 15:08 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Leif Lindholm, Rebecca Cran, Sami Mujawar,
	Marcin Juszkiewicz

Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.

This change adds reading platform version into EDK2.

Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
---
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc                |  3 +++
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c      | 14 ++++++++++++++
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf    |  5 +++++
 Silicon/Qemu/SbsaQemu/SbsaQemu.dec                 |  3 +++
 4 files changed, 25 insertions(+)

diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index c9b912cc1e9e..facca3b3e272 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -561,6 +561,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE       = FALSE
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000"
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000"
 
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..7a22f067b600 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,12 +7,14 @@
 *
 **/
 
+#include <Library/ArmSmcLib.h>
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/NonDiscoverableDeviceRegistrationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/UefiDriverEntryPoint.h>
+#include <IndustryStandard/ArmStdSmc.h>
 
 #include <Protocol/FdtClient.h>
 
@@ -26,6 +28,9 @@ InitializeSbsaQemuPlatformDxe (
   EFI_STATUS                     Status;
   UINTN                          Size;
   VOID*                          Base;
+  UINTN                          Major;
+  UINTN                          Minor;
+  UINTN                          Result;
 
   DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
 
@@ -51,5 +56,14 @@ InitializeSbsaQemuPlatformDxe (
     return Status;
   }
 
+  Result = ArmCallSmc0(SIP_FUNCTION_ID(1), &Major, &Minor, NULL);
+  if (Result != 0xFFFFFF)
+  {
+        PcdSet32S (PcdPlatformVersionMajor, Major);
+        PcdSet32S (PcdPlatformVersionMinor, Minor);
+  }
+
+  DEBUG((DEBUG_ERROR, "Platform version: %d.%d\n", Major, Minor));
+
   return EFI_SUCCESS;
 }
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..1f2c8a9dd6af 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@
   SbsaQemuPlatformDxe.c
 
 [Packages]
+  ArmPkg/ArmPkg.dec
   ArmVirtPkg/ArmVirtPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@
   Silicon/Qemu/SbsaQemu/SbsaQemu.dec
 
 [LibraryClasses]
+  ArmSmcLib
   PcdLib
   DebugLib
   NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,9 @@
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
 
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
 [Depex]
   TRUE
 
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 8654cc7c858c..fb5903bfda0f 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -70,3 +70,6 @@
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x0000011B
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x0000011C
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x0000011D
+
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x0000011E
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x0000011F
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-05-10 17:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 15:08 [PATCH 1/1] Platform/SbsaQemu: read platform version Marcin Juszkiewicz
2023-05-10 15:21 ` [edk2-devel] " Ard Biesheuvel
2023-05-10 15:26 ` Rebecca Cran
2023-05-10 15:40   ` [PATCH v2 " Marcin Juszkiewicz
2023-05-10 15:49     ` Rebecca Cran
2023-05-10 16:06       ` [PATCH v3 " Marcin Juszkiewicz
2023-05-10 16:14         ` Rebecca Cran
2023-05-10 17:30           ` [PATCH v4 " Marcin Juszkiewicz
2023-05-10 17:32           ` [PATCH v3 " Marcin Juszkiewicz
     [not found]   ` <175DD274B9968CD4.32438@groups.io>
2023-05-10 15:42     ` [edk2-devel] [PATCH v2 " Marcin Juszkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox