From nobody Mon Nov 25 12:25:21 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+70312+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+70312+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1610642225; cv=none; d=zohomail.com; s=zohoarc; b=J/1sc/R6TUTM4Gt49igR6LSukmLVTv87iSKXgdMbLdiVNxC1p+NsD7ufpvdfjRRt1Odc33WZODfBXdDnJ3jKEE38mHGsqGbJIbrkMbOwf/9LIyD36ZqzbNh6uhqAEn1GGO4gAIQoo25J9Mvuk93wFGH9BfH+N0u5ayG6KPpBmNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610642225; 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=H7598TcowWj0ZydrmQaazUjVifsA+oiMKYsg7EOHYSg=; b=GYSZnVko07VCSzajcHgJN1fZt8DfObDTdhe6UnMoC5Ouaf8Rg1whKQwtHnUfNkxfUA9WTkprphgVKCFTD1bvS17GKnqbAA9mLm53pNK2k7vh+jjtbmxyewhdbEHyNOVG50cgbEmph5p9cWu0vUacFhxLEYGZ7KpzJXVIIfL9eYE= 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+70312+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610642225434422.06756468852404; Thu, 14 Jan 2021 08:37:05 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Kf1WYY1788612xnOOGXNeKyj; Thu, 14 Jan 2021 08:37:04 -0800 X-Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by mx.groups.io with SMTP id smtpd.web12.4181.1610642220837674537 for ; Thu, 14 Jan 2021 08:37:00 -0800 X-Received: by mail-io1-f54.google.com with SMTP id r9so12347988ioo.7 for ; Thu, 14 Jan 2021 08:37:00 -0800 (PST) X-Gm-Message-State: AbEw55qCY9bqtM981vU7TokDx1787277AA= X-Google-Smtp-Source: ABdhPJxK1Tw5KW4rXHyvx0O/AYpFJ+SQ5LYyLYLvzaGdm1RlI/yo1L+zjYlePqhSwrCYtgFinBidlA== X-Received: by 2002:a05:6638:2192:: with SMTP id s18mr1673002jaj.18.1610642219886; Thu, 14 Jan 2021 08:36:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 08:36:59 -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 17/22] ArmPkg: Add Universal/Smbios/SmbiosMiscDxe/Type02 Date: Thu, 14 Jan 2021 09:36:23 -0700 Message-Id: <20210114163628.31952-18-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=1610642224; bh=sdgkWZcz9x9pzcFOfaTm4PXG1Swv8majG64Ca0UtK6Y=; h=Cc:Date:From:Reply-To:Subject:To; b=eO11d14JDhY5whBEzyT0UPGXYPus/fH2nrEvxnvWVIrbW64PADEF7w3NXYVaVQM1IZm GY7mkleUI6ANcRs+42TyCEgzuAYpF3kpY5ve1M166c+JL41n2xYY2euJXRAk6elWw596z SzwW6WfwHCinNkrLXdR4YexWeuO1iODj7sA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This code provides information for the SMBIOS Type 2 table. Signed-off-by: Rebecca Cran Reviewed-by: Leif Lindholm Reviewed-by: Samer El-Haj-Mahmoud --- ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManufacturerData= .c | 46 ++++ ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManufacturerFunc= tion.c | 230 ++++++++++++++++++++ ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManufacturer.uni= | 20 ++ 3 files changed, 296 insertions(+) diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManu= facturerData.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoard= ManufacturerData.c new file mode 100644 index 000000000000..dfe1f2d45b92 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManufacture= rData.c @@ -0,0 +1,46 @@ +/** @file + + This file provide OEM to define Smbios Type2 Data + + Based on 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) Chassis Manufacturer data. +// +SMBIOS_MISC_TABLE_DATA(SMBIOS_TABLE_TYPE2, MiscBaseBoardManufacturer) =3D { + { // Hdr + EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, // Type, + 0, // Length, + 0 // Handle + }, + 1, // BaseBoardManu= facturer + 2, // BaseBoardProd= uctName + 3, // BaseBoardVers= ion + 4, // BaseBoardSeri= alNumber + 5, // BaseBoardAsse= tTag + { // FeatureFlag + 1, // Motherboard = :1 + 0, // RequiresDaugh= terCard :1 + 0, // Removable = :1 + 1, // Replaceable = :1 + 0, // HotSwappable = :1 + 0 // Reserved = :3 + }, + 6, // BaseBoardChas= sisLocation + 0, // ChassisHandle; + BaseBoardTypeMotherBoard, // BoardType; + 0, // NumberOfConta= inedObjectHandles; + { + 0 + } // ContainedObje= ctHandles[1]; +}; diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManu= facturerFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseB= oardManufacturerFunction.c new file mode 100644 index 000000000000..097777a23904 --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManufacture= rFunction.c @@ -0,0 +1,230 @@ +/** @file + This driver parses the mSmbiosMiscDataTable structure and reports + any generated data using SMBIOS protocol. + + Based on files under Nt32Pkg/MiscSubClassPlatformDxe/ + + Copyright (c) 2021, NUVIA Inc. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 + +#include "SmbiosMisc.h" + + +/** + This function makes boot time changes to the contents of the + MiscBaseBoardManufacturer (Type 2) 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(MiscBaseBoardManufacturer) +{ + CHAR8 *OptionalStrStart; + CHAR8 *StrStart; + UINTN RecordLength; + UINTN ManuStrLen; + UINTN ProductNameStrLen; + UINTN VerStrLen; + UINTN SerialNumStrLen; + UINTN AssetTagStrLen; + UINTN ChassisLocaStrLen; + UINTN HandleCount; + UINT16 *HandleArray; + CHAR16 *BaseBoardManufacturer; + CHAR16 *BaseBoardProductName; + CHAR16 *Version; + EFI_STRING SerialNumber; + EFI_STRING AssetTag; + EFI_STRING ChassisLocation; + EFI_STRING_ID TokenToGet; + SMBIOS_TABLE_TYPE2 *SmbiosRecord; + SMBIOS_TABLE_TYPE2 *InputData; + EFI_STATUS Status; + + EFI_STRING_ID TokenToUpdate; + + HandleCount =3D 0; + HandleArray =3D NULL; + InputData =3D NULL; + + // + // First check for invalid parameters. + // + if (RecordData =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + InputData =3D (SMBIOS_TABLE_TYPE2*)RecordData; + + BaseBoardManufacturer =3D (CHAR16 *) PcdGetPtr (PcdBaseBoardManufacturer= ); + if (StrLen (BaseBoardManufacturer) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, BaseBoardManufactur= er, NULL); + } + + BaseBoardProductName =3D (CHAR16 *) PcdGetPtr (PcdBaseBoardProductName); + if (StrLen (BaseBoardProductName) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, BaseBoardProductNam= e, NULL); + } + + Version =3D (CHAR16 *) PcdGetPtr (PcdBaseBoardVersion); + if (StrLen (Version) > 0) { + TokenToUpdate =3D STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION); + HiiSetString (mSmbiosMiscHiiHandle, TokenToUpdate, Version, NULL); + } + + OemUpdateSmbiosInfo (mSmbiosMiscHiiHandle, + STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG), + AssertTagType02 + ); + OemUpdateSmbiosInfo (mSmbiosMiscHiiHandle, + STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER), + SerialNumberType02 + ); + OemUpdateSmbiosInfo (mSmbiosMiscHiiHandle, + STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER), + BoardManufacturerType02 + ); + OemUpdateSmbiosInfo (mSmbiosMiscHiiHandle, + STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER), + SerialNumberType02 + ); + OemUpdateSmbiosInfo (mSmbiosMiscHiiHandle, + STRING_TOKEN (STR_MISC_BASE_BOARD_SKU_NUMBER), + SerialNumberType02 + ); + OemUpdateSmbiosInfo (mSmbiosMiscHiiHandle, + STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION), + ChassisLocationType02 + ); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_MANUFACTURER); + BaseBoardManufacturer =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenT= oGet, NULL); + ManuStrLen =3D StrLen (BaseBoardManufacturer); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME); + BaseBoardProductName =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenTo= Get, NULL); + ProductNameStrLen =3D StrLen (BaseBoardProductName); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_VERSION); + Version =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NULL); + VerStrLen =3D StrLen (Version); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_SERIAL_NUMBER); + SerialNumber =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NUL= L); + SerialNumStrLen =3D StrLen (SerialNumber); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG); + AssetTag =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, NULL); + AssetTagStrLen =3D StrLen (AssetTag); + + TokenToGet =3D STRING_TOKEN (STR_MISC_BASE_BOARD_CHASSIS_LOCATION); + ChassisLocation =3D HiiGetPackageString (&gEfiCallerIdGuid, TokenToGet, = NULL); + ChassisLocaStrLen =3D StrLen (ChassisLocation); + + // + // Two zeros following the last string. + // + RecordLength =3D sizeof (SMBIOS_TABLE_TYPE2) + + ManuStrLen + 1 + + ProductNameStrLen + 1 + + VerStrLen + 1 + + SerialNumStrLen + 1 + + AssetTagStrLen + 1 + + ChassisLocaStrLen + 1 + 1; + SmbiosRecord =3D AllocateZeroPool (RecordLength); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Exit; + } + + (VOID)CopyMem (SmbiosRecord, InputData, sizeof (SMBIOS_TABLE_TYPE2)); + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE2); + + // + // Update Contained objects Handle + // + SmbiosRecord->NumberOfContainedObjectHandles =3D 0; + SmbiosMiscGetLinkTypeHandle (EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, &HandleAr= ray, + &HandleCount); + // It's assumed there's at most a single chassis + ASSERT (HandleCount < 2); + if (HandleCount > 0) { + SmbiosRecord->ChassisHandle =3D HandleArray[0]; + } + + FreePool (HandleArray); + + OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); + UnicodeStrToAsciiStrS (BaseBoardManufacturer, OptionalStrStart, ManuStrL= en + 1); + + StrStart =3D OptionalStrStart + ManuStrLen + 1; + UnicodeStrToAsciiStrS (BaseBoardProductName, StrStart, ProductNameStrLen= + 1); + + StrStart +=3D ProductNameStrLen + 1; + UnicodeStrToAsciiStrS (Version, StrStart, VerStrLen + 1); + + StrStart +=3D VerStrLen + 1; + UnicodeStrToAsciiStrS (SerialNumber, StrStart, SerialNumStrLen + 1); + + StrStart +=3D SerialNumStrLen + 1; + UnicodeStrToAsciiStrS (AssetTag, StrStart, AssetTagStrLen + 1); + + StrStart +=3D AssetTagStrLen + 1; + UnicodeStrToAsciiStrS (ChassisLocation, StrStart, ChassisLocaStrLen + 1); + + Status =3D SmbiosMiscAddRecord ((UINT8 *)SmbiosRecord, NULL); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "[%a]:[%dL] Smbios Type02 Table Log Failed! %r \n= ", + __FUNCTION__, __LINE__, Status)); + } + + FreePool (SmbiosRecord); + +Exit: + if (BaseBoardManufacturer !=3D NULL) { + FreePool (BaseBoardManufacturer); + } + + if (BaseBoardProductName !=3D NULL) { + FreePool (BaseBoardProductName); + } + + if (Version !=3D NULL) { + FreePool (Version); + } + + if (SerialNumber !=3D NULL) { + FreePool (SerialNumber); + } + + if (AssetTag !=3D NULL) { + FreePool (AssetTag); + } + + if (ChassisLocation !=3D NULL) { + FreePool (ChassisLocation); + } + + return 0; +} diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManu= facturer.uni b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardMa= nufacturer.uni new file mode 100644 index 000000000000..0f0fb1f93bbb --- /dev/null +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type02/MiscBaseBoardManufacture= r.uni @@ -0,0 +1,20 @@ +/** @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_BASE_BOARD_MANUFACTURER #language en-US "Not Specifi= ed" +#string STR_MISC_BASE_BOARD_PRODUCT_NAME #language en-US "Not Specifi= ed" +#string STR_MISC_BASE_BOARD_VERSION #language en-US "Not Specifi= ed" +#string STR_MISC_BASE_BOARD_SERIAL_NUMBER #language en-US "Not Specifi= ed" +#string STR_MISC_BASE_BOARD_ASSET_TAG #language en-US "Not Specifi= ed" +#string STR_MISC_BASE_BOARD_CHASSIS_LOCATION #language en-US "Not Specifi= ed" +#string STR_MISC_BASE_BOARD_SKU_NUMBER #language en-US "Not Specifi= ed" --=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 (#70312): https://edk2.groups.io/g/devel/message/70312 Mute This Topic: https://groups.io/mt/79679262/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-