From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Jordan Justen <jordan.l.justen@intel.com>,
Julien Grall <julien@xen.org>,
Oliver Steffen <osteffen@redhat.com>,
Pawel Polawski <ppolawsk@redhat.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Anthony Perard <anthony.perard@citrix.com>,
Jiewen Yao <jiewen.yao@intel.com>
Subject: [PATCH 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmwareVersionString
Date: Mon, 10 Oct 2022 16:42:13 +0200 [thread overview]
Message-ID: <20221010144213.1470478-1-kraxel@redhat.com> (raw)
Instead of using hard-coded string "0.0.0" for BiosVersion (which is
quite useless) read PcdFirmwareVersionString and append that to the
type0 entry string table.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
.../SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 4 +++
.../XenSmbiosPlatformDxe.inf | 7 +++-
OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 32 ++++++++++++++++---
3 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 0066bbc9229c..1a0a032342f9 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -32,9 +32,12 @@ [Sources]
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
DebugLib
MemoryAllocationLib
PcdLib
@@ -45,6 +48,7 @@ [LibraryClasses]
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
[Protocols]
gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
diff --git a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
index 7f4588e33d1e..73c78ec7cc73 100644
--- a/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
+++ b/OvmfPkg/SmbiosPlatformDxe/XenSmbiosPlatformDxe.inf
@@ -38,19 +38,24 @@ [Sources.ARM, Sources.AARCH64]
[Packages]
MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
[Packages.IA32, Packages.X64]
OvmfPkg/OvmfPkg.dec
[LibraryClasses]
+ BaseLib
+ BaseMemoryLib
DebugLib
UefiBootServicesTableLib
UefiDriverEntryPoint
[LibraryClasses.IA32, LibraryClasses.X64]
- BaseLib
HobLib
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
+
[Protocols]
gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED
diff --git a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 94249d3ff1b0..f2eb568b6964 100644
--- a/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -9,7 +9,11 @@
**/
#include <IndustryStandard/SmBios.h> // SMBIOS_TABLE_TYPE0
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h> // ASSERT_EFI_ERROR()
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h> // gBS
#include <Protocol/Smbios.h> // EFI_SMBIOS_PROTOCOL
@@ -17,8 +21,7 @@
#define TYPE0_STRINGS \
"EFI Development Kit II / OVMF\0" /* Vendor */ \
- "0.0.0\0" /* BiosVersion */ \
- "02/06/2015\0" /* BiosReleaseDate */
+ "02/06/2015" /* BiosReleaseDate */
//
// Type definition and contents of the default Type 0 SMBIOS table.
//
@@ -37,9 +40,9 @@ STATIC CONST OVMF_TYPE0 mOvmfDefaultType0 = {
sizeof (SMBIOS_TABLE_TYPE0), // UINT8 Length
},
1, // SMBIOS_TABLE_STRING Vendor
- 2, // SMBIOS_TABLE_STRING BiosVersion
+ 3, // SMBIOS_TABLE_STRING BiosVersion
0xE800, // UINT16 BiosSegment
- 3, // SMBIOS_TABLE_STRING BiosReleaseDate
+ 2, // SMBIOS_TABLE_STRING BiosReleaseDate
0, // UINT8 BiosSize
{ // MISC_BIOS_CHARACTERISTICS BiosCharacteristics
0, // Reserved :2
@@ -153,14 +156,33 @@ InstallAllStructures (
//
// Add OVMF default Type 0 (BIOS Information) table
//
+ CHAR16 *Str16;
+ UINTN Chars;
+ CHAR8 *Type0;
+
+ Str16 = (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString);
+ Chars = StrLen (Str16);
+ if (Chars == 0) {
+ Str16 = L"unknown";
+ Chars = StrLen (Str16);
+ }
+
+ DEBUG ((DEBUG_INFO, "FirmwareVersionString: \"%s\" (%d chars)\n", Str16, Chars));
+
+ Type0 = AllocateZeroPool (sizeof (mOvmfDefaultType0) + Chars + 2);
+ CopyMem (Type0, &mOvmfDefaultType0, sizeof (mOvmfDefaultType0));
+ UnicodeStrToAsciiStrS (Str16, Type0 + sizeof (mOvmfDefaultType0), Chars + 1);
+
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->Add (
Smbios,
NULL,
&SmbiosHandle,
- (EFI_SMBIOS_TABLE_HEADER *)&mOvmfDefaultType0
+ (EFI_SMBIOS_TABLE_HEADER *)Type0
);
ASSERT_EFI_ERROR (Status);
+
+ FreePool (Type0);
}
return EFI_SUCCESS;
--
2.37.3
next reply other threads:[~2022-10-10 14:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-10 14:42 Gerd Hoffmann [this message]
2022-10-10 16:27 ` [edk2-devel] [PATCH 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmwareVersionString Rebecca Cran
2022-10-11 7:59 ` Gerd Hoffmann
2022-10-11 15:34 ` Rebecca Cran
2022-10-12 8:52 ` Gerd Hoffmann
2022-10-24 14:03 ` Ard Biesheuvel
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=20221010144213.1470478-1-kraxel@redhat.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