From: "Zeng, Star" <star.zeng@intel.com>
To: Chris Phillips <chrisp@hpe.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Ni, Ruiyu" <ruiyu.ni@intel.com>, "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] Nt32Pkg: Fixes to correctly set SMBIOS Type 3
Date: Tue, 10 Jan 2017 10:06:22 +0000 [thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B815685@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <be3090a8-7c7a-4cdc-b4b2-76458aefc2b2@AIA2PHNNRN.local>
Reviewed-by: Star Zeng <star.zeng@intel.com>
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Chris Phillips
Sent: Tuesday, January 10, 2017 2:57 PM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
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 -> Asset), and properly handle setting the Type 3 values.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hpe.com>
---
.../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.<BR>
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
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.<BR>
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
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.<BR>
+// (C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>
// 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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
prev parent reply other threads:[~2017-01-10 10:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-10 6:56 [PATCH] Nt32Pkg: Fixes to correctly set SMBIOS Type 3 Chris Phillips
2017-01-10 10:06 ` Zeng, Star [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0C09AFA07DD0434D9E2A0C6AEB0483103B815685@shsmsx102.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox