public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Tinh Nguyen" <tinhnguyen@os.amperecomputing.com>
To: devel@edk2.groups.io
Cc: patches@amperecomputing.com, quic_llindhol@quicinc.com,
	ardb+tianocore@kernel.org,
	Tinh Nguyen <tinhnguyen@os.amperecomputing.com>,
	Nhi Pham <nhi@os.amperecomputing.com>
Subject: [PATCH 1/1] ArmPkg/SmbiosMiscDxe: Adjust the priority of getting firmware version
Date: Mon, 13 Mar 2023 13:43:21 +0700	[thread overview]
Message-ID: <20230313064321.170866-1-tinhnguyen@os.amperecomputing.com> (raw)

The BIOS Firmware Version in the SMBIOS Type 0 can be fetched from
the fixed PcdFirmwareVersionString or platform specific OemMiscLib.
In fact, the support from OemMiscLib comes into play when the firmware
version may be modified at boot time for extended information.

Therefore, the priority of getting the version from OemMiscLib should
be higher. In case there is no modification in the OemMiscLib,
we have to keep HII string STR_MISC_BIOS_VERSION empty or 'Not Specified'
to indicate that the firmware version should be fetched from
the PcdFirmwareVersionString.

Reviewed-by: Nhi Pham <nhi@os.amperecomputing.com>
Signed-off-by: Tinh Nguyen <tinhnguyen@os.amperecomputing.com>
---
 ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c | 36 ++++++++++++++------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c
index 66ead22a6e2c..31a3f6cde544 100644
--- a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c
+++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2022, Ampere Computing LLC. All rights reserved.<BR>
+  Copyright (c) 2022 - 2023, 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>
@@ -170,6 +170,7 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
   EFI_STRING_ID       TokenToGet;
   SMBIOS_TABLE_TYPE0  *SmbiosRecord;
   SMBIOS_TABLE_TYPE0  *InputData;
+  CHAR16              *DefaultVersionString;
 
   //
   // First check for invalid parameters.
@@ -187,17 +188,30 @@ SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) {
     HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Vendor, NULL);
   }
 
-  Version = GetBiosVersion ();
+  DefaultVersionString = HiiGetString (
+                           mSmbiosMiscHiiHandle,
+                           STRING_TOKEN (STR_MISC_BIOS_VERSION),
+                           NULL
+                           );
 
-  if (StrLen (Version) > 0) {
-    TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
-    HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
-  } else {
-    OemUpdateSmbiosInfo (
-      mSmbiosMiscHiiHandle,
-      STRING_TOKEN (STR_MISC_BIOS_VERSION),
-      BiosVersionType00
-      );
+  OemUpdateSmbiosInfo (
+    mSmbiosMiscHiiHandle,
+    STRING_TOKEN (STR_MISC_BIOS_VERSION),
+    BiosVersionType00
+    );
+
+  Version = HiiGetString (
+              mSmbiosMiscHiiHandle,
+              STRING_TOKEN (STR_MISC_BIOS_VERSION),
+              NULL
+              );
+
+  if (((StrCmp (Version, DefaultVersionString) == 0) || (StrLen (Version) == 0))) {
+    Version = GetBiosVersion ();
+    if (StrLen (Version) > 0) {
+      TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VERSION);
+      HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL);
+    }
   }
 
   Char16String = GetBiosReleaseDate ();
-- 
2.39.2


             reply	other threads:[~2023-03-13  6:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13  6:43 Tinh Nguyen [this message]
2023-03-13 15:03 ` [PATCH 1/1] ArmPkg/SmbiosMiscDxe: Adjust the priority of getting firmware version Leif Lindholm
2023-03-13 16:52   ` Tinh Nguyen
2023-03-14 12:48     ` [edk2-devel] " Leif Lindholm
2023-03-14 17:59       ` Rebecca Cran
2023-03-17 14:52         ` Tinh Nguyen
2023-03-16  8:30 ` Tinh Nguyen
2023-03-16 13:00   ` [edk2-devel] " Rebecca Cran
2023-03-17 14:50     ` Tinh Nguyen
2023-03-17 14:50     ` Tinh Nguyen

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=20230313064321.170866-1-tinhnguyen@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