From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) Date: Tue, 10 Jan 2017 00:56:43 -0600 From: Chris Phillips CC: ruiyu.ni@intel.com; Sender: Chris Phillips To: edk2-devel@lists.01.org; Message-ID: X-Mailer: TortoiseGit MIME-Version: 1.0 Subject: [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 06:56:43 -0000 Content-Type: text/plain; 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 -> Asset), 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 Copyright (c) 2006 - 2009, 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 @@ -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 }; /* eof - MiscChassisManufacaturerData.c */ diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.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. 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; ForType3InputData = (EFI_MISC_CHASSIS_MANUFACTURER *)RecordData; @@ -74,20 +78,40 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) } TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG); - AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); - AssertTagStrLen = StrLen(AssertTag); - if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) { + AssetTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); + AssetTagStrLen = StrLen(AssetTag); + if (AssetTagStrLen > SMBIOS_STRING_MAX_LENGTH) { + return EFI_UNSUPPORTED; + } + + TokenToGet = STRING_TOKEN (STR_MISC_CHASSIS_SKU_NUMBER); + SkuNumber = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL); + SkuNumberStrLen = StrLen(SkuNumber); + if (SkuNumberStrLen > SMBIOS_STRING_MAX_LENGTH) { return EFI_UNSUPPORTED; } // // Two zeros following the last string. // - SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); - ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + 1); + // Since we set ContainedElementCount = 0 and ContainedElementRecordLength = 0, + // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. + // + // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained in SMBIOS_TABLE_TYPE3. + // + SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + SkuNumberStrLen + 1 + 1); + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT) + sizeof (SMBIOS_TABLE_STRING) + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + SkuNumberStrLen + 1 + 1); + + Buffer = (UINT8 *) SmbiosRecord; SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE; - SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE3); + // + // Since we set ContainedElementCount = 0 and ContainedElementRecordLength = 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 = sizeof (SMBIOS_TABLE_TYPE3) - sizeof (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 = 3; // - // AssertTag will be the 4th optional string following the formatted structure. + // AssetTag will be the 4th optional string following the formatted structure. // - SmbiosRecord->AssetTag = 4; + SmbiosRecord->AssetTag = 4; + SmbiosRecord->BootupState = (UINT8)ForType3InputData->ChassisBootupState; SmbiosRecord->PowerSupplyState = (UINT8)ForType3InputData->ChassisPowerSupplyState; SmbiosRecord->ThermalState = (UINT8)ForType3InputData->ChassisThermalState; SmbiosRecord->SecurityStatus = (UINT8)ForType3InputData->ChassisSecurityState; CopyMem (SmbiosRecord->OemDefined,(UINT8*)&ForType3InputData->ChassisOemDefined, 4); + SmbiosRecord->Height = (UINT8)ForType3InputData->ChassisHeight; + SmbiosRecord->NumberofPowerCords = (UINT8)ForType3InputData->ChassisNumberPowerCords; + SmbiosRecord->ContainedElementCount = 0; + SmbiosRecord->ContainedElementRecordLength = 0; + + // + // SKU Number will be the 5th optional string following the formatted structure. + // + // Since SKU Number is not in SMBIOS_TABLE_TYPE3 structure, must locate it after ContainedElementRecordLength. + // + Buffer[sizeof (SMBIOS_TABLE_TYPE3) - sizeof (CONTAINED_ELEMENT)] = 5; OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1); - UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart); - UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1); - UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1); - UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); + // + // Since we set ContainedElementCount = 0 and ContainedElementRecordLength = 0, + // remove sizeof (CONTAINED_ELEMENT) for ContainedElements[1]. + // + OptionalStrStart -= sizeof (CONTAINED_ELEMENT); + // + // Add sizeof (SMBIOS_TABLE_STRING) for SKU Number, since not contained in SMBIOS_TABLE_TYPE3. + // + OptionalStrStart += sizeof (SMBIOS_TABLE_STRING); + UnicodeStrToAsciiStr (Manufacturer, OptionalStrStart); + UnicodeStrToAsciiStr (Version, OptionalStrStart + ManuStrLen + 1); + UnicodeStrToAsciiStr (SerialNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1); + UnicodeStrToAsciiStr (AssetTag, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); + UnicodeStrToAsciiStr (SkuNumber, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1); // // Now we have got the full smbios record, call smbios protocol to add this record. diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscSubclassDriver.uni b/Nt32Pkg/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 // 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 @@ -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 Number" #string STR_MISC_CHASSIS_ASSET_TAG #language en-US "Chassis Asset Tag" +#string STR_MISC_CHASSIS_SKU_NUMBER #language en-US "Chassis SKU Number" #string STR_MISC_OEM_STRING #language en-US "System Language String" -- 2.11.0.windows.1