From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by mx.groups.io with SMTP id smtpd.web11.29803.1611158520709621639 for ; Wed, 20 Jan 2021 08:02:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@9elements.com header.s=google header.b=TjsRRh/S; spf=pass (domain: 9elements.com, ip: 209.85.208.53, mailfrom: patrick.rudolph@9elements.com) Received: by mail-ed1-f53.google.com with SMTP id j13so2083510edp.2 for ; Wed, 20 Jan 2021 08:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bA7AvYvt9+P1dhLYRaYizciVtZUlH4aq6rqPvblzCA8=; b=TjsRRh/SlUYsrU0PhGd4VyQvQfpC/WnD6vDlpenMjfoFn7RN+G+VxZI5+0m0WeM16H bdA0hDcf3moJ49I9l34vlnGQ+R+5aeXNPcys+T4pkziL/FXoJvo8iu1BsMBFT4rysR/B aAKBC0itk6zch7rv3iObP8T4xbVusaaCFbcbCGnmUa/FJT0QOuKPPjZMs2UfTvrmoAtW 08ScLpsQybpWC5Fldx/UEIV4OvdkYUhqLfhn5vPAdginHbnYXm5ebMH+V8QMCFNZvvbC FwWRTXKdgHxzGTBJtvqh5LIpt8DXYgEX9Zf4jdNKBIKRnh0GoJ/IwljETISvnFOqrTc3 Qnpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bA7AvYvt9+P1dhLYRaYizciVtZUlH4aq6rqPvblzCA8=; b=uSow5mgB2w+FWPLdZjOgYJ/9ISeu4PZLoe6GDgbbz9QJL7gGURAfmdFXIq5vwizKTN Uu3EIqlRnYpnOZsnCAaEMjrYQNiKCDKASigmIjJdSZJ5igcW9KfrqJtjuIyvVEJSiNEW gbVTlKN8xPRBAv/WBf2TAhS9LqHMzMwfYpXdmksBUGgR2bVoK1eT+O3X30k8VerUdOe3 QLQPQeu2mUCJj4OTGnreJFkLbx+6hlYB/8rlJnR9XrAydPMonfU1tYmD2od/GDhI/515 TQ5BAlumkBHzYQSrmBzg7tX6HnoaxnWn6g6KBnE8PfMxhI1kCKy582y7KOiJ//8YwQrb bJtw== X-Gm-Message-State: AOAM532CIwq1h3Pbx4VRZc8cZJIYdBcgW+ZFtoJAwKmjGN7/jCE29ITH zn7lnh66r/2Ce0nE3LSqnjsOYZcP30zZPiU0 X-Google-Smtp-Source: ABdhPJwOw62R2zESlR9Cr96i+0bcFOz0xoqQFT3sLRWfZlV323HzzXDkdSfEpyBZlMp3zN9vQS8+zw== X-Received: by 2002:a05:6402:c9c:: with SMTP id cm28mr8148899edb.281.1611158519233; Wed, 20 Jan 2021 08:01:59 -0800 (PST) Return-Path: Received: from rudolphp-notebook.9e.network (ip-95-222-8-167.hsi15.unitymediagroup.de. [95.222.8.167]) by smtp.gmail.com with ESMTPSA id i6sm1063422ejd.110.2021.01.20.08.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 08:01:58 -0800 (PST) From: "Patrick Rudolph" To: devel@edk2.groups.io Cc: maurice.ma@intel.com, guo.dong@intel.com, benjamin.you@intel.com Subject: [PATCH] UefiPayloadPkg/BlSupportDxe: Use EfiSmbiosProtocol to install tables Date: Wed, 20 Jan 2021 17:01:57 +0100 Message-Id: <20210120160157.3343911-1-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The default EfiSmbiosProtocol operates on an empty SMBIOS table. As the SMBIOS tables are provided by the bootloader, install the SMBIOS tables using the EfiSmbiosProtocol. This fixes the settings menu not showing any hardware information, instead only "0 MB RAM" was displayed. Tests showed that the OS can still see the SMBIOS tables. Signed-off-by: Patrick Rudolph --- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 111 +++++++++++++++++++- UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 3 + UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 5 +- 3 files changed, 115 insertions(+), 4 deletions(-) diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.c index a746d0581e..db478c1abc 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c @@ -79,6 +79,107 @@ ReserveResourceInGcd ( return Status;=0D }=0D =0D +EFI_STATUS=0D +EFIAPI=0D +BlDxeInstallSMBIOStables(=0D + IN UINT64 SmbiosTableBase,=0D + IN UINT32 SmbiosTableSize=0D +)=0D +{=0D + EFI_STATUS Status;=0D + SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;=0D + SMBIOS_TABLE_3_0_ENTRY_POINT *Smbios30Table;=0D + SMBIOS_STRUCTURE_POINTER Smbios;=0D + SMBIOS_STRUCTURE_POINTER SmbiosEnd;=0D + CHAR8 *String;=0D + EFI_SMBIOS_HANDLE SmbiosHandle;=0D + EFI_SMBIOS_PROTOCOL *SmbiosProto;=0D +=0D + //=0D + // Locate Smbios protocol.=0D + //=0D + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)= &SmbiosProto);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "%a: Failed to locate gEfiSmbiosProtocolGuid\n",= =0D + __FUNCTION__));=0D + return Status;=0D + }=0D +=0D + Smbios30Table =3D (SMBIOS_TABLE_3_0_ENTRY_POINT *)(UINTN)(SmbiosTableBas= e);=0D + SmbiosTable =3D (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)(SmbiosTableBase);=0D +=0D + if (CompareMem (Smbios30Table->AnchorString, "_SM3_", 5) =3D=3D 0) {=0D + Smbios.Hdr =3D (SMBIOS_STRUCTURE *) (UINTN) Smbios30Table->TableAddres= s;=0D + SmbiosEnd.Raw =3D (UINT8 *) (UINTN) (Smbios30Table->TableAddress + Smb= ios30Table->TableMaximumSize);=0D + if (Smbios30Table->TableMaximumSize > SmbiosTableSize) {=0D + DEBUG((DEBUG_INFO, "%a: SMBIOS table size greater than reported by b= ootloader\n",=0D + __FUNCTION__));=0D + }=0D + } else if (CompareMem (SmbiosTable->AnchorString, "_SM_", 4) =3D=3D 0) {= =0D + Smbios.Hdr =3D (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddre= ss;=0D + SmbiosEnd.Raw =3D (UINT8 *) ((UINTN) SmbiosTable->TableAddress + Smbio= sTable->TableLength);=0D +=0D + if (SmbiosTable->TableLength > SmbiosTableSize) {=0D + DEBUG((DEBUG_INFO, "%a: SMBIOS table size greater than reported by b= ootloader\n",=0D + __FUNCTION__));=0D + }=0D + } else {=0D + DEBUG ((DEBUG_ERROR, "%a: No valid SMBIOS table found\n", __FUNCTION__= ));=0D + return EFI_NOT_FOUND;=0D + }=0D +=0D + do {=0D + // Check for end marker=0D + if (Smbios.Hdr->Type =3D=3D 127) {=0D + break;=0D + }=0D +=0D + // Install the table=0D + SmbiosHandle =3D SMBIOS_HANDLE_PI_RESERVED;=0D + Status =3D SmbiosProto->Add (=0D + SmbiosProto,=0D + gImageHandle,=0D + &SmbiosHandle,=0D + Smbios.Hdr=0D + );=0D + ASSERT_EFI_ERROR (Status);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D + //=0D + // Go to the next SMBIOS structure. Each SMBIOS structure may include = 2 parts:=0D + // 1. Formatted section; 2. Unformatted string section. So, 2 steps ar= e needed=0D + // to skip one SMBIOS structure.=0D + //=0D +=0D + //=0D + // Step 1: Skip over formatted section.=0D + //=0D + String =3D (CHAR8 *) (Smbios.Raw + Smbios.Hdr->Length);=0D +=0D + //=0D + // Step 2: Skip over unformatted string section.=0D + //=0D + do {=0D + //=0D + // Each string is terminated with a NULL(00h) BYTE and the sets of s= trings=0D + // is terminated with an additional NULL(00h) BYTE.=0D + //=0D + for ( ; *String !=3D 0; String++) {=0D + }=0D +=0D + if (*(UINT8*)++String =3D=3D 0) {=0D + //=0D + // Pointer to the next SMBIOS structure.=0D + //=0D + Smbios.Raw =3D (UINT8 *)++String;=0D + break;=0D + }=0D + } while (TRUE);=0D + } while (Smbios.Raw < SmbiosEnd.Raw);=0D +=0D + return EFI_SUCCESS;=0D +}=0D =0D /**=0D Main entry for the bootloader support DXE module.=0D @@ -133,9 +234,13 @@ BlDxeEntryPoint ( // Install Smbios Table=0D //=0D if (SystemTableInfo->SmbiosTableBase !=3D 0 && SystemTableInfo->SmbiosTa= bleSize !=3D 0) {=0D - DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", S= ystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize));=0D - Status =3D gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID= *)(UINTN)SystemTableInfo->SmbiosTableBase);=0D - ASSERT_EFI_ERROR (Status);=0D + DEBUG ((DEBUG_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n",=0D + SystemTableInfo->SmbiosTableBase, SystemTableInfo->SmbiosTableSize))= ;=0D +=0D + if (BlDxeInstallSMBIOStables(SystemTableInfo->SmbiosTableBase, SystemT= ableInfo->SmbiosTableSize) !=3D EFI_SUCCESS) {=0D + Status =3D gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VO= ID *)(UINTN)SystemTableInfo->SmbiosTableBase);=0D + ASSERT_EFI_ERROR (Status);=0D + }=0D }=0D =0D //=0D diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/Bl= SupportDxe/BlSupportDxe.h index 512105fafd..a5216cd2e9 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h @@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D #include =0D =0D +#include =0D +=0D #include =0D #include =0D #include =0D @@ -26,5 +28,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D =0D #include =0D +#include =0D =0D #endif=0D diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/= BlSupportDxe/BlSupportDxe.inf index cebc811355..d26a75248b 100644 --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf @@ -56,5 +56,8 @@ gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress=0D gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseSize=0D =0D +[Protocols]=0D + gEfiSmbiosProtocolGuid=0D +=0D [Depex]=0D - TRUE=0D + gEfiSmbiosProtocolGuid=0D --=20 2.26.2