public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Nhi Pham" <nhi@os.amperecomputing.com>
To: devel@edk2.groups.io, quic_llindhol@quicinc.com,
	ardb+tianocore@kernel.org, sami.mujawar@arm.com,
	quic_rcran@quicinc.com
Cc: patches@amperecomputing.com,
	Minh Nguyen <minhn@amperecomputing.com>,
	Nhi Pham <nhi@os.amperecomputing.com>
Subject: [PATCH 6/6] ArmPkg/SmbiosMiscDxe: Get SMBIOS information from OemMiscLib
Date: Tue, 23 Aug 2022 17:59:26 +0700	[thread overview]
Message-ID: <20220823105926.1379824-7-nhi@os.amperecomputing.com> (raw)
In-Reply-To: <20220823105926.1379824-1-nhi@os.amperecomputing.com>

From: Minh Nguyen <minhn@amperecomputing.com>

In some scenarios, the information of Bios Version, Bios Release
and Embedded Controller Firmware Release are fetched during UEFI
booting. This patch supports updating those fields dynamically
when the PCDs are empty.

Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
---
 ArmPkg/Include/Library/OemMiscLib.h                                   | 21 +++++++++++++
 ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLib.c                   | 28 +++++++++++++++++
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c | 32 +++++++++++++-------
 3 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/ArmPkg/Include/Library/OemMiscLib.h b/ArmPkg/Include/Library/OemMiscLib.h
index 1936619d9b5b..541274999e5c 100644
--- a/ArmPkg/Include/Library/OemMiscLib.h
+++ b/ArmPkg/Include/Library/OemMiscLib.h
@@ -37,6 +37,7 @@ typedef struct {
 } OEM_MISC_PROCESSOR_DATA;
 
 typedef enum {
+  BiosVersionType00,
   ProductNameType01,
   SerialNumType01,
   UuidType01,
@@ -247,4 +248,24 @@ OemGetSystemUuid (
   OUT GUID  *SystemUuid
   );
 
+/** Fetches the BIOS release.
+
+  @return The BIOS release.
+**/
+UINT16
+EFIAPI
+OemGetBiosRelease (
+  VOID
+  );
+
+/** Fetches the embedded controller firmware release.
+
+  @return The embedded controller firmware release.
+**/
+UINT16
+EFIAPI
+OemGetEmbeddedControllerFirmwareRelease (
+  VOID
+  );
+
 #endif // OEM_MISC_LIB_H_
diff --git a/ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLib.c b/ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLib.c
index 32f6d55c1a9a..788ccab9e8c1 100644
--- a/ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLib.c
+++ b/ArmPkg/Universal/Smbios/OemMiscLibNull/OemMiscLib.c
@@ -254,3 +254,31 @@ OemGetSystemUuid (
   ASSERT (FALSE);
   CopyGuid (SystemUuid, &gZeroGuid);
 }
+
+/** Fetches the BIOS release.
+
+  @return The BIOS release.
+**/
+UINT16
+EFIAPI
+OemGetBiosRelease (
+  VOID
+  )
+{
+  ASSERT (FALSE);
+  return 0xFFFF;
+}
+
+/** Fetches the embedded controller firmware release.
+
+  @return The embedded controller firmware release.
+**/
+UINT16
+EFIAPI
+OemGetEmbeddedControllerFirmwareRelease (
+  VOID
+  )
+{
+  ASSERT (FALSE);
+  return 0xFFFF;
+}
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c
index b49c4b754cab..e9106a8a2fec 100644
--- a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c
@@ -1,5 +1,6 @@
 /** @file
 
+  Copyright (c) 2022, Ampere Computing LLC. All rights reserved.<BR>
   Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
   Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2015, Hisilicon Limited. All rights reserved.<BR>
@@ -13,6 +14,7 @@
 #include <Library/DebugLib.h>
 #include <Library/HiiLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/OemMiscLib.h>
 #include <Library/PrintLib.h>
 #include <Library/UefiBootServicesTableLib.h>
 
@@ -191,11 +193,11 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
     HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
   } else {
-    Version = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
-    if (StrLen (Version) > 0) {
-      TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
-      HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
-    }
+      OemUpdateSmbiosInfo (
+        mSmbiosMiscHiiHandle,
+        STRING_TOKEN (STR_MISC_BIOS_VERSION),
+        BiosVersionType00
+        );
   }
 
   Char16String = GetBiosReleaseDate ();
@@ -251,13 +253,21 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
     }
   }
 
-  SmbiosRecord->SystemBiosMajorRelease = (UINT8)(PcdGet16 (PcdSystemBiosRelease) >> 8);
-  SmbiosRecord->SystemBiosMinorRelease = (UINT8)(PcdGet16 (PcdSystemBiosRelease) & 0xFF);
+  if (PcdGet16 (PcdSystemBiosRelease) != 0xFFFF) {
+    SmbiosRecord->SystemBiosMajorRelease = (UINT8)(PcdGet16 (PcdSystemBiosRelease) >> 8);
+    SmbiosRecord->SystemBiosMinorRelease = (UINT8)(PcdGet16 (PcdSystemBiosRelease) & 0xFF);
+  } else {
+    SmbiosRecord->SystemBiosMajorRelease = (UINT8)(OemGetBiosRelease () >> 8);
+    SmbiosRecord->SystemBiosMinorRelease = (UINT8)(OemGetBiosRelease () & 0xFF);
+  }
 
-  SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = (UINT16)
-                                                         (PcdGet16 (PcdEmbeddedControllerFirmwareRelease) >> 8);
-  SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = (UINT16)
-                                                         (PcdGet16 (PcdEmbeddedControllerFirmwareRelease) & 0xFF);
+  if (PcdGet16 (PcdEmbeddedControllerFirmwareRelease) != 0xFFFF) {
+    SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = (UINT16)(PcdGet16 (PcdEmbeddedControllerFirmwareRelease) >> 8);
+    SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = (UINT16)(PcdGet16 (PcdEmbeddedControllerFirmwareRelease) & 0xFF);
+  } else {
+    SmbiosRecord->EmbeddedControllerFirmwareMajorRelease = (UINT16)(OemGetEmbeddedControllerFirmwareRelease () >> 8);
+    SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = (UINT16)(OemGetEmbeddedControllerFirmwareRelease () & 0xFF);
+  }
 
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
   UnicodeStrToAsciiStrS (Vendor, OptionalStrStart, VendorStrLen + 1);
-- 
2.25.1


  parent reply	other threads:[~2022-08-23 11:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 10:59 [PATCH 0/6] ArmPkg/SMBIOS fixes and improvements Nhi Pham
2022-08-23 10:59 ` [PATCH 1/6] ArmPkg/ProcessorSubClassDxe: Get processor version from OemMiscLib Nhi Pham
2022-08-23 16:21   ` Sami Mujawar
2022-08-24 16:10     ` Nhi Pham
2022-08-23 10:59 ` [PATCH 2/6] ArmPkg: Correct return value of "SMCCC_ARCH_SOC_ID" Function ID call Nhi Pham
2022-08-23 16:28   ` Sami Mujawar
2022-08-23 10:59 ` [PATCH 3/6] ArmPkg/SmbiosMiscDxe: Support fetching System UUID Nhi Pham
2022-08-23 16:31   ` Sami Mujawar
2022-08-23 10:59 ` [PATCH 4/6] ArmPkg/SmbiosMiscDxe: Fix typo of "AssetTagType02" Nhi Pham
2022-08-23 16:34   ` Sami Mujawar
2022-08-23 10:59 ` [PATCH 5/6] ArmPkg/SmbiosMiscDxe: Remove redundant updates in SMBIOS Type 2 Nhi Pham
2022-08-23 16:36   ` Sami Mujawar
2022-08-23 10:59 ` Nhi Pham [this message]
2022-08-23 16:57   ` [PATCH 6/6] ArmPkg/SmbiosMiscDxe: Get SMBIOS information from OemMiscLib Sami Mujawar
2022-08-23 14:24 ` [edk2-devel] [PATCH 0/6] ArmPkg/SMBIOS fixes and improvements Rebecca Cran
2022-08-23 15:57 ` PierreGondois

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=20220823105926.1379824-7-nhi@os.amperecomputing.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