From nobody Sun Nov 24 14:35:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86272+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86272+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1643708080; cv=none; d=zohomail.com; s=zohoarc; b=fzVkByUrO9wCHMFo4Ohamkofkhf7oqbY+n5dDjJcO9eFtLWfrBce8lns1ZmrQiEwpzz/0SL2iNViWyOPC6/ZX1h8fcdntJQH1AUW3uoeY60LGWRha9s7m4XtlWn50BD65ua304HBmQ/As2eaDatyRyErUp3oMTq8ERfSx2jUazE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643708080; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=cT3vJ/g6KFotp4EIuoNl3+cJVidLUqo73y1VIaqKrXk=; b=MNfzAJNMQ9jwsJh1AWDLmVG0LYjgTm17JTl6ec3qYNeqbTZSvq7uOjwWYCGMuITIFJl+4Du63d/2NbfpRaJ0TfV0rbpSy1iRVAAZAoUkxRHpdpaCaVv4SyFaqciluwZ7xCu3FQgTFxCF2wMfDe4bJZm4q2ql6WOCDjD1dcCxHj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86272+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1643708080185600.9137563457565; Tue, 1 Feb 2022 01:34:40 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id iFVpYY1788612xFTSy6k4J3Q; Tue, 01 Feb 2022 01:34:39 -0800 X-Received: from smarthost01b.ixn.mail.zen.net.uk (smarthost01b.ixn.mail.zen.net.uk [212.23.1.21]) by mx.groups.io with SMTP id smtpd.web09.46362.1643708072828325191 for ; Tue, 01 Feb 2022 01:34:33 -0800 X-Received: from [51.148.147.4] (helo=sean-StarBook.lan) by smarthost01b.ixn.mail.zen.net.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1nEpYU-0004gL-RC; Tue, 01 Feb 2022 09:34:30 +0000 From: "Sean Rhodes" To: devel@edk2.groups.io Cc: Sean Rhodes , Matt DeVillier Subject: [edk2-devel] [PATCH] MdeModulePkg/Frontpage: Get SMBIOS Data from table directly Date: Tue, 1 Feb 2022 09:34:29 +0000 Message-Id: MIME-Version: 1.0 X-Originating-smarthost01b-IP: [51.148.147.4] Feedback-ID: 51.148.147.4 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,sean@starlabs.systems X-Gm-Message-State: LNw7eS94ud9lZz08JWK6SrNrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1643708079; bh=sNErMlKQK7CKVvb7U6XpTOf6UuMLI2998hVRvAbhp0k=; h=Cc:Date:From:Reply-To:Subject:To; b=XgGPhKBxA4ECAxS0BU0Ppp0udp9Q1KwNc/eaRbcZm0Gw/014wAfPbARVK4lT6UzobyC AgDX14osGm8+U24ZE1fnTioYx036OTZZL9latNB7CP+iMf3Kyu/mYhnw1PGrS8qhr0EeX sa9HExDKt9Rth+jmbCAqa0oWotfA66JN9uQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1643708083099100001 Content-Type: text/plain; charset="utf-8" Gather information from SMBIOS table rather than getting it from the EFI SMBIOS protocol for coreboot builds. Signed-off-by: Matt DeVillier Signed-off-by: Sean Rhodes --- MdeModulePkg/Application/UiApp/FrontPage.c | 196 ++++++++++++++++++++- MdeModulePkg/Application/UiApp/UiApp.inf | 2 + MdeModulePkg/MdeModulePkg.dec | 2 + UefiPayloadPkg/UefiPayloadPkg.dsc | 6 + 4 files changed, 205 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Appl= ication/UiApp/FrontPage.c index cc9569e225..1a7182c4dc 100644 --- a/MdeModulePkg/Application/UiApp/FrontPage.c +++ b/MdeModulePkg/Application/UiApp/FrontPage.c @@ -293,7 +293,11 @@ InitializeFrontPage ( // // Updata Front Page banner strings // - UpdateFrontPageBannerStrings (); + if (FixedPcdGetBool (PcdCoreboot)) { + DirectUpdateFrontPageBannerStrings (); + } else { + UpdateFrontPageBannerStrings (); + } =20 // // Update front page menus. @@ -496,6 +500,55 @@ GetOptionalStringByIndex ( return EFI_SUCCESS; } =20 +UINT16 +SmbiosTableLength ( + SMBIOS_STRUCTURE_POINTER SmbiosTableN + ) +{ + CHAR8 *AChar; + UINT16 Length; + + AChar =3D (CHAR8 *)(SmbiosTableN.Raw + SmbiosTableN.Hdr->Length); + while ((*AChar !=3D 0) || (*(AChar + 1) !=3D 0)) { + AChar++; // stop at 00 - first 0 + } + + Length =3D (UINT16)((UINTN)AChar - (UINTN)SmbiosTableN.Raw + 2); // leng= th includes 00 + return Length; +} + +SMBIOS_STRUCTURE_POINTER +GetSmbiosTableFromType ( + SMBIOS_TABLE_ENTRY_POINT *SmbiosPoint, + UINT8 SmbiosType, + UINTN IndexTable + ) +{ + SMBIOS_STRUCTURE_POINTER SmbiosTableN; + UINTN SmbiosTypeIndex; + + SmbiosTypeIndex =3D 0; + SmbiosTableN.Raw =3D (UINT8 *)((UINTN)SmbiosPoint->TableAddress); + if (SmbiosTableN.Raw =3D=3D NULL) { + return SmbiosTableN; + } + + while ((SmbiosTypeIndex !=3D IndexTable) || (SmbiosTableN.Hdr->Type !=3D= SmbiosType)) { + if (SmbiosTableN.Hdr->Type =3D=3D SMBIOS_TYPE_END_OF_TABLE) { + SmbiosTableN.Raw =3D NULL; + return SmbiosTableN; + } + + if (SmbiosTableN.Hdr->Type =3D=3D SmbiosType) { + SmbiosTypeIndex++; + } + + SmbiosTableN.Raw =3D (UINT8 *)(SmbiosTableN.Raw + SmbiosTableLength (S= mbiosTableN)); + } + + return SmbiosTableN; +} + /** =20 Update the banner information for the Front Page based on Smbios informa= tion. @@ -662,6 +715,147 @@ UpdateFrontPageBannerStrings ( FreePool (NewString); } =20 +/** + + Update the banner information for the Front Page based on table. + +**/ +VOID +DirectUpdateFrontPageBannerStrings ( + VOID + ) +{ + CHAR16 *MemoryStr; + EFI_STATUS Status; + EFI_STRING_ID TokenToUpdate; + EFI_PHYSICAL_ADDRESS *Table; + SMBIOS_TABLE_ENTRY_POINT *EntryPoint; + SMBIOS_STRUCTURE_POINTER SmbiosTable; + UINT64 InstalledMemory; + + InstalledMemory =3D 0; + + // + // Update Front Page strings + // + Status =3D EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID *= *)&Table); + if (EFI_ERROR (Status) || (Table =3D=3D NULL)) { + } else { + EntryPoint =3D (SMBIOS_TABLE_ENTRY_POINT *)Table; + + SmbiosTable =3D GetSmbiosTableFromType (EntryPoint, EFI_SMBIOS_TYPE_BI= OS_INFORMATION, 0); + + if (SmbiosTable.Raw !=3D NULL) { + CHAR16 *FwVersion; + CHAR16 *FwDate; + CHAR16 *TmpBuffer; + UINT8 VersionIdx; + UINT8 DateIdx; + + TmpBuffer =3D AllocateZeroPool (0x60); + + VersionIdx =3D SmbiosTable.Type0->BiosVersion; + DateIdx =3D SmbiosTable.Type0->BiosReleaseDate; + + GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)SmbiosTable.Raw + Smbio= sTable.Hdr->Length), VersionIdx, &FwVersion); + GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)SmbiosTable.Raw + Smbio= sTable.Hdr->Length), DateIdx, &FwDate); + + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), L"FW: "); + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), FwVersion); + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), L" "); + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), FwDate); + + TokenToUpdate =3D STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, TmpBuffer,= NULL); + + FreePool (FwVersion); + FreePool (FwDate); + FreePool (TmpBuffer); + } + + SmbiosTable =3D GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_SYSTEM= _INFORMATION, 0); + + if (SmbiosTable.Raw !=3D NULL) { + CHAR16 *ProductName; + CHAR16 *Manufacturer; + CHAR16 *DeviceName; + CHAR16 *TmpBuffer; + UINT8 ProductIdx; + UINT8 ManIdx; + + TmpBuffer =3D AllocateZeroPool (0x60); + DeviceName =3D AllocateZeroPool (0x60); + + ProductIdx =3D SmbiosTable.Type1->ProductName; + ManIdx =3D SmbiosTable.Type1->Manufacturer; + + GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)SmbiosTable.Raw + Smbio= sTable.Hdr->Length), ProductIdx, &ProductName); + GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)SmbiosTable.Raw + Smbio= sTable.Hdr->Length), ManIdx, &Manufacturer); + + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), Manufacturer); + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), L" "); + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), ProductName); + + TokenToUpdate =3D STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, TmpBuffer,= NULL); + + FreePool (ProductName); + FreePool (Manufacturer); + FreePool (DeviceName); + FreePool (TmpBuffer); + } + + SmbiosTable =3D GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_PROCES= SOR_INFORMATION, 0); + if (SmbiosTable.Raw !=3D NULL) { + CHAR16 *ProcessorVersion; + CHAR16 *TmpBuffer; + UINT8 CpuIdx; + + TmpBuffer =3D AllocateZeroPool (0x60); + + CpuIdx =3D SmbiosTable.Type4->ProcessorVersion; + + GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)SmbiosTable.Raw + Smbio= sTable.Hdr->Length), CpuIdx, &ProcessorVersion); + StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), ProcessorVersion); + + // Trim leading spaces + while (TmpBuffer[0] =3D=3D 0x20) { + TmpBuffer =3D &TmpBuffer[1]; + } + + TokenToUpdate =3D STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, TmpBuffer,= NULL); + + FreePool (ProcessorVersion); + FreePool (TmpBuffer); + } + + SmbiosTable =3D GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_MEMORY= _ARRAY_MAPPED_ADDRESS, 0); + if (SmbiosTable.Raw !=3D NULL) { + if (SmbiosTable.Type19->StartingAddress !=3D 0xFFFFFFFF ) { + InstalledMemory +=3D RShiftU64 ( + SmbiosTable.Type19->EndingAddress - + SmbiosTable.Type19->StartingAddress + 1, + 10 + ); + } else { + InstalledMemory +=3D RShiftU64 ( + SmbiosTable.Type19->ExtendedEndingAddress - + SmbiosTable.Type19->ExtendedStartingAddress += 1, + 20 + ); + } + + // now update the total installed RAM size + ConvertMemorySizeToString ((UINT32)InstalledMemory, &MemoryStr); + TokenToUpdate =3D STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE); + HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, MemoryStr,= NULL); + + FreePool (MemoryStr); + } + } +} + /** This function will change video resolution and text mode according to defined setup mode or defined boot mode diff --git a/MdeModulePkg/Application/UiApp/UiApp.inf b/MdeModulePkg/Applic= ation/UiApp/UiApp.inf index 3b9e048851..21979c5a55 100644 --- a/MdeModulePkg/Application/UiApp/UiApp.inf +++ b/MdeModulePkg/Application/UiApp/UiApp.inf @@ -58,6 +58,7 @@ [Guids] gEfiIfrTianoGuid ## CONSUMES ## GUID (Exten= ded IFR Guid Opcode) gEfiIfrFrontPageGuid ## CONSUMES ## GUID + gEfiSmbiosTableGuid ## CONSUMES ## GUID =20 [Protocols] gEfiSmbiosProtocolGuid ## CONSUMES @@ -77,6 +78,7 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution ## CON= SUMES gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString ## CON= SUMES gEfiMdeModulePkgTokenSpaceGuid.PcdTestKeyUsed ## CON= SUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdCoreboot ## CON= SUMES =20 [UserExtensions.TianoCore."ExtraFiles"] UiAppExtra.uni diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 463e889e9a..e8565cf542 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1076,6 +1076,8 @@ # FALSE - UEFI Stack Guard will be disabled.
# @Prompt Enable UEFI Stack Guard. gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055 + # Build Type + gEfiMdeModulePkgTokenSpaceGuid.PcdCoreboot|FALSE|BOOLEAN|0x00000027 =20 [PcdsFixedAtBuild, PcdsPatchableInModule] ## Dynamic type PCD can be registered callback function for Pcd setting = action. diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 1ce96a51c1..636ab31b64 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -399,6 +399,12 @@ gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask | 0x1 !endif =20 +!if $(BOOTLOADER) =3D=3D "COREBOOT" + gEfiMdeModulePkgTokenSpaceGuid.PcdCoreboot|TRUE +!else + gEfiMdeModulePkgTokenSpaceGuid.PcdCoreboot|FALSE +!endif + [PcdsPatchableInModule.X64] gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER) gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER) --=20 2.32.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86272): https://edk2.groups.io/g/devel/message/86272 Mute This Topic: https://groups.io/mt/88828789/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-