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 <kra...@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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94941): https://edk2.groups.io/g/devel/message/94941 Mute This Topic: https://groups.io/mt/94237616/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-