public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dong, Eric" <eric.dong@intel.com>
To: devel@edk2.groups.io
Cc: Liming Gao <liming.gao@intel.com>,
	Michael Kubacki <michael.a.kubacki@intel.com>,
	Sai Chaganty <rangasai.v.chaganty@intel.com>,
	Oram, Isaac W <isaac.w.oram@intel.com>
Subject: [Patch 3/3] [edk2-platform] Platform/Intel/BoardModulePkg: Add BiosId Module.
Date: Mon, 27 May 2019 09:12:41 +0800	[thread overview]
Message-ID: <20190527011241.14916-4-eric.dong@intel.com> (raw)
In-Reply-To: <20190527011241.14916-1-eric.dong@intel.com>

Add Bios ID library used to read BIOS ID related info.

This library exports APIs like below:
GetBiosId
GetBiosVersionDateTime

Signed-off-by: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kubacki <michael.a.kubacki@intel.com>
Cc: Sai Chaganty <rangasai.v.chaganty@intel.com>
Cc: Oram, Isaac W <isaac.w.oram@intel.com>
---
 .../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/DxeBiosIdLib.c
 create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf
 create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c
 create mode 100644 Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf

diff --git a/Platform/Intel/BoardModulePkg/BoardModulePkg.dec b/Platform/Intel/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 area.
   PlatformCmosAccessLib|Include/Library/PlatformCmosAccessLib.h
 
+  ##  @libraryclass    Provide services to get BIOS ID information.
+  BiosIdLib|Include/Library/BiosIdLib.h
+
+[Guids]
+  ## Include Include/Guid/BiosId.h
+  gBiosIdGuid = { 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.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _BIOS_ID_GUID_H_
+#define _BIOS_ID_GUID_H_
+
+#include <Pi/PiHob.h>
+
+#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)$(VERSION_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 external 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/Platform/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 called during runtime
+  or in SMM which should use a RT or SMM library.
+
+Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _BIOS_ID_LIB_H_
+#define _BIOS_ID_LIB_H_
+
+#include <Guid/BiosId.h>
+
+/**
+  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 input.
+
+  @retval EFI_SUCCESS               BIOS ID has been got successfully.
+  @retval EFI_NOT_FOUND             BIOS ID image is not found, and no parameter will be modified.
+
+**/
+EFI_STATUS
+EFIAPI
+GetBiosId (
+  OUT BIOS_ID_IMAGE     *BiosIdImage OPTIONAL
+  );
+
+/**
+  This function returns the BIOS Version & Release Date and Time by getting and converting BIOS ID.
+
+  @param[out] BiosVersion       The Bios Version out of the conversion.
+  @param[out] BiosReleaseDate   The Bios Release Date out of the conversion.
+  @param[out] BiosReleaseTime   The Bios Release Time out of the conversion.
+
+  @retval EFI_SUCCESS               BIOS Version & Release Date and Time have been got successfully.
+  @retval EFI_NOT_FOUND             BIOS ID image is not found, and no parameter 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 called during runtime
+  or in SMM which should use a RT or SMM library.
+
+
+Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiDxe.h>
+#include <Library/BaseLib.h>
+#include <Library/HobLib.h>
+#include <Library/DxeServicesLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BiosIdLib.h>
+
+#include <Guid/BiosId.h>
+
+/**
+  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 input.
+
+  @retval EFI_SUCCESS               BIOS ID has been got successfully.
+  @retval EFI_NOT_FOUND             BIOS ID image is not found, and no parameter 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 = NULL;
+  Size = 0;
+
+  if (BiosIdImage == NULL) {
+    //
+    // It is NULL as input, so no BIOS ID will be returned.
+    // Use temp buffer to hold the BIOS ID.
+    //
+    BiosIdImage = &TempBiosIdImage;
+  }
+
+  Address = GetFirstGuidHob (&gBiosIdGuid);
+  if (Address != NULL) {
+    Size = 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->BiosIdString))));
+    return EFI_SUCCESS;
+  }
+
+  Status = GetSectionFromAnyFv (
+             &gBiosIdGuid,
+             EFI_SECTION_RAW,
+             0,
+             &Address,
+             &Size
+             );
+  if ((Status == EFI_SUCCESS) && (Address != NULL)) {
+    //
+    // BIOS ID image is present in FV.
+    //
+    Size = 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->BiosIdString))));
+    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 getting and converting BIOS ID.
+
+  @param[out] BiosVersion       The Bios Version out of the conversion.
+  @param[out] BiosReleaseDate   The Bios Release Date out of the conversion.
+  @param[out] BiosReleaseTime   The Bios Release Time out of the conversion.
+
+  @retval EFI_SUCCESS               BIOS Version & Release Date and Time have been got successfully.
+  @retval EFI_NOT_FOUND             BIOS ID image is not found, and no parameter 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 == NULL) && (BiosReleaseDate == NULL) && (BiosReleaseTime == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = GetBiosId (&BiosIdImage);
+  if (EFI_ERROR (Status)) {
+    return EFI_NOT_FOUND;
+  }
+
+  if (BiosVersion != NULL) {
+    //
+    // Fill the BiosVersion data from the BIOS ID.
+    //
+    CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof (BIOS_ID_STRING));
+  }
+
+  if (BiosReleaseDate != NULL) {
+    //
+    // Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" format.
+    //
+    BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2];
+    BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3];
+    BiosReleaseDate[2] = (CHAR16) ((UINT8) ('/'));
+
+    BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4];
+    BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5];
+    BiosReleaseDate[5] = (CHAR16) ((UINT8) ('/'));
+
+    //
+    // Add 20 for SMBIOS table
+    // Current Linux kernel will misjudge 09 as year 0, so using 2009 for SMBIOS table
+    //
+    BiosReleaseDate[6] = '2';
+    BiosReleaseDate[7] = '0';
+    BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0];
+    BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1];
+
+    BiosReleaseDate[10] = (CHAR16) ((UINT8) ('\0'));
+  }
+
+  if (BiosReleaseTime != NULL) {
+
+    //
+    // Fill the build timestamp time from the BIOS ID in the "HH:MM" format.
+    //
+    BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6];
+    BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7];
+    BiosReleaseTime[2] = (CHAR16) ((UINT8) (':'));
+
+    BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8];
+    BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9];
+
+    BiosReleaseTime[5] = (CHAR16) ((UINT8) ('\0'));
+  }
+
+  return  EFI_SUCCESS;
+}
+
diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf 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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+[Defines]
+  INF_VERSION                   = 0x00010005
+  BASE_NAME                     = DxeBiosIdLib
+  FILE_GUID                     = D72C04E9-C6C4-49d5-BC16-BD612EBA127B
+  MODULE_TYPE                   = DXE_DRIVER
+  VERSION_STRING                = 1.0
+  LIBRARY_CLASS                 = BiosIdLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_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          = 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.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiPei.h>
+#include <Library/BaseLib.h>
+#include <Library/PeiServicesLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BiosIdLib.h>
+
+#include <Guid/BiosId.h>
+
+/**
+  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 input.
+
+  @retval EFI_SUCCESS               BIOS ID has been got successfully.
+  @retval EFI_NOT_FOUND             BIOS ID image is not found, and no parameter 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 = NULL;
+  Size = 0;
+
+  if (BiosIdImage == NULL) {
+    //
+    // It is NULL as input, so no BIOS ID will be returned.
+    // Use temp buffer to hold the BIOS ID.
+    //
+    BiosIdImage = &TempBiosIdImage;
+  }
+
+  Address = GetFirstGuidHob (&gBiosIdGuid);
+  if (Address != NULL) {
+    Size = 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->BiosIdString))));
+    return EFI_SUCCESS;
+  }
+
+  VolumeHandle = NULL;
+  Instance = 0;
+  while (TRUE) {
+    //
+    // Traverse all firmware volume instances.
+    //
+    Status = PeiServicesFfsFindNextVolume (Instance, &VolumeHandle);
+    if (EFI_ERROR (Status)) {
+      break;
+    }
+
+    FileHandle = NULL;
+    Status = PeiServicesFfsFindFileByName (&gBiosIdGuid, VolumeHandle, &FileHandle);
+    if (!EFI_ERROR (Status)) {
+      //
+      // Search RAW section.
+      //
+      Status = PeiServicesFfsFindSectionData (EFI_SECTION_RAW, FileHandle, &Address);
+      if (!EFI_ERROR (Status)) {
+        //
+        // BIOS ID image is present in this FV.
+        //
+        Size = 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->BiosIdString))));
+
+        //
+        // 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 getting and converting BIOS ID.
+
+  @param[out] BiosVersion       The Bios Version out of the conversion.
+  @param[out] BiosReleaseDate   The Bios Release Date out of the conversion.
+  @param[out] BiosReleaseTime   The Bios Release Time out of the conversion.
+
+  @retval EFI_SUCCESS               BIOS Version & Release Date and Time have been got successfully.
+  @retval EFI_NOT_FOUND             BIOS ID image is not found, and no parameter 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 == NULL) && (BiosReleaseDate == NULL) && (BiosReleaseTime == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  Status = GetBiosId (&BiosIdImage);
+  if (EFI_ERROR (Status)) {
+    return EFI_NOT_FOUND;
+  }
+
+  if (BiosVersion != NULL) {
+    //
+    // Fill the BiosVersion data from the BIOS ID.
+    //
+    CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof (BIOS_ID_STRING));
+  }
+
+  if (BiosReleaseDate != NULL) {
+    //
+    // Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" format.
+    //
+    BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2];
+    BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3];
+    BiosReleaseDate[2] = (CHAR16) ((UINT8) ('/'));
+
+    BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4];
+    BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5];
+    BiosReleaseDate[5] = (CHAR16) ((UINT8) ('/'));
+
+    //
+    // Add 20 for SMBIOS table
+    // Current Linux kernel will misjudge 09 as year 0, so using 2009 for SMBIOS table
+    //
+    BiosReleaseDate[6] = '2';
+    BiosReleaseDate[7] = '0';
+    BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0];
+    BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1];
+
+    BiosReleaseDate[10] = (CHAR16) ((UINT8) ('\0'));
+  }
+
+  if (BiosReleaseTime != NULL) {
+
+    //
+    // Fill the build timestamp time from the BIOS ID in the "HH:MM" format.
+    //
+    BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6];
+    BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7];
+    BiosReleaseTime[2] = (CHAR16) ((UINT8) (':'));
+
+    BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8];
+    BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9];
+
+    BiosReleaseTime[5] = (CHAR16) ((UINT8) ('\0'));
+  }
+
+  return  EFI_SUCCESS;
+}
+
diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf 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.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+[Defines]
+  INF_VERSION                   = 0x00010005
+  BASE_NAME                     = PeiBiosIdLib
+  FILE_GUID                     = C97DA4CA-67C1-4523-9A78-CE8CAFE6E239
+  MODULE_TYPE                   = PEIM
+  VERSION_STRING                = 1.0
+  LIBRARY_CLASS                 = BiosIdLib|PEI_CORE PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES          = 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
+
-- 
2.21.0.windows.1


  parent reply	other threads:[~2019-05-27  1:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-27  1:12 [Patch 0/3] Add modules to BoardModulePkg Dong, Eric
2019-05-27  1:12 ` [Patch 1/3] [edk2-platform] Maintainers.txt: Add BoardModulePkg in Platform/Intel/ folder Dong, Eric
2019-05-27  1:12 ` [Patch 2/3] [edk2-platform] Platform/Intel: Add Cmos related modules to BoardModulePkg Dong, Eric
2019-05-27  1:12 ` Dong, Eric [this message]
2019-05-28  0:38 ` [edk2-devel] [Patch 0/3] Add " Liming Gao
     [not found] ` <15A2B1D15A184189.14260@groups.io>
2019-05-28  0:42   ` Liming Gao

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=20190527011241.14916-4-eric.dong@intel.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