From nobody Sat Feb 7 08:23:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41379+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41379+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1558919577; cv=none; d=zoho.com; s=zohoarc; b=LEBdewUSvTF7NoZ4W6fE45rR4TCKXIqvxHBya1xigVNQFvC9JZECMro078Qvad25Jn2hkfwhKDMWdmy/mRAThIICvb4OrdBooeeXlbiwcHttS/mgZilhvtLy62wMZpyA+o4fr8r4LpyambjXcyZJ2x8uv+1BFf7m1UrGTe9Q5TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1558919577; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=UucNDaJIcbIc25yHvfZ+gk5j+RnFbEIHikJHlsxRLHc=; b=clEB8ngdD+nfvYGnrzQhOi6ifBgGSz/x2FyJtP37x2MMJ2yZWK00ti17L9e+H4nsecpQqNj//StnU2Ywggw3LFFb1t3TDQXuZ3c6tqVQq5Oo9ESaDuCunxOmBnMldmpmXkLio8bEtBDUrjrOebw5iiSdFV5S0562IF5zXwHFvro= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41379+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1558919576948921.5985234496437; Sun, 26 May 2019 18:12:56 -0700 (PDT) Return-Path: X-Received: from mga03.intel.com (mga03.intel.com []) by groups.io with SMTP; Sun, 26 May 2019 18:12:56 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 May 2019 18:12:55 -0700 X-ExtLoop1: 1 X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by FMSMGA003.fm.intel.com with ESMTP; 26 May 2019 18:12:54 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Liming Gao , Michael Kubacki , Sai Chaganty , Oram, Isaac W Subject: [edk2-devel] [Patch 3/3] [edk2-platform] Platform/Intel/BoardModulePkg: Add BiosId Module. Date: Mon, 27 May 2019 09:12:41 +0800 Message-Id: <20190527011241.14916-4-eric.dong@intel.com> In-Reply-To: <20190527011241.14916-1-eric.dong@intel.com> References: <20190527011241.14916-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1558919576; bh=zkMDMRn0XaXU9iiAi57Q1omXvcdNmthW4bA0X7/PssQ=; h=Cc:Date:From:Reply-To:Subject:To; b=pZNCHu0YGbdqb1sgrfqVWRs+dnaicrH/KcKSttYdjCh/q2B+1rt5rX5yBCz4ieLL7TN 6/mP1AlwMCEK31dwA6SyHxsvVx6MptrN/9UwoAMmmEASgwiDTQ83SVpbDkfIShqXGOwRw TuYMoc+9lWtAdGV7/qUhoNIz5U5ravYTXhw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add Bios ID library used to read BIOS ID related info. This library exports APIs like below: GetBiosId GetBiosVersionDateTime Signed-off-by: Eric Dong Cc: Liming Gao Cc: Michael Kubacki Cc: Sai Chaganty Cc: Oram, Isaac W --- .../Intel/BoardModulePkg/BoardModulePkg.dec | 6 + .../BoardModulePkg/Include/Guid/BiosId.h | 59 ++++++ .../Include/Library/BiosIdLib.h | 57 ++++++ .../Library/BiosIdLib/DxeBiosIdLib.c | 175 ++++++++++++++++ .../Library/BiosIdLib/DxeBiosIdLib.inf | 42 ++++ .../Library/BiosIdLib/PeiBiosIdLib.c | 191 ++++++++++++++++++ .../Library/BiosIdLib/PeiBiosIdLib.inf | 42 ++++ 7 files changed, 572 insertions(+) create mode 100644 Platform/Intel/BoardModulePkg/Include/Guid/BiosId.h create mode 100644 Platform/Intel/BoardModulePkg/Include/Library/BiosIdLib= .h create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBios= IdLib.c create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBios= IdLib.inf create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBios= IdLib.c create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBios= IdLib.inf diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec b/Platform/In= tel/BoardModulePkg/BoardModulePkg.dec index 6b41d65aee..50a783d418 100644 --- a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec +++ b/Platform/Intel/BoardModulePkg/BoardModulePkg.dec @@ -30,3 +30,9 @@ ## @libraryclass Provide platform relevant services to access CMOS a= rea. PlatformCmosAccessLib|Include/Library/PlatformCmosAccessLib.h =20 + ## @libraryclass Provide services to get BIOS ID information. + BiosIdLib|Include/Library/BiosIdLib.h + +[Guids] + ## Include Include/Guid/BiosId.h + gBiosIdGuid =3D { 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, = 0x8F, 0xE3, 0x3E, 0x28 } } \ No newline at end of file diff --git a/Platform/Intel/BoardModulePkg/Include/Guid/BiosId.h b/Platform= /Intel/BoardModulePkg/Include/Guid/BiosId.h new file mode 100644 index 0000000000..8dd416576d --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Include/Guid/BiosId.h @@ -0,0 +1,59 @@ +/** @file + GUID and definitions for BIOS ID. + +Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _BIOS_ID_GUID_H_ +#define _BIOS_ID_GUID_H_ + +#include + +#define BIOS_ID_GUID \ + { \ + 0xC3E36D09, 0x8294, 0x4b97, { 0xA8, 0x57, 0xD5, 0x28, 0x8F, 0xE3, 0x3E= , 0x28 } \ + } + +extern EFI_GUID gBiosIdGuid; + +// +// $(BOARD_ID)$(BOARD_REV).$(BOARD_EXT).$(VERSION_MAJOR).$(BUILD_TYPE)$(VE= RSION_MINOR).YYMMDDHHMM +// +// Example: "TRFTCRB1.000.0008.D03.1501301017" +// +#pragma pack(1) + +typedef struct { + CHAR16 BoardId[7]; // "TRFTCRB" + CHAR16 BoardRev; // "1" + CHAR16 Dot1; // "." + CHAR16 BoardExt[3]; // "000" + CHAR16 Dot2; // "." + CHAR16 VersionMajor[4]; // "0008" + CHAR16 Dot3; // "." + CHAR16 BuildType; // "D" + CHAR16 VersionMinor[2]; // "03" + CHAR16 Dot4; // "." + CHAR16 TimeStamp[10]; // "YYMMDDHHMM" + CHAR16 NullTerminator; // 0x0000 +} BIOS_ID_STRING; + +// +// A signature precedes the BIOS ID string in the FV to enable search by e= xternal tools. +// +typedef struct { + UINT8 Signature[8]; // "$IBIOSI$" + BIOS_ID_STRING BiosIdString; // "TRFTCRB1.000.0008.D03.1501301017" +} BIOS_ID_IMAGE; + +#pragma pack() + +typedef struct { + EFI_HOB_GUID_TYPE GuidType; + BIOS_ID_IMAGE BiosIdImage; +} BIOS_ID_HOB; + +#endif + diff --git a/Platform/Intel/BoardModulePkg/Include/Library/BiosIdLib.h b/Pl= atform/Intel/BoardModulePkg/Include/Library/BiosIdLib.h new file mode 100644 index 0000000000..6608752da1 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Include/Library/BiosIdLib.h @@ -0,0 +1,57 @@ +/** @file + BIOS ID library functions. + + This library provides functions to get BIOS ID, VERSION, DATE and TIME. + + These functions in this file can be called during DXE and cannot be call= ed during runtime + or in SMM which should use a RT or SMM library. + +Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _BIOS_ID_LIB_H_ +#define _BIOS_ID_LIB_H_ + +#include + +/** + This function returns BIOS ID by searching HOB or FV. + It also debug print the BIOS ID found. + + @param[out] BiosIdImage The BIOS ID got from HOB or FV. It is optional, + no BIOS ID will be returned if it is NULL as i= nput. + + @retval EFI_SUCCESS BIOS ID has been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no par= ameter will be modified. + +**/ +EFI_STATUS +EFIAPI +GetBiosId ( + OUT BIOS_ID_IMAGE *BiosIdImage OPTIONAL + ); + +/** + This function returns the BIOS Version & Release Date and Time by gettin= g and converting BIOS ID. + + @param[out] BiosVersion The Bios Version out of the conversion. + @param[out] BiosReleaseDate The Bios Release Date out of the conversio= n. + @param[out] BiosReleaseTime The Bios Release Time out of the conversio= n. + + @retval EFI_SUCCESS BIOS Version & Release Date and Time h= ave been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no par= ameter will be modified. + @retval EFI_INVALID_PARAMETER All the parameters are NULL. + +**/ +EFI_STATUS +EFIAPI +GetBiosVersionDateTime ( + OUT CHAR16 *BiosVersion, OPTIONAL + OUT CHAR16 *BiosReleaseDate, OPTIONAL + OUT CHAR16 *BiosReleaseTime OPTIONAL + ); + +#endif + diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c= b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c new file mode 100644 index 0000000000..3e614d9efc --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c @@ -0,0 +1,175 @@ +/** @file + Boot service DXE BIOS ID library implementation. + + These functions in this file can be called during DXE and cannot be call= ed during runtime + or in SMM which should use a RT or SMM library. + + +Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/** + This function returns BIOS ID by searching HOB or FV. + It also debug print the BIOS ID found. + + @param[out] BiosIdImage The BIOS ID got from HOB or FV. It is optional, + no BIOS ID will be returned if it is NULL as i= nput. + + @retval EFI_SUCCESS BIOS ID has been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no par= ameter will be modified. + +**/ +EFI_STATUS +EFIAPI +GetBiosId ( + OUT BIOS_ID_IMAGE *BiosIdImage OPTIONAL + ) +{ + EFI_STATUS Status; + BIOS_ID_IMAGE TempBiosIdImage; + VOID *Address; + UINTN Size; + + Address =3D NULL; + Size =3D 0; + + if (BiosIdImage =3D=3D NULL) { + // + // It is NULL as input, so no BIOS ID will be returned. + // Use temp buffer to hold the BIOS ID. + // + BiosIdImage =3D &TempBiosIdImage; + } + + Address =3D GetFirstGuidHob (&gBiosIdGuid); + if (Address !=3D NULL) { + Size =3D sizeof (BIOS_ID_IMAGE); + CopyMem ((VOID *) BiosIdImage, GET_GUID_HOB_DATA (Address), Size); + + DEBUG ((EFI_D_INFO, "DXE get BIOS ID from HOB successfully\n")); + DEBUG ((EFI_D_INFO, "BIOS ID: %s\n", (CHAR16 *) (&(BiosIdImage->BiosId= String)))); + return EFI_SUCCESS; + } + + Status =3D GetSectionFromAnyFv ( + &gBiosIdGuid, + EFI_SECTION_RAW, + 0, + &Address, + &Size + ); + if ((Status =3D=3D EFI_SUCCESS) && (Address !=3D NULL)) { + // + // BIOS ID image is present in FV. + // + Size =3D sizeof (BIOS_ID_IMAGE); + CopyMem ((VOID *) BiosIdImage, Address, Size); + // + // GetSectionFromAnyFv () allocated buffer for Address, now free it. + // + FreePool (Address); + + DEBUG ((EFI_D_INFO, "DXE get BIOS ID from FV successfully\n")); + DEBUG ((EFI_D_INFO, "BIOS ID: %s\n", (CHAR16 *) (&(BiosIdImage->BiosId= String)))); + return EFI_SUCCESS; + } + + DEBUG ((EFI_D_ERROR, "DXE get BIOS ID failed: %r\n", EFI_NOT_FOUND)); + return EFI_NOT_FOUND; +} + +/** + This function returns the BIOS Version & Release Date and Time by gettin= g and converting BIOS ID. + + @param[out] BiosVersion The Bios Version out of the conversion. + @param[out] BiosReleaseDate The Bios Release Date out of the conversio= n. + @param[out] BiosReleaseTime The Bios Release Time out of the conversio= n. + + @retval EFI_SUCCESS BIOS Version & Release Date and Time h= ave been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no par= ameter will be modified. + @retval EFI_INVALID_PARAMETER All the parameters are NULL. + +**/ +EFI_STATUS +EFIAPI +GetBiosVersionDateTime ( + OUT CHAR16 *BiosVersion, OPTIONAL + OUT CHAR16 *BiosReleaseDate, OPTIONAL + OUT CHAR16 *BiosReleaseTime OPTIONAL + ) +{ + EFI_STATUS Status; + BIOS_ID_IMAGE BiosIdImage; + + if ((BiosVersion =3D=3D NULL) && (BiosReleaseDate =3D=3D NULL) && (BiosR= eleaseTime =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D GetBiosId (&BiosIdImage); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + if (BiosVersion !=3D NULL) { + // + // Fill the BiosVersion data from the BIOS ID. + // + CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof (BIOS_ID_STR= ING)); + } + + if (BiosReleaseDate !=3D NULL) { + // + // Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" fo= rmat. + // + BiosReleaseDate[0] =3D BiosIdImage.BiosIdString.TimeStamp[2]; + BiosReleaseDate[1] =3D BiosIdImage.BiosIdString.TimeStamp[3]; + BiosReleaseDate[2] =3D (CHAR16) ((UINT8) ('/')); + + BiosReleaseDate[3] =3D BiosIdImage.BiosIdString.TimeStamp[4]; + BiosReleaseDate[4] =3D BiosIdImage.BiosIdString.TimeStamp[5]; + BiosReleaseDate[5] =3D (CHAR16) ((UINT8) ('/')); + + // + // Add 20 for SMBIOS table + // Current Linux kernel will misjudge 09 as year 0, so using 2009 for = SMBIOS table + // + BiosReleaseDate[6] =3D '2'; + BiosReleaseDate[7] =3D '0'; + BiosReleaseDate[8] =3D BiosIdImage.BiosIdString.TimeStamp[0]; + BiosReleaseDate[9] =3D BiosIdImage.BiosIdString.TimeStamp[1]; + + BiosReleaseDate[10] =3D (CHAR16) ((UINT8) ('\0')); + } + + if (BiosReleaseTime !=3D NULL) { + + // + // Fill the build timestamp time from the BIOS ID in the "HH:MM" forma= t. + // + BiosReleaseTime[0] =3D BiosIdImage.BiosIdString.TimeStamp[6]; + BiosReleaseTime[1] =3D BiosIdImage.BiosIdString.TimeStamp[7]; + BiosReleaseTime[2] =3D (CHAR16) ((UINT8) (':')); + + BiosReleaseTime[3] =3D BiosIdImage.BiosIdString.TimeStamp[8]; + BiosReleaseTime[4] =3D BiosIdImage.BiosIdString.TimeStamp[9]; + + BiosReleaseTime[5] =3D (CHAR16) ((UINT8) ('\0')); + } + + return EFI_SUCCESS; +} + diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.i= nf b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf new file mode 100644 index 0000000000..39f42e91a0 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf @@ -0,0 +1,42 @@ +### @file +# DXE BIOS ID library. +# +# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D DxeBiosIdLib + FILE_GUID =3D D72C04E9-C6C4-49d5-BC16-BD612EBA127B + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D BiosIdLib|DXE_CORE DXE_DRIVER DXE_RUNT= IME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources.common] + DxeBiosIdLib.c + +[Packages] + MdePkg/MdePkg.dec + BoardModulePkg/BoardModulePkg.dec + +[LibraryClasses] + BaseLib + DxeServicesLib + BaseMemoryLib + HobLib + MemoryAllocationLib + DebugLib + +[Guids] + ## SOMETIMES_CONSUMES ## HOB + ## SOMETIMES_CONSUMES ## GUID + gBiosIdGuid + diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c= b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c new file mode 100644 index 0000000000..b0f15d2cb8 --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c @@ -0,0 +1,191 @@ +/** @file + Boot service PEI BIOS ID library implementation. + +Copyright (c) 2-015 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +/** + This function returns BIOS ID by searching HOB or FV. + It also debug print the BIOS ID found. + + @param[out] BiosIdImage The BIOS ID got from HOB or FV. It is optional, + no BIOS ID will be returned if it is NULL as i= nput. + + @retval EFI_SUCCESS BIOS ID has been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no par= ameter will be modified. + +**/ +EFI_STATUS +EFIAPI +GetBiosId ( + OUT BIOS_ID_IMAGE *BiosIdImage OPTIONAL + ) +{ + EFI_STATUS Status; + BIOS_ID_IMAGE TempBiosIdImage; + VOID *Address; + UINTN Size; + UINTN Instance; + EFI_PEI_FV_HANDLE VolumeHandle; + EFI_PEI_FILE_HANDLE FileHandle; + + Address =3D NULL; + Size =3D 0; + + if (BiosIdImage =3D=3D NULL) { + // + // It is NULL as input, so no BIOS ID will be returned. + // Use temp buffer to hold the BIOS ID. + // + BiosIdImage =3D &TempBiosIdImage; + } + + Address =3D GetFirstGuidHob (&gBiosIdGuid); + if (Address !=3D NULL) { + Size =3D sizeof (BIOS_ID_IMAGE); + CopyMem ((VOID *) BiosIdImage, GET_GUID_HOB_DATA (Address), Size); + + DEBUG ((EFI_D_INFO, "PEI get BIOS ID from HOB successfully\n")); + DEBUG ((EFI_D_INFO, "BIOS ID: %s\n", (CHAR16 *) (&(BiosIdImage->BiosId= String)))); + return EFI_SUCCESS; + } + + VolumeHandle =3D NULL; + Instance =3D 0; + while (TRUE) { + // + // Traverse all firmware volume instances. + // + Status =3D PeiServicesFfsFindNextVolume (Instance, &VolumeHandle); + if (EFI_ERROR (Status)) { + break; + } + + FileHandle =3D NULL; + Status =3D PeiServicesFfsFindFileByName (&gBiosIdGuid, VolumeHandle, &= FileHandle); + if (!EFI_ERROR (Status)) { + // + // Search RAW section. + // + Status =3D PeiServicesFfsFindSectionData (EFI_SECTION_RAW, FileHandl= e, &Address); + if (!EFI_ERROR (Status)) { + // + // BIOS ID image is present in this FV. + // + Size =3D sizeof (BIOS_ID_IMAGE); + CopyMem ((VOID *) BiosIdImage, Address, Size); + + DEBUG ((EFI_D_INFO, "PEI get BIOS ID from FV successfully\n")); + DEBUG ((EFI_D_INFO, "BIOS ID: %s\n", (CHAR16 *) (&(BiosIdImage->Bi= osIdString)))); + + // + // Build GUID HOB for the BIOS ID image. + // + BuildGuidDataHob (&gBiosIdGuid, Address, Size); + return EFI_SUCCESS; + } + } + + // + // Search the next volume. + // + Instance++; + } + + DEBUG ((EFI_D_ERROR, "PEI get BIOS ID failed: %r\n", EFI_NOT_FOUND)); + return EFI_NOT_FOUND; +} + +/** + This function returns the BIOS Version & Release Date and Time by gettin= g and converting BIOS ID. + + @param[out] BiosVersion The Bios Version out of the conversion. + @param[out] BiosReleaseDate The Bios Release Date out of the conversio= n. + @param[out] BiosReleaseTime The Bios Release Time out of the conversio= n. + + @retval EFI_SUCCESS BIOS Version & Release Date and Time h= ave been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no par= ameter will be modified. + @retval EFI_INVALID_PARAMETER All the parameters are NULL. + +**/ +EFI_STATUS +EFIAPI +GetBiosVersionDateTime ( + OUT CHAR16 *BiosVersion, OPTIONAL + OUT CHAR16 *BiosReleaseDate, OPTIONAL + OUT CHAR16 *BiosReleaseTime OPTIONAL + ) +{ + EFI_STATUS Status; + BIOS_ID_IMAGE BiosIdImage; + + if ((BiosVersion =3D=3D NULL) && (BiosReleaseDate =3D=3D NULL) && (BiosR= eleaseTime =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + Status =3D GetBiosId (&BiosIdImage); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + if (BiosVersion !=3D NULL) { + // + // Fill the BiosVersion data from the BIOS ID. + // + CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof (BIOS_ID_STR= ING)); + } + + if (BiosReleaseDate !=3D NULL) { + // + // Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" fo= rmat. + // + BiosReleaseDate[0] =3D BiosIdImage.BiosIdString.TimeStamp[2]; + BiosReleaseDate[1] =3D BiosIdImage.BiosIdString.TimeStamp[3]; + BiosReleaseDate[2] =3D (CHAR16) ((UINT8) ('/')); + + BiosReleaseDate[3] =3D BiosIdImage.BiosIdString.TimeStamp[4]; + BiosReleaseDate[4] =3D BiosIdImage.BiosIdString.TimeStamp[5]; + BiosReleaseDate[5] =3D (CHAR16) ((UINT8) ('/')); + + // + // Add 20 for SMBIOS table + // Current Linux kernel will misjudge 09 as year 0, so using 2009 for = SMBIOS table + // + BiosReleaseDate[6] =3D '2'; + BiosReleaseDate[7] =3D '0'; + BiosReleaseDate[8] =3D BiosIdImage.BiosIdString.TimeStamp[0]; + BiosReleaseDate[9] =3D BiosIdImage.BiosIdString.TimeStamp[1]; + + BiosReleaseDate[10] =3D (CHAR16) ((UINT8) ('\0')); + } + + if (BiosReleaseTime !=3D NULL) { + + // + // Fill the build timestamp time from the BIOS ID in the "HH:MM" forma= t. + // + BiosReleaseTime[0] =3D BiosIdImage.BiosIdString.TimeStamp[6]; + BiosReleaseTime[1] =3D BiosIdImage.BiosIdString.TimeStamp[7]; + BiosReleaseTime[2] =3D (CHAR16) ((UINT8) (':')); + + BiosReleaseTime[3] =3D BiosIdImage.BiosIdString.TimeStamp[8]; + BiosReleaseTime[4] =3D BiosIdImage.BiosIdString.TimeStamp[9]; + + BiosReleaseTime[5] =3D (CHAR16) ((UINT8) ('\0')); + } + + return EFI_SUCCESS; +} + diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.i= nf b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf new file mode 100644 index 0000000000..e38d17bd9b --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf @@ -0,0 +1,42 @@ +### @file +# PEI BIOS ID library. +# +# Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +### +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiBiosIdLib + FILE_GUID =3D C97DA4CA-67C1-4523-9A78-CE8CAFE6E239 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D BiosIdLib|PEI_CORE PEIM + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D IA32 X64 +# + +[Sources.common] + PeiBiosIdLib.c + +[Packages] + MdePkg/MdePkg.dec + BoardModulePkg/BoardModulePkg.dec + +[LibraryClasses] + BaseLib + PeiServicesLib + BaseMemoryLib + HobLib + DebugLib + +[Guids] + ## SOMETIMES_CONSUMES ## HOB + ## SOMETIMES_PRODUCES ## HOB + ## SOMETIMES_CONSUMES ## GUID + gBiosIdGuid + --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41379): https://edk2.groups.io/g/devel/message/41379 Mute This Topic: https://groups.io/mt/31804583/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-