From nobody Sat Nov 2 14:30:34 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1484031407079501.8178429606079; Mon, 9 Jan 2017 22:56:47 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 69CE681B31; Mon, 9 Jan 2017 22:56:45 -0800 (PST) Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B23DD817B4 for ; Mon, 9 Jan 2017 22:56:43 -0800 (PST) Received: from AIA2PHNNRN.local (unknown [16.214.90.9]) by g2t2352.austin.hpe.com (Postfix) with SMTP id 338474D; Tue, 10 Jan 2017 06:56:43 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org Date: Tue, 10 Jan 2017 00:56:43 -0600 From: Chris Phillips To: edk2-devel@lists.01.org; Message-ID: X-Mailer: TortoiseGit MIME-Version: 1.0 Subject: [edk2] [PATCH] Nt32Pkg: Fixes to correctly set SMBIOS Type 3 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ruiyu.ni@intel.com, Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 X-Zoho-Virus-Status: 2 X-ZM-MESSAGEID: 226431000000902267 Content-Type: text/plain; charset="utf-8" When running Nt32Pkg, SMBIOS Type 3 was missing Height, NumberofPowerCords,= and SKU Number. Also, ContainedElements was not being handled correctly. Fixed code to add example data, correct some variable names (Assert -> Asse= t), and properly handle setting the Type 3 values. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chris Phillips --- .../MiscChassisManufacturerData.c | 5 +- .../MiscChassisManufacturerFunction.c | 74 ++++++++++++++++++= ---- .../MiscSubClassPlatformDxe/MiscSubclassDriver.uni | 2 + 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c = b/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c index 4fbf5de028..cbf90e9c03 100644 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerData.c @@ -1,6 +1,7 @@ /**@file =20 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP
This program and the accompanying materials =20 are licensed and made available under the terms and conditions of the BSD = License =20 which accompanies this distribution. The full text of the license may be = found at =20 @@ -39,7 +40,9 @@ MISC_SMBIOS_TABLE_DATA(EFI_MISC_CHASSIS_MANUFACTURER_DATA= , MiscChassisManufactur EfiChassisStateOther, // ChassisPowerSupplyState EfiChassisStateOther, // ChassisThermalState EfiChassisSecurityStatusOther, // ChassisSecurityState - 0 // ChassisOemDefined + 0, // ChassisOemDefined + 1, // Height + 1 // NumberofPowerCords }; =20 /* eof - MiscChassisManufacaturerData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunctio= n.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c index c7f65ea830..c41e86aead 100644 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c @@ -3,6 +3,7 @@ SMBIOS type 3. =20 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -31,17 +32,20 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) CHAR8 *OptionalStrStart; UINTN ManuStrLen; UINTN VerStrLen; - UINTN AssertTagStrLen; + UINTN AssetTagStrLen; UINTN SerialNumStrLen; + UINTN SkuNumberStrLen; EFI_STATUS Status; EFI_STRING Manufacturer; EFI_STRING Version; EFI_STRING SerialNumber; - EFI_STRING AssertTag; + EFI_STRING AssetTag; + EFI_STRING SkuNumber; STRING_REF TokenToGet; EFI_SMBIOS_HANDLE SmbiosHandle; SMBIOS_TABLE_TYPE3 *SmbiosRecord; EFI_MISC_CHASSIS_MANUFACTURER *ForType3InputData; + UINT8 *Buffer; =20 ForType3InputData =3D (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData; =20 @@ -74,20 +78,40 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) } =20 TokenToGet =3D STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG); - AssertTag =3D HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - AssertTagStrLen =3D StrLen(AssertTag); - if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) { + AssetTag =3D HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); + AssetTagStrLen =3D StrLen(AssetTag); + if (AssetTagStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + TokenToGet =3D STRING_TOKEN (STR_MISC_CHASSIS_SKU_NUMBER); + SkuNumber =3D HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); + SkuNumberStrLen =3D StrLen(SkuNumber); + if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } =20 // // Two zeros following the last string. // - SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen += 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + Ve= rStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); + // Since we set ContainedElementCount =3D 0 and ContainedElementRecordLe= ngth =3D 0, + // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. + // + // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained = in SMBIOS_TABLE_TYPE3. + // + SmbiosRecord =3D AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONT= AINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen = + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + SkuNumberStrLen + 1 + 1); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_EL= EMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen + 1 + S= erialNumStrLen + 1 + AssetTagStrLen + 1 + SkuNumberStrLen + 1 + 1); + + Buffer =3D (UINT8 *) SmbiosRecord; =20 SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE; - SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE3); + // + // Since we set ContainedElementCount =3D 0 and ContainedElementRecordLe= ngth =3D 0, + // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. + // + // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained = in SMBIOS_TABLE_TYPE3. + // + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTA= INED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING); // // Make handle chosen by smbios protocol.add automatically. // @@ -106,20 +130,42 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) // SmbiosRecord->SerialNumber =3D 3; =20 // - // AssertTag will be the 4th optional string following the formatted str= ucture. + // AssetTag will be the 4th optional string following the formatted stru= cture. // - SmbiosRecord->AssetTag =3D 4; =20 + SmbiosRecord->AssetTag =3D 4; + SmbiosRecord->BootupState =3D (UINT8)ForType3InputData->ChassisBootupSta= te; SmbiosRecord->PowerSupplyState =3D (UINT8)ForType3InputData->ChassisPowe= rSupplyState; SmbiosRecord->ThermalState =3D (UINT8)ForType3InputData->ChassisThermalS= tate; SmbiosRecord->SecurityStatus =3D (UINT8)ForType3InputData->ChassisSecuri= tyState; CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOem= Defined, 4); + SmbiosRecord->Height =3D (UINT8)ForType3InputData->ChassisHeight; + SmbiosRecord->NumberofPowerCords =3D (UINT8)ForType3InputData->ChassisNu= mberPowerCords; + SmbiosRecord->ContainedElementCount =3D 0; + SmbiosRecord->ContainedElementRecordLength =3D 0; + + // + // SKU Number will be the 5th optional string following the formatted st= ructure. + // + // Since SKU Number is not in SMBIOS_TABLE_TYPE3 structure, must locate = it after ContainedElementRecordLength. + // + Buffer[sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT)] =3D 5; =20 OptionalStrStart =3D (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + V= erStrLen + 1); - UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerS= trLen + 1 + SerialNumStrLen + 1); + // + // Since we set ContainedElementCount =3D 0 and ContainedElementRecordLe= ngth =3D 0, + // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. + // + OptionalStrStart -=3D sizeof (CONTAINED_ELEMENT); + // + // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained = in SMBIOS_TABLE_TYPE3. + // + OptionalStrStart +=3D sizeof (SMBIOS_TABLE_STRING); + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); + UnicodeStrToAsciiStr (Version, OptionalStrStart + ManuStrLen + 1); + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart + ManuStrLen + 1 + = VerStrLen + 1); + UnicodeStrToAsciiStr (AssetTag, OptionalStrStart + ManuStrLen + 1 + VerS= trLen + 1 + SerialNumStrLen + 1); + UnicodeStrToAsciiStr (SkuNumber, OptionalStrStart + ManuStrLen + 1 + Ver= StrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1); =20 // // Now we have got the full smbios record, call smbios protocol to add t= his record. diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni b/Nt32P= kg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni index df197b12d3..6d6a0b7f07 100644 --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni @@ -1,6 +1,7 @@ // *++ // // Copyright (c) 2006, Intel Corporation. All rights reserved.
+// (C) Copyright 2017 Hewlett Packard Enterprise Development LP
// This program and the accompanying materials =20 // are licensed and made available under the terms and conditions of the B= SD License =20 // which accompanies this distribution. The full text of the license may = be found at =20 @@ -45,6 +46,7 @@ #string STR_MISC_CHASSIS_VERSION #language en-US "Chassis Version" #string STR_MISC_CHASSIS_SERIAL_NUMBER #language en-US "Chassis Serial Nu= mber" #string STR_MISC_CHASSIS_ASSET_TAG #language en-US "Chassis Asset Tag" +#string STR_MISC_CHASSIS_SKU_NUMBER #language en-US "Chassis SKU Numbe= r" =20 #string STR_MISC_OEM_STRING #language en-US "System Language S= tring" =20 --=20 2.11.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel