From nobody Mon Nov 25 12:20:41 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+70310+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+70310+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610642223; cv=none; d=zohomail.com; s=zohoarc; b=DTO3TMU03iVNnRWRyySDuJx0mr8llYxmYZHqO6x/P33l1OdlWZzC6cT/gTvXKlEyzwguVOsZUF8f+EQ9fLXgLRXeyAox2PKVgwLTV8Tbb3eDiGy9dODn5a+ymJkwNCVglHKEcJyYa2qcMx8QXkcKCm14HOTqhUoooZWyU1gS5DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610642223; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=KFelStcv8cTPmOoet9c5zvWqbbUU2Qk9eeQ38XMR3Ug=; b=bRbuVwMgk7mVpTn4OrjqUnCRaz94zpFe72Gjk8bBZsF2Eacm6epWjRnmo420OI0k3q2jfVuQlFLXq3tDwbDGgJ29hX/L/MF6tA3HhZkeGL2RYUkBqMV6LzbIXsGBVrnkY7B4NOfxwKSvsWX2DskW+U4C05arBMH2fjQTSLzhp3M= 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+70310+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610642223736274.65487642151174; Thu, 14 Jan 2021 08:37:03 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id wCkhYY1788612xiYPvNj9evG; Thu, 14 Jan 2021 08:37:03 -0800 X-Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by mx.groups.io with SMTP id smtpd.web11.4160.1610642217851414217 for ; Thu, 14 Jan 2021 08:36:57 -0800 X-Received: by mail-io1-f49.google.com with SMTP id e22so12359462iom.5 for ; Thu, 14 Jan 2021 08:36:57 -0800 (PST) X-Gm-Message-State: dRf1BrfvfeAGgh97qMD0Oa5qx1787277AA= X-Google-Smtp-Source: ABdhPJwVCYbV/jcSyT8sGZSo40WZFK7H6oDeqTLRTHsnogFvJaO8q+XJZ1uzXLFRF/Fgwevz6XRtjQ== X-Received: by 2002:a5d:96c5:: with SMTP id r5mr5710739iol.62.1610642216794; Thu, 14 Jan 2021 08:36:56 -0800 (PST) X-Received: from cube.nuviainc.com (c-174-52-16-57.hsd1.ut.comcast.net. [174.52.16.57]) by smtp.gmail.com with ESMTPSA id y5sm3711920ilj.35.2021.01.14.08.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 08:36:56 -0800 (PST) From: "Rebecca Cran" To: devel@edk2.groups.io Cc: Rebecca Cran , Leif Lindholm , Ard Biesheuvel , nd@arm.com, Sami Mujawar , Liming Gao , Michael D Kinney , Zhiguang Liu Subject: [edk2-devel] [PATCH v6 15/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type00 Date: Thu, 14 Jan 2021 09:36:21 -0700 Message-Id: <20210114163628.31952-16-rebecca@nuviainc.com> In-Reply-To: <20210114163628.31952-1-rebecca@nuviainc.com> References: <20210114163628.31952-1-rebecca@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,rebecca@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610642223; bh=srzdvu2eAftjKdQMkRwrkhze1dFlbkfN4AGDBhpixKs=; h=Cc:Date:From:Reply-To:Subject:To; b=SAjZISEqnznsoBRBK/LVsuqR2ACYT/VnnRiomMEWQY+Me8S4jx1+npe/BtjZN5e335m AoowYMRkA9VPSqG9xgMlazVtXhQEyMvj/01tOzS00PO88lx34ZEaWELgz6RUEjDolfOIf C1Y6W6+7O3SpGRhgkPwOdTHERHFqr9U7yvE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This code provides information for the SMBIOS Type 0 table. Signed-off-by: Rebecca Cran Reviewed-by: Leif Lindholm Reviewed-by: Samer El-Haj-Mahmoud --- ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorData.c | 9= 3 ++++++ ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c | 29= 7 ++++++++++++++++++++ ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendor.uni | 1= 8 ++ 3 files changed, 408 insertions(+) diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorDat= a.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorData.c new file mode 100644 index 000000000000..edf0186aeae8 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorData.c @@ -0,0 +1,93 @@ +/** @file + This file provides Smbios Type0 Data + + Based on the files under Nt32Pkg/MiscSubClassPlatformDxe/ + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + + +#include "SmbiosMisc.h" + + +// +// Static (possibly build generated) Bios Vendor data. +// +SMBIOS_MISC_TABLE_DATA(SMBIOS_TABLE_TYPE0, MiscBiosVendor) =3D { + { // Hdr + EFI_SMBIOS_TYPE_BIOS_INFORMATION, // Type, + 0, // Length, + 0 // Handle + }, + 1, // Vendor + 2, // BiosVersion + 0xE000, // BiosSegment + 3, // BiosReleaseDate + 0, // BiosSize + { // BiosCharacteristics + 0, // Reserved = :2 + 0, // Unknown = :1 + 0, // BiosCharacteristicsNotSu= pported :1 + 0, // IsaIsSupported = :1 + 0, // McaIsSupported = :1 + 0, // EisaIsSupported = :1 + 1, // PciIsSupported = :1 + 0, // PcmciaIsSupported = :1 + 1, // PlugAndPlayIsSupported = :1 + 0, // ApmIsSupported = :1 + 1, // BiosIsUpgradable = :1 + 1, // BiosShadowingAllowed = :1 + 0, // VlVesaIsSupported = :1 + 0, // EscdSupportIsAvailable = :1 + 1, // BootFromCdIsSupported = :1 + 1, // SelectableBootIsSupporte= d :1 + 0, // RomBiosIsSocketed = :1 + 0, // BootFromPcmciaIsSupporte= d :1 + 0, // EDDSpecificationIsSuppor= ted :1 + 0, // JapaneseNecFloppyIsSuppo= rted :1 + 0, // JapaneseToshibaFloppyIsS= upported :1 + 0, // Floppy525_360IsSupported= :1 + 0, // Floppy525_12IsSupported = :1 + 0, // Floppy35_720IsSupported = :1 + 0, // Floppy35_288IsSupported = :1 + 0, // PrintScreenIsSupported = :1 + 0, // Keyboard8042IsSupported = :1 + 0, // SerialIsSupported = :1 + 0, // PrinterIsSupported = :1 + 0, // CgaMonoIsSupported = :1 + 0, // NecPc98 = :1 + 0 // ReservedForVendor = :32 + }, + + { + 0x01, // BIOSCharacteristicsExt= ensionBytes[0] + // { // BiosReserved + // 1, // AcpiIsSupported = :1 + // 0, // UsbLegacyIsSupport= ed :1 + // 0, // AgpIsSupported = :1 + // 0, // I20BootIsSupported= :1 + // 0, // Ls120BootIsSupport= ed :1 + // 0, // AtapiZipDriveBootI= sSupported :1 + // 0, // Boot1394IsSupporte= d :1 + // 0 // SmartBatteryIsSupp= orted :1 + // }, + 0x0C //BIOSCharacteristicsExte= nsionBytes[1] + // { //SystemReserved + // 0, //BiosBootSpecIsSuppo= rted :1 + // 0, //FunctionKeyNetworkB= ootIsSupported :1 + // 1, //TargetContentDistri= butionEnabled :1 + // 1, //UefiSpecificationSu= pported :1 + // 0, //VirtualMachineSuppo= rted :1 + // 0 //ExtensionByte2Reser= ved :3 + // }, + }, + 0xFF, // SystemBiosMajorRelease; + 0xFF, // SystemBiosMinorRelease; + 0xFF, // EmbeddedControllerFirmwareM= ajorRelease; + 0xFF // EmbeddedControllerFirmwareM= inorRelease; +}; diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFun= ction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFuncti= on.c new file mode 100644 index 000000000000..dd8d062d4903 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendorFunction.c @@ -0,0 +1,297 @@ +/** @file + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +#include "SmbiosMisc.h" + + +typedef struct { + CONST CHAR8* MonthStr; + UINT32 MonthInt; +} MONTH_DESCRIPTION; + +STATIC CONST +MONTH_DESCRIPTION mMonthDescription[] =3D { + { "Jan", 1 }, + { "Feb", 2 }, + { "Mar", 3 }, + { "Apr", 4 }, + { "May", 5 }, + { "Jun", 6 }, + { "Jul", 7 }, + { "Aug", 8 }, + { "Sep", 9 }, + { "Oct", 10 }, + { "Nov", 11 }, + { "Dec", 12 }, + { "???", 1 }, // Use 1 as default month +}; + +/** + Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with = '64k' + as the unit. + + @param Value Pointer to Base2_Data + + @retval + +**/ +UINT8 +Base2ToByteWith64KUnit ( + IN UINTN Value + ) +{ + UINT8 Size; + + Size =3D ((Value + (SIZE_64KB - 1)) >> 16); + + return Size; +} + +/** + Returns the date and time this file (and firmware) was built. + + @param[out] *Time Pointer to the EFI_TIME structure to fill in. +**/ +VOID +GetReleaseTime ( + OUT EFI_TIME *Time + ) +{ + CONST CHAR8 *ReleaseDate =3D __DATE__; + CONST CHAR8 *ReleaseTime =3D __TIME__; + UINTN i; + + for (i =3D 0; i < 12; i++) { + if (AsciiStrnCmp (ReleaseDate, mMonthDescription[i].MonthStr, 3) =3D= =3D 0) { + break; + } + } + + Time->Month =3D mMonthDescription[i].MonthInt; + Time->Day =3D AsciiStrDecimalToUintn (ReleaseDate + 4); + Time->Year =3D AsciiStrDecimalToUintn (ReleaseDate + 7); + Time->Hour =3D AsciiStrDecimalToUintn (ReleaseTime); + Time->Minute =3D AsciiStrDecimalToUintn (ReleaseTime + 3); + Time->Second =3D AsciiStrDecimalToUintn (ReleaseTime + 6); +} + +/** + Fetches the firmware ('BIOS') release date from the + FirmwareVersionInfo HOB. + + @return The release date as a UTF-16 string +**/ +CHAR16 * +GetBiosReleaseDate ( + VOID + ) +{ + CHAR16 *ReleaseDate; + EFI_TIME BuildTime; + + ReleaseDate =3D AllocateZeroPool ((sizeof (CHAR16)) * SMBIOS_STRING_MAX_= LENGTH); + if (ReleaseDate =3D=3D NULL) { + return NULL; + } + + GetReleaseTime (&BuildTime); + + (VOID)UnicodeSPrintAsciiFormat (ReleaseDate, + (sizeof (CHAR16)) * SMBIOS_STRING_MAX_LENGTH, + "%02d/%02d/%4d", + BuildTime.Month, + BuildTime.Day, + BuildTime.Year + ); + + return ReleaseDate; +} + +/** + Fetches the firmware ('BIOS') version from the + FirmwareVersionInfo HOB. + + @return The version as a UTF-16 string +**/ +CHAR16 * +GetBiosVersion ( + VOID + ) +{ + CHAR16 *ReleaseString; + + ReleaseString =3D + (CHAR16 *)FixedPcdGetPtr (PcdFirmwareVersionString); + + return ReleaseString; +} + + +/** + This function makes boot time changes to the contents of the + MiscBiosVendor (Type 0) record. + + @param RecordData Pointer to SMBIOS table with default = values. + @param Smbios SMBIOS protocol. + + @retval EFI_SUCCESS The SMBIOS table was successfully add= ed. + @retval EFI_INVALID_PARAMETER Invalid parameter was found. + @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory. + +**/ +SMBIOS_MISC_TABLE_FUNCTION (MiscBiosVendor) +{ + CHAR8 *OptionalStrStart; + CHAR8 *StrStart; + UINTN VendorStrLen; + UINTN VerStrLen; + UINTN DateStrLen; + UINTN BiosPhysicalSize; + CHAR16 *Vendor; + CHAR16 *Version; + CHAR16 *ReleaseDate; + CHAR16 *Char16String; + EFI_STATUS Status; + EFI_STRING_ID TokenToUpdate; + EFI_STRING_ID TokenToGet; + SMBIOS_TABLE_TYPE0 *SmbiosRecord; + SMBIOS_TABLE_TYPE0 *InputData; + + // + // First check for invalid parameters. + // + if (RecordData =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + InputData =3D (SMBIOS_TABLE_TYPE0 *)RecordData; + + Vendor =3D (CHAR16 *) PcdGetPtr (PcdFirmwareVendor); + + if (StrLen (Vendor) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BIOS_VENDOR); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Vendor, NULL); + } + + Version =3D GetBiosVersion(); + + if (StrLen (Version) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BIOS_VERSION); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL); + } else { + Version =3D (CHAR16 *) PcdGetPtr (PcdFirmwareVersionString); + if (StrLen (Version) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BIOS_VERSION); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL); + } + } + + Char16String =3D GetBiosReleaseDate (); + if (StrLen(Char16String) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Char16String, NULL); + } + + TokenToGet =3D STRING_TOKEN (STR_MISC_BIOS_VENDOR); + Vendor =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NULL); + VendorStrLen =3D StrLen (Vendor); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BIOS_VERSION); + Version =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NULL); + VerStrLen =3D StrLen (Version); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE); + ReleaseDate =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NULL= ); + DateStrLen =3D StrLen (ReleaseDate); + + // + // Now update the BiosPhysicalSize + // + BiosPhysicalSize =3D FixedPcdGet32 (PcdFdSize); + + // + // Two zeros following the last string. + // + SmbiosRecord =3D AllocateZeroPool (sizeof (SMBIOS_TABLE_TYPE0) + VendorS= trLen + 1 + + VerStrLen + 1 + + DateStrLen + 1 + 1); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + (VOID)CopyMem (SmbiosRecord, InputData, sizeof (SMBIOS_TABLE_TYPE0)); + + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE0); + SmbiosRecord->BiosSegment =3D (UINT16)(FixedPcdGet32 (PcdFdBaseAddress) = / SIZE_64KB); + if (BiosPhysicalSize < SIZE_16MB) { + SmbiosRecord->BiosSize =3D Base2ToByteWith64KUnit (BiosPhysicalSize) -= 1; + SmbiosRecord->ExtendedBiosSize.Size =3D BiosPhysicalSize / SIZE_1MB; + SmbiosRecord->ExtendedBiosSize.Unit =3D 0; // Size is in MB + } else { + SmbiosRecord->BiosSize =3D 0xFF; + if (BiosPhysicalSize > 0x3FFF) { + SmbiosRecord->ExtendedBiosSize.Size =3D BiosPhysicalSize / SIZE_1GB; + SmbiosRecord->ExtendedBiosSize.Unit =3D 1; // Size is in GB + } + } + + SmbiosRecord->SystemBiosMajorRelease =3D (UINT8) (PcdGet16 (PcdSystemBio= sRelease) >> 8); + SmbiosRecord->SystemBiosMinorRelease =3D (UINT8) (PcdGet16 (PcdSystemBio= sRelease) & 0xFF); + + SmbiosRecord->EmbeddedControllerFirmwareMajorRelease =3D (UINT16) + (PcdGet16 (PcdEmbeddedControllerFirmwareRelease) >> 8); + SmbiosRecord->EmbeddedControllerFirmwareMinorRelease =3D (UINT16) + (PcdGet16 (PcdEmbeddedControllerFirmwareRelease) & 0xFF); + + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStrS (Vendor, OptionalStrStart, VendorStrLen + 1); + StrStart =3D OptionalStrStart + VendorStrLen + 1; + UnicodeStrToAsciiStrS (Version, StrStart, VerStrLen + 1); + StrStart +=3D VerStrLen + 1; + UnicodeStrToAsciiStrS (ReleaseDate, StrStart, DateStrLen + 1); + // + // Now we have got the full smbios record, call smbios protocol to add t= his record. + // + Status =3D SmbiosMiscAddRecord ((UINT8*)SmbiosRecord, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Smbios Type00 Table Log Failed! %r = \n", + __FUNCTION__, __LINE__, Status)); + } + + FreePool (SmbiosRecord); + +Exit: + if (Vendor !=3D NULL) { + FreePool (Vendor); + } + + if (Version !=3D NULL) { + FreePool (Version); + } + + if (ReleaseDate !=3D NULL) { + FreePool (ReleaseDate); + } + + if (Char16String !=3D NULL) { + FreePool (Char16String); + } + + return Status; +} diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendor.un= i b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendor.uni new file mode 100644 index 000000000000..a3f068cdcca2 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type00/MiscBiosVendor.uni @@ -0,0 +1,18 @@ +/** @file + Based on files under Nt32Pkg/MiscSubClassPlatformDxe/ + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+ Copyright (c) 2015, Hisilicon Limited. All rights reserved.
+ Copyright (c) 2015, Linaro Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +/=3D# + +#string STR_MISC_BIOS_VENDOR #language en-US "Not Specified" +#string STR_MISC_BIOS_VERSION #language en-US "Not Specified" +#string STR_MISC_BIOS_RELEASE_DATE #language en-US "Not Specified" +#string STR_MISC_BIOS_VENDOR #language en-US "Not Specified" +#string STR_MISC_BIOS_RELEASE_DATE #language en-US "12/02/2020" --=20 2.26.2 -=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 (#70310): https://edk2.groups.io/g/devel/message/70310 Mute This Topic: https://groups.io/mt/79679257/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-