From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: Rebecca Cran <rebecca@nuviainc.com>, devel@edk2.groups.io
Cc: Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Zhiguang Liu <zhiguang.liu@intel.com>,
Leif Lindholm <leif@nuviainc.com>,
Sami Mujawar <Sami.Mujawar@arm.com>
Subject: Re: [PATCH v4 09/11] ArmPkg: Add FirmwareVersionInfoPeim
Date: Wed, 2 Dec 2020 16:20:37 +0100 [thread overview]
Message-ID: <0a794787-7db6-f13c-3bc0-7abe906427bd@arm.com> (raw)
In-Reply-To: <20201201003358.8780-10-rebecca@nuviainc.com>
On 12/1/20 1:33 AM, Rebecca Cran wrote:
> Add the FirmwareVersionInfoPeim driver, which provides the firmware
> release date to the SMBIOS code.
>
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Hi Rebecca,
Is there any pressing need for this to execute in the PEI phase? These
are all compile time constants, which can easily be exposed the the
SMBIOS driver running in DXE in a different way, no?
> ---
> ArmPkg/ArmPkg.dec | 3 +
> ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.inf | 47 ++++++++++
> ArmPkg/Include/Guid/FirmwareVersionInfoHobGuid.h | 29 +++++++
> ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.c | 91 ++++++++++++++++++++
> 4 files changed, 170 insertions(+)
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> index eaf1072d9ef3..840f6c7c34e1 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -45,6 +45,9 @@ [Guids.common]
> # Include/Guid/ArmMpCoreInfo.h
> gArmMpCoreInfoGuid = { 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 0xe8, 0x34} }
>
> + gFirmwareInfoHobGuid = { 0x78ba5a73, 0x04d0, 0x4adf, {0xb6, 0x14, 0x04, 0xa6, 0xa3, 0xd8, 0xa2, 0x57} }
> +
> +
> [Protocols.common]
> ## Arm System Control and Management Interface(SCMI) Base protocol
> ## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
> diff --git a/ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.inf b/ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.inf
> new file mode 100644
> index 000000000000..5b61fcfa2ebf
> --- /dev/null
> +++ b/ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.inf
> @@ -0,0 +1,47 @@
> +#/** @file
> +#
> +# Copyright (c) 2020, NUVIA Inc. All rights reserved.
> +# Copyright (c) 2016, Hisilicon Limited. All rights reserved.
> +# Copyright (c) 2016, Linaro Limited. All rights reserved.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#**/
> +
> +[Defines]
> + INF_VERSION = 1.29
> + BASE_NAME = FirmwareVersionInfoPeim
> + FILE_GUID = 3d45d0a0-4ded-4c01-b16f-2b3007c1fbe2
> + MODULE_TYPE = PEIM
> + VERSION_STRING = 1.0
> + ENTRY_POINT = FirmwareVersionInfoEntry
> +
> +[Sources.common]
> + FirmwareVersionInfoPeim.c
> +
> +[Packages]
> + ArmPkg/ArmPkg.dec
> + MdeModulePkg/MdeModulePkg.dec
> + MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> + BaseLib
> + BaseMemoryLib
> + DebugLib
> + HobLib
> + PcdLib
> + PeimEntryPoint
> + PrintLib
> + SerialPortLib
> +
> +[Pcd]
> + gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
> +
> +[Guids]
> + gFirmwareVersionInfoHobGuid
> +
> +[Depex]
> + TRUE
> +
> +[BuildOptions]
> +
> diff --git a/ArmPkg/Include/Guid/FirmwareVersionInfoHobGuid.h b/ArmPkg/Include/Guid/FirmwareVersionInfoHobGuid.h
> new file mode 100644
> index 000000000000..af4fa6fec823
> --- /dev/null
> +++ b/ArmPkg/Include/Guid/FirmwareVersionInfoHobGuid.h
> @@ -0,0 +1,29 @@
> +/** @file
> +*
> +* Copyright (c) 2020, NUVIA Inc. All rights reserved.
> +* Copyright (c) 2016, Hisilicon Limited. All rights reserved.
> +* Copyright (c) 2016, Linaro Limited. All rights reserved.
> +*
> +* SPDX-License-Identifier: BSD-2-Clause-Patent
> +*
> +**/
> +
> +#ifndef FIRMWARE_VERSION_INFO_HOB_GUID_H_
> +#define FIRMWARE_VERSION_INFO_HOB_GUID_H_
> +
> +// {78ba5a73-04d0-4adf-b614-04a6a3d8a257}
> +#define FIRMWARE_VERSION_INFO_HOB_GUID \
> + {0x78ba5a73, 0x04d0, 0x4adf, {0xb6, 0x14, 0x04, 0xa6, 0xa3, 0xd8, 0xa2, 0x57}}
> +
> +extern GUID gFirmwareVersionInfoHobGuid;
> +
> +#pragma pack(1)
> +
> +typedef struct {
> + EFI_TIME BuildTime;
> + CHAR16 String[1];
> +} FIRMWARE_VERSION_INFO;
> +
> +#pragma pack()
> +
> +#endif /* FIRMWARE_VERSION_INFO_HOB_GUID_H_ */
> diff --git a/ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.c b/ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.c
> new file mode 100644
> index 000000000000..48dcf4602a95
> --- /dev/null
> +++ b/ArmPkg/Drivers/FirmwareVersionInfoPeim/FirmwareVersionInfoPeim.c
> @@ -0,0 +1,91 @@
> +/** @file
> +*
> +* Copyright (c) 2020, NUVIA Inc. All rights reserved.
> +* Copyright (c) 2016, Hisilicon Limited. All rights reserved.
> +* Copyright (c) 2016, Linaro Limited. All rights reserved.
> +*
> +* SPDX-License-Identifier: BSD-2-Clause-Patent
> +*
> +**/
> +
> +#include <Uefi.h>
> +#include <PiPei.h>
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PrintLib.h>
> +#include <Library/SerialPortLib.h>
> +
> +#include <Guid/FirmwareVersionInfoHobGuid.h>
> +
> +struct MonthDescription {
> + CONST CHAR8* MonthStr;
> + UINT32 MonthInt;
> +} mMonthDescription[] = {
> + { "Jan", 1 },
> + { "Feb", 2 },
> + { "Mar", 3 },
> + { "Apr", 4 },
> + { "May", 5 },
> + { "Jun", 6 },
> + { "Jul", 7 },
> + { "Aug", 8 },
> + { "Sep", 9 },
> + { "Oct", 10 },
> + { "Nov", 11 },
> + { "Dec", 12 },
> + { "???", 1 }, // Use 1 as default month
> +};
> +
> +VOID GetReleaseTime (EFI_TIME *Time)
> +{
> + CONST CHAR8 *ReleaseDate = __DATE__;
> + CONST CHAR8 *ReleaseTime = __TIME__;
> + UINTN i;
> +
> + for (i = 0;i < 12;i++) {
> + if (AsciiStrnCmp (ReleaseDate, mMonthDescription[i].MonthStr, 3) == 0) {
> + break;
> + }
> + }
> +
> + Time->Month = mMonthDescription[i].MonthInt;
> + Time->Day = AsciiStrDecimalToUintn (ReleaseDate + 4);
> + Time->Year = AsciiStrDecimalToUintn (ReleaseDate + 7);
> + Time->Hour = AsciiStrDecimalToUintn (ReleaseTime);
> + Time->Minute = AsciiStrDecimalToUintn (ReleaseTime + 3);
> + Time->Second = AsciiStrDecimalToUintn (ReleaseTime + 6);
> +
> + return;
> +}
> +
> +EFI_STATUS
> +EFIAPI
> +FirmwareVersionInfoEntry (
> + IN EFI_PEI_FILE_HANDLE FileHandle,
> + IN CONST EFI_PEI_SERVICES **PeiServices
> + )
> +{
> + FIRMWARE_VERSION_INFO *VersionInfo;
> + EFI_TIME Time = {0};
> + CONST CHAR16 *ReleaseString =
> + (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
> +
> + GetReleaseTime (&Time);
> +
> + VersionInfo = BuildGuidHob (&gFirmwareVersionInfoHobGuid,
> + sizeof (FIRMWARE_VERSION_INFO) -
> + sizeof (VersionInfo->String) +
> + StrSize (ReleaseString));
> + if (VersionInfo == NULL) {
> + DEBUG ((DEBUG_ERROR, "[%a]:[%d] Build HOB failed!\n", __FILE__, __LINE__));
> + return EFI_OUT_OF_RESOURCES;
> + }
> +
> + CopyMem (&VersionInfo->BuildTime, &Time, sizeof (EFI_TIME));
> + CopyMem (VersionInfo->String, ReleaseString, StrSize (ReleaseString));
> +
> + return EFI_SUCCESS;
> +}
>
next prev parent reply other threads:[~2020-12-02 15:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 0:33 [PATCH v4 00/11] ArmPkg,MdePkg: Add Universal/Smbios and Drivers/FirmwareVersionInfoPeim Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 01/11] ArmPkg: Add ARM SMC Architecture functions to ArmStdSmc.h Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 02/11] MdePkg: Update IndustryStandard/SmBios.h with processor status data Rebecca Cran
2020-12-01 0:39 ` 回复: " gaoliming
2020-12-01 0:33 ` [PATCH v4 03/11] ArmPkg: Add register encoding definition for MMFR2 Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 04/11] ArmPkg: Add helper to read the Memory Model Features Register 2 Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 05/11] ArmPkg: Add helper function to read the Memory Model Feature Register 4 Rebecca Cran
2020-12-16 11:06 ` Sami Mujawar
2020-12-01 0:33 ` [PATCH v4 06/11] ArmPkg: Add helper to read CCIDX status Rebecca Cran
2020-12-16 11:06 ` Sami Mujawar
2020-12-01 0:33 ` [PATCH v4 07/11] ArmPkg: Fix the return type of the ReadCCSIDR function Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 08/11] ArmPkg: Update ArmLibPrivate.h with cache register definitions Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 09/11] ArmPkg: Add FirmwareVersionInfoPeim Rebecca Cran
2020-12-02 15:20 ` Ard Biesheuvel [this message]
2020-12-02 15:31 ` Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 10/11] ArmPkg: Add Universal/Smbios, a generic SMBIOS library for ARM Rebecca Cran
2020-12-01 0:33 ` [PATCH v4 11/11] ArmPkg: Add definition of the maximum cache level in ARMv8-A Rebecca Cran
2020-12-01 21:26 ` [PATCH v4 00/11] ArmPkg,MdePkg: Add Universal/Smbios and Drivers/FirmwareVersionInfoPeim Rebecca Cran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0a794787-7db6-f13c-3bc0-7abe906427bd@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox