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.web10.89073.1684158481276118390 for ; Mon, 15 May 2023 06:48:01 -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 7E494260BAA; Mon, 15 May 2023 15:47:58 +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 EpY29a_bhbst; Mon, 15 May 2023 15:47:56 +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 5214C260BA9; Mon, 15 May 2023 15:47:56 +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: Mon, 15 May 2023 15:47:51 +0200 Message-Id: <20230515134752.362671-2-marcin.juszkiewicz@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515134752.362671-1-marcin.juszkiewicz@linaro.org> References: <20230515134752.362671-1-marcin.juszkiewicz@linaro.org> 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 | 28 +++++++++++++++++++ .../SbsaQemuPlatformDxe.inf | 5 ++++ Silicon/Qemu/SbsaQemu/SbsaQemu.dec | 3 ++ 4 files changed, 39 insertions(+) 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 @@ 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..39f5639d0a28 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,10 @@ InitializeSbsaQemuPlatformDxe ( EFI_STATUS Status; UINTN Size; VOID* Base; + UINTN Arg0; + UINTN Arg1; + UINTN SmcResult; + RETURN_STATUS Result; =20 DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", __FU= NCTION__)); =20 @@ -51,5 +65,19 @@ InitializeSbsaQemuPlatformDxe ( return Status; } =20 + SmcResult =3D ArmCallSmc0 (SIP_SVC_VERSION, &Arg0, &Arg1, NULL); + if (SmcResult =3D=3D SMC_ARCH_CALL_SUCCESS) + { + Result =3D PcdSet32S (PcdPlatformVersionMajor, Arg0); + ASSERT_RETURN_ERROR (Result); + Result =3D PcdSet32S (PcdPlatformVersionMinor, Arg1); + ASSERT_RETURN_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