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>
---
Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++
Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++
.../SbsaQemuPlatformDxe.inf | 4 ++++
.../Include/IndustryStandard/SbsaQemuSmc.h | 11 +++++++++++
.../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 19 +++++++++++++++++++
5 files changed, 40 insertions(+)
create mode 100644 Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 9448852967b6..5182978cf56d 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -67,3 +67,6 @@ [PcdsDynamic.common]
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
diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index 0bd0df4f0239..b88729ad8ad6 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -558,6 +558,9 @@ [PcdsDynamicDefault.common]
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.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..cb1826979bd6 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@ [Sources]
SbsaQemuPlatformDxe.c
[Packages]
+ ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@ [Packages]
Silicon/Qemu/SbsaQemu/SbsaQemu.dec
[LibraryClasses]
+ ArmSmcLib
PcdLib
DebugLib
NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,8 @@ [Pcd]
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
[Depex]
TRUE
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
new file mode 100644
index 000000000000..5a179f69b629
--- /dev/null
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuSmc.h
@@ -0,0 +1,11 @@
+/** @file
+*
+* Copyright (c) 2023, Linaro Ltd. All rights reserved.
+*
+* SPDX-License-Identifier: BSD-2-Clause-Patent
+*
+**/
+
+#include <IndustryStandard/ArmStdSmc.h>
+
+#define SIP_SVC_VERSION SMC_SIP_FUNCTION_ID(1)
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..515d18564bd0 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/SbsaQemuSmc.h>
#include <Protocol/FdtClient.h>
@@ -26,6 +28,10 @@ InitializeSbsaQemuPlatformDxe (
EFI_STATUS Status;
UINTN Size;
VOID* Base;
+ UINTN Arg0;
+ UINTN Arg1;
+ UINTN SmcResult;
+ RETURN_STATUS Result;
DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FUNCTION__));
@@ -51,5 +57,18 @@ InitializeSbsaQemuPlatformDxe (
return Status;
}
+ SmcResult = ArmCallSmc0 (SIP_SVC_VERSION, &Arg0, &Arg1, NULL);
+ if (SmcResult == SMC_ARCH_CALL_SUCCESS)
+ {
+ Result = PcdSet32S (PcdPlatformVersionMajor, Arg0);
+ ASSERT_RETURN_ERROR (Result);
+ Result = PcdSet32S (PcdPlatformVersionMinor, Arg1);
+ ASSERT_RETURN_ERROR (Result);
+ }
+
+ Arg0 = PcdGet32 (PcdPlatformVersionMajor);
+ Arg1 = PcdGet32 (PcdPlatformVersionMinor);
+
+ DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
return EFI_SUCCESS;
}
--
2.40.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105771): https://edk2.groups.io/g/devel/message/105771
Mute This Topic: https://groups.io/mt/99359661/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2026 Red Hat, Inc.