From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 586F381B34 for ; Tue, 10 Jan 2017 02:06:26 -0800 (PST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP; 10 Jan 2017 02:06:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,343,1477983600"; d="scan'208";a="51280734" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga005.jf.intel.com with ESMTP; 10 Jan 2017 02:06:26 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 10 Jan 2017 02:06:25 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 10 Jan 2017 02:06:25 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.88]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.132]) with mapi id 14.03.0248.002; Tue, 10 Jan 2017 18:06:23 +0800 From: "Zeng, Star" To: Chris Phillips , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] Nt32Pkg: Fixes to correctly set SMBIOS Type 3 Thread-Index: AQHSaw64Iw2P4MgaYU65j6TKunPLP6ExfCrg Date: Tue, 10 Jan 2017 10:06:22 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B815685@shsmsx102.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Tue, 10 Jan 2017 10:06:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Chri= s Phillips Sent: Tuesday, January 10, 2017 2:57 PM To: edk2-devel@lists.01.org Cc: Ni, Ruiyu Subject: [edk2] [PATCH] Nt32Pkg: Fixes to correctly set SMBIOS Type 3 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/MiscSubCla= ssPlatformDxe/MiscChassisManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatf= ormDxe/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 availab= le under the terms and conditions of the BSD License which accompanies thi= s 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); = =20 + AssetTagStrLen =3D StrLen(AssetTag); if (AssetTagStrLen >=20 + SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + TokenToGet =3D STRING_TOKEN (STR_MISC_CHASSIS_SKU_NUMBER); SkuNumber = =3D=20 + HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); =20 + SkuNumberStrLen =3D StrLen(SkuNumber); if (SkuNumberStrLen >=20 + 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=20 + ContainedElementRecordLength =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=20 + (CONTAINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 +=20 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 +=20 + SkuNumberStrLen + 1 + 1); ZeroMem(SmbiosRecord, sizeof=20 + (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT) + sizeof=20 + (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen + 1 +=20 + SerialNumStrLen + 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=20 + ContainedElementRecordLength =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=20 + (CONTAINED_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=20 + (UINT8)ForType3InputData->ChassisNumberPowerCords; + SmbiosRecord->ContainedElementCount =3D 0; =20 + 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=20 + ContainedElementRecordLength =3D 0, // remove sizeof (CONTAINED_ELEMENT)= for ContainedElements[1]. + // + OptionalStrStart -=3D sizeof (CONTAINED_ELEMENT); // // Add sizeof=20 + (SMBIOS_TABLE_STRING) for SKU Number, since not contained in SMBIOS_TABLE= _TYPE3. + // + OptionalStrStart +=3D sizeof (SMBIOS_TABLE_STRING); =20 + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); =20 + UnicodeStrToAsciiStr (Version, OptionalStrStart + ManuStrLen + 1); =20 + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart + ManuStrLen + 1=20 + + VerStrLen + 1); UnicodeStrToAsciiStr (AssetTag, OptionalStrStart +=20 + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); =20 + UnicodeStrToAsciiStr (SkuNumber, OptionalStrStart + ManuStrLen + 1 +=20 + VerStrLen + 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 -- 2.11.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel