From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from muminek.juszkiewicz.com.pl (muminek.juszkiewicz.com.pl [213.251.184.221]) by mx.groups.io with SMTP id smtpd.web11.501.1683819869628272849 for ; Thu, 11 May 2023 08:44:29 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=softfail (domain: linaro.org, ip: 213.251.184.221, mailfrom: marcin.juszkiewicz@linaro.org) Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id 346C926066D; Thu, 11 May 2023 17:44:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at juszkiewicz.com.pl Received: from muminek.juszkiewicz.com.pl ([127.0.0.1]) by localhost (muminek.juszkiewicz.com.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f11d3wETcHln; Thu, 11 May 2023 17:44:26 +0200 (CEST) Received: from applejack.lan (83.11.34.59.ipv4.supernova.orange.pl [83.11.34.59]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id CA37526007F; Thu, 11 May 2023 17:44:25 +0200 (CEST) From: "Marcin Juszkiewicz" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Rebecca Cran , Sami Mujawar , Marcin Juszkiewicz Subject: [PATCH v5 1/2] Platform/SbsaQemu: read platform version Date: Thu, 11 May 2023 17:44:23 +0200 Message-Id: <20230511154423.321013-1-marcin.juszkiewicz@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <175E2102FF399ADF.29341@groups.io> References: <175E2102FF399ADF.29341@groups.io> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- Platform/Qemu/SbsaQemu/SbsaQemu.dsc | 3 +++ .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 27 +++++++++++++++++++ .../SbsaQemuPlatformDxe.inf | 5 ++++ Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 +++ 4 files changed, 38 insertions(+) diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc b/Platform/Qemu/SbsaQemu= /SbsaQemu.dsc index 9ca030cfe9a7..43798e03d33c 100644 --- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc +++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc @@ -558,6 +558,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE =3D FALSE gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT0000" gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK0000" =20 + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0 + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0 + ########################################################################= ######## # # Components Section - list of all EDK II Modules needed by this Platfor= m diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPl= atformDxe.c b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuP= latformDxe.c index b7270a07abbd..199766c7014a 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformD= xe.c +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformD= xe.c @@ -7,15 +7,25 @@ * **/ =20 +#include #include #include #include #include #include #include +#include =20 #include =20 +/* those probably should go into IndustryStandard/ArmStdSmc.h */ +#define SMC_FASTCALL 0x80000000 +#define SMC64_FUNCTION (SMC_FASTCALL | 0x40000000) +#define SIP_FUNCTION (SMC64_FUNCTION | 0x02000000) +#define SIP_FUNCTION_ID(n) (SIP_FUNCTION | (n)) + +#define SIP_SVC_VERSION SIP_FUNCTION_ID(1) + EFI_STATUS EFIAPI InitializeSbsaQemuPlatformDxe ( @@ -26,6 +36,9 @@ InitializeSbsaQemuPlatformDxe ( EFI_STATUS Status; UINTN Size; VOID* Base; + UINTN Arg0; + UINTN Arg1; + UINTN Result; =20 DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FU= NCTION__)); =20 @@ -51,5 +64,19 @@ InitializeSbsaQemuPlatformDxe ( return Status; } =20 + Result =3D ArmCallSmc0 (SIP_SVC_VERSION, &Arg0, &Arg1, NULL); + if (Result =3D=3D SMC_ARCH_CALL_SUCCESS) + { + Result =3D PcdSet32S (PcdPlatformVersionMajor, Arg0); + ASSERT_EFI_ERROR (Result); + Result =3D PcdSet32S (PcdPlatformVersionMinor, Arg1); + ASSERT_EFI_ERROR (Result); + } + + Arg0 =3D PcdGet32 (PcdPlatformVersionMajor); + Arg1 =3D PcdGet32 (PcdPlatformVersionMinor); + + DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1)); + return EFI_SUCCESS; } diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPl= atformDxe.inf b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQem= uPlatformDxe.inf index 21d2135f6d17..1f2c8a9dd6af 100644 --- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformD= xe.inf +++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformD= xe.inf @@ -20,6 +20,7 @@ SbsaQemuPlatformDxe.c =20 [Packages] + ArmPkg/ArmPkg.dec ArmVirtPkg/ArmVirtPkg.dec EmbeddedPkg/EmbeddedPkg.dec MdeModulePkg/MdeModulePkg.dec @@ -27,6 +28,7 @@ Silicon/Qemu/SbsaQemu/SbsaQemu.dec =20 [LibraryClasses] + ArmSmcLib PcdLib DebugLib NonDiscoverableDeviceRegistrationLib @@ -36,6 +38,9 @@ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize =20 + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor + [Depex] TRUE =20 diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec b/Silicon/Qemu/SbsaQemu/S= bsaQemu.dec index 9448852967b6..5182978cf56d 100644 --- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec +++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec @@ -67,3 +67,6 @@ gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID= *|0x0000011B gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x= 0000011C gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x00000= 11D + + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UIN= T32|0x0000011E + gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UIN= T32|0x0000011F --=20 2.40.1