From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.7190.1665412939580505706 for ; Mon, 10 Oct 2022 07:42:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Mc/RGivP; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665412938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GX0TRkjoxbEP/ZWsPqVC+QFtxk9kNCRDXTzMkkl9ffg=; b=Mc/RGivPftVyMCYjhXUivrb0FV2MM0SqL0wjn4+WA5lItixAkHISxkyF9xt1f0TVklJleZ nTj+1J5KHHMPmvoKm2gqdFxVR+AWoiPQJbQ7IT7ihxPc7SzRhetP8lVpoMxEq8zOPJEsHU 2vLt8iQCLN3f8Bz9CRnvoFW11adWGCI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-125-up1kjHEHOTy7khP9mHqJsA-1; Mon, 10 Oct 2022 10:42:15 -0400 X-MC-Unique: up1kjHEHOTy7khP9mHqJsA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2BC2C802C17; Mon, 10 Oct 2022 14:42:15 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.195.183]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF6512083A6E; Mon, 10 Oct 2022 14:42:14 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 258C418000B3; Mon, 10 Oct 2022 16:42:13 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Jordan Justen , Julien Grall , Oliver Steffen , Pawel Polawski , Ard Biesheuvel , Anthony Perard , Jiewen Yao Subject: [PATCH 1/1] OvmfPkg/SmbiosPlatformDxe: use PcdFirmwareVersionString Date: Mon, 10 Oct 2022 16:42:13 +0200 Message-Id: <20221010144213.1470478-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 --- .../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 // SMBIOS_TABLE_TYPE0 +#include +#include #include // ASSERT_EFI_ERROR() +#include +#include #include // gBS #include // 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