public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
@ 2017-01-10 16:48 Chris Phillips
  2017-01-11  1:36 ` Zeng, Star
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Phillips @ 2017-01-10 16:48 UTC (permalink / raw)
  To: edk2-devel; +Cc: ruiyu.ni

When running Nt32Pkg, SMBIOS Type 2 had the wrong Length.
Fixed the code to use the correct structure in sizeof, and properly account for ContainedObjectHandles.
Also updated variable names with Assert -> Asset

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hpe.com>
---
 .../MiscBaseBoardManufacturerFunction.c            | 32 +++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
index 303726c3fd..765627a8e6 100644
--- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
+++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
@@ -3,6 +3,7 @@
   SMBIOS type 2.
   
 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,7 +32,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   UINTN                           ManuStrLen;
   UINTN                           ProductStrLen;
   UINTN                           VerStrLen;
-  UINTN                           AssertTagStrLen;
+  UINTN                           AssetTagStrLen;
   UINTN                           SerialNumStrLen;
   UINTN                           ChassisStrLen;
   EFI_STATUS                      Status;
@@ -39,7 +40,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   EFI_STRING                      Product;
   EFI_STRING                      Version;
   EFI_STRING                      SerialNumber;
-  EFI_STRING                      AssertTag;
+  EFI_STRING                      AssetTag;
   EFI_STRING                      Chassis;
   STRING_REF                      TokenToGet;
   EFI_SMBIOS_HANDLE               SmbiosHandle;
@@ -84,9 +85,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   }
 
   TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_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;
   }
 
@@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //
   // Two zeros following the last string.
   //
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]
+  //
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
 
   SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
+  //
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]
+  //
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16);
   //
   // Make handle chosen by smbios protocol.add automatically.
   //
@@ -127,7 +133,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //
   SmbiosRecord->SerialNumber = 4;  
   //
-  // AssertTag will be the 5th optional string following the formatted structure.
+  // AssetTag will be the 5th optional string following the formatted structure.
   //
   SmbiosRecord->AssetTag = 5;  
 
@@ -142,15 +148,15 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
   //
-  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
+  // Since we fill NumberOfContainedObjectHandles = 0, just after this field to fill string
   //
-  OptionalStrStart -= 2;
+  OptionalStrStart -= sizeof (UINT16);
   UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
   UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
   UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
   UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
-  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
-  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
+  UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
+  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1);
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.
   //
-- 
2.11.0.windows.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
  2017-01-10 16:48 [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length Chris Phillips
@ 2017-01-11  1:36 ` Zeng, Star
  2017-01-11 10:07   ` Zeng, Star
  0 siblings, 1 reply; 5+ messages in thread
From: Zeng, Star @ 2017-01-11  1:36 UTC (permalink / raw)
  To: Chris Phillips, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu, Zeng, Star

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: Wednesday, January 11, 2017 12:49 AM
To: edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length

When running Nt32Pkg, SMBIOS Type 2 had the wrong Length.
Fixed the code to use the correct structure in sizeof, and properly account for ContainedObjectHandles.
Also updated variable names with Assert -> Asset

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chris Phillips <chrisp@hpe.com>
---
 .../MiscBaseBoardManufacturerFunction.c            | 32 +++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
index 303726c3fd..765627a8e6 100644
--- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
+++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.
+++ c
@@ -3,6 +3,7 @@
   SMBIOS type 2.
   
 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,7 +32,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   UINTN                           ManuStrLen;
   UINTN                           ProductStrLen;
   UINTN                           VerStrLen;
-  UINTN                           AssertTagStrLen;
+  UINTN                           AssetTagStrLen;
   UINTN                           SerialNumStrLen;
   UINTN                           ChassisStrLen;
   EFI_STATUS                      Status;
@@ -39,7 +40,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   EFI_STRING                      Product;
   EFI_STRING                      Version;
   EFI_STRING                      SerialNumber;
-  EFI_STRING                      AssertTag;
+  EFI_STRING                      AssetTag;
   EFI_STRING                      Chassis;
   STRING_REF                      TokenToGet;
   EFI_SMBIOS_HANDLE               SmbiosHandle;
@@ -84,9 +85,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   }
 
   TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_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;
   }
 
@@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //
   // Two zeros following the last string.
   //
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof 
+ (UINT16) bytes for ContainedObjectHandles[1]  //  SmbiosRecord = 
+ AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + 
+ ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 
+ 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);  
+ ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + 
+ ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 
+ 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
 
   SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
+  //
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof 
+ (UINT16) bytes for ContainedObjectHandles[1]  //  
+ SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof 
+ (UINT16);
   //
   // Make handle chosen by smbios protocol.add automatically.
   //
@@ -127,7 +133,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //
   SmbiosRecord->SerialNumber = 4;  
   //
-  // AssertTag will be the 5th optional string following the formatted structure.
+  // AssetTag will be the 5th optional string following the formatted structure.
   //
   SmbiosRecord->AssetTag = 5;  
 
@@ -142,15 +148,15 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
   //
-  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
+  // Since we fill NumberOfContainedObjectHandles = 0, just after this 
+ field to fill string
   //
-  OptionalStrStart -= 2;
+  OptionalStrStart -= sizeof (UINT16);
   UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
   UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
   UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
   UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
-  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
-  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
+  UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 + 
+ ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);  
+ UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + 
+ ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 
+ AssetTagStrLen + 1);
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.
   //
--
2.11.0.windows.1


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
  2017-01-11  1:36 ` Zeng, Star
@ 2017-01-11 10:07   ` Zeng, Star
  2017-01-12  8:15     ` Phillips, Chris J (Plano, TX)
  0 siblings, 1 reply; 5+ messages in thread
From: Zeng, Star @ 2017-01-11 10:07 UTC (permalink / raw)
  To: Chris Phillips, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu, star.zeng

Chris,

Since no other comments received, do you need me to help push the SMBIOS 
related patches?

Thanks,
Star

On 2017/1/11 9:36, Zeng, Star wrote:
> 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: Wednesday, January 11, 2017 12:49 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
>
> When running Nt32Pkg, SMBIOS Type 2 had the wrong Length.
> Fixed the code to use the correct structure in sizeof, and properly account for ContainedObjectHandles.
> Also updated variable names with Assert -> Asset
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Chris Phillips <chrisp@hpe.com>
> ---
>  .../MiscBaseBoardManufacturerFunction.c            | 32 +++++++++++++---------
>  1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> index 303726c3fd..765627a8e6 100644
> --- a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.
> +++ c
> @@ -3,6 +3,7 @@
>    SMBIOS type 2.
>
>  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,7 +32,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    UINTN                           ManuStrLen;
>    UINTN                           ProductStrLen;
>    UINTN                           VerStrLen;
> -  UINTN                           AssertTagStrLen;
> +  UINTN                           AssetTagStrLen;
>    UINTN                           SerialNumStrLen;
>    UINTN                           ChassisStrLen;
>    EFI_STATUS                      Status;
> @@ -39,7 +40,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    EFI_STRING                      Product;
>    EFI_STRING                      Version;
>    EFI_STRING                      SerialNumber;
> -  EFI_STRING                      AssertTag;
> +  EFI_STRING                      AssetTag;
>    EFI_STRING                      Chassis;
>    STRING_REF                      TokenToGet;
>    EFI_SMBIOS_HANDLE               SmbiosHandle;
> @@ -84,9 +85,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    }
>
>    TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_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;
>    }
>
> @@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    //
>    // Two zeros following the last string.
>    //
> -  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
> -  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
> +  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof
> + (UINT16) bytes for ContainedObjectHandles[1]  //  SmbiosRecord =
> + AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) +
> + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen +
> + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
> + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) +
> + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen +
> + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
>
>    SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
> -  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
> +  //
> +  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof
> + (UINT16) bytes for ContainedObjectHandles[1]  //
> + SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof
> + (UINT16);
>    //
>    // Make handle chosen by smbios protocol.add automatically.
>    //
> @@ -127,7 +133,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    //
>    SmbiosRecord->SerialNumber = 4;
>    //
> -  // AssertTag will be the 5th optional string following the formatted structure.
> +  // AssetTag will be the 5th optional string following the formatted structure.
>    //
>    SmbiosRecord->AssetTag = 5;
>
> @@ -142,15 +148,15 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>
>    OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
>    //
> -  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
> +  // Since we fill NumberOfContainedObjectHandles = 0, just after this
> + field to fill string
>    //
> -  OptionalStrStart -= 2;
> +  OptionalStrStart -= sizeof (UINT16);
>    UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
>    UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
>    UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
>    UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
> -  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
> -  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
> +  UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 +
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
> + UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 +
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 +
> + AssetTagStrLen + 1);
>    //
>    // Now we have got the full smbios record, call smbios protocol to add this record.
>    //
> --
> 2.11.0.windows.1
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
  2017-01-11 10:07   ` Zeng, Star
@ 2017-01-12  8:15     ` Phillips, Chris J (Plano, TX)
  2017-01-12  9:06       ` Zeng, Star
  0 siblings, 1 reply; 5+ messages in thread
From: Phillips, Chris J (Plano, TX) @ 2017-01-12  8:15 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Ni, Ruiyu

Star,

Yes, please help push the patches.  This one, and the following with subject:
MdePkg: Add comments for SMBIOS Type 3 structure to cover SKU Number
ShellPkg: Update smbiosview command to display Type 3 values
Nt32Pkg: Fixes to correctly set SMBIOS Type 3

Thanks,
Chris

-----Original Message-----
From: Zeng, Star [mailto:star.zeng@intel.com] 
Sent: Wednesday, January 11, 2017 4:08 AM
To: Phillips, Chris J (Plano, TX) <chrisp@hpe.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; star.zeng@intel.com
Subject: Re: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length

Chris,

Since no other comments received, do you need me to help push the SMBIOS related patches?

Thanks,
Star

On 2017/1/11 9:36, Zeng, Star wrote:
> 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: Wednesday, January 11, 2017 12:49 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS 
> Type 2 Length
>
> When running Nt32Pkg, SMBIOS Type 2 had the wrong Length.
> Fixed the code to use the correct structure in sizeof, and properly account for ContainedObjectHandles.
> Also updated variable names with Assert -> Asset
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Chris Phillips <chrisp@hpe.com>
> ---
>  .../MiscBaseBoardManufacturerFunction.c            | 32 +++++++++++++---------
>  1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git 
> a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c 
> b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> index 303726c3fd..765627a8e6 100644
> --- 
> a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.
> +++ c
> @@ -3,6 +3,7 @@
>    SMBIOS type 2.
>
>  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,7 +32,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    UINTN                           ManuStrLen;
>    UINTN                           ProductStrLen;
>    UINTN                           VerStrLen;
> -  UINTN                           AssertTagStrLen;
> +  UINTN                           AssetTagStrLen;
>    UINTN                           SerialNumStrLen;
>    UINTN                           ChassisStrLen;
>    EFI_STATUS                      Status;
> @@ -39,7 +40,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    EFI_STRING                      Product;
>    EFI_STRING                      Version;
>    EFI_STRING                      SerialNumber;
> -  EFI_STRING                      AssertTag;
> +  EFI_STRING                      AssetTag;
>    EFI_STRING                      Chassis;
>    STRING_REF                      TokenToGet;
>    EFI_SMBIOS_HANDLE               SmbiosHandle;
> @@ -84,9 +85,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    }
>
>    TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_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;
>    }
>
> @@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    //
>    // Two zeros following the last string.
>    //
> -  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + 
> ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 
> 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
> -  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 
> AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
> +  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof
> + (UINT16) bytes for ContainedObjectHandles[1]  //  SmbiosRecord = 
> + AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + 
> + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen 
> + +
> + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1); 
> + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) 
> + + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + 
> + SerialNumStrLen +
> + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
>
>    SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
> -  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
> +  //
> +  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof
> + (UINT16) bytes for ContainedObjectHandles[1]  //
> + SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof
> + (UINT16);
>    //
>    // Make handle chosen by smbios protocol.add automatically.
>    //
> @@ -127,7 +133,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    //
>    SmbiosRecord->SerialNumber = 4;
>    //
> -  // AssertTag will be the 5th optional string following the formatted structure.
> +  // AssetTag will be the 5th optional string following the formatted structure.
>    //
>    SmbiosRecord->AssetTag = 5;
>
> @@ -142,15 +148,15 @@ 
> MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>
>    OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
>    //
> -  // Since we fill NumberOfContainedObjectHandles = 0 for simple, 
> just after this filed to fill string
> +  // Since we fill NumberOfContainedObjectHandles = 0, just after 
> + this field to fill string
>    //
> -  OptionalStrStart -= 2;
> +  OptionalStrStart -= sizeof (UINT16);
>    UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
>    UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
>    UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
>    UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 
> 1 + ProductStrLen + 1 + VerStrLen + 1);
> -  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + 
> ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
> -  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + 
> ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 
> AssertTagStrLen + 1);
> +  UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 + 
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); 
> + UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + 
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 
> + AssetTagStrLen + 1);
>    //
>    // Now we have got the full smbios record, call smbios protocol to add this record.
>    //
> --
> 2.11.0.windows.1
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length
  2017-01-12  8:15     ` Phillips, Chris J (Plano, TX)
@ 2017-01-12  9:06       ` Zeng, Star
  0 siblings, 0 replies; 5+ messages in thread
From: Zeng, Star @ 2017-01-12  9:06 UTC (permalink / raw)
  To: Phillips, Chris J (Plano, TX), edk2-devel@lists.01.org
  Cc: Ni, Ruiyu, Zeng, Star

Chris,

The patches have been pushed at https://github.com/tianocore/edk2/compare/32fd9c4150d0...12233c19177d.
Thanks for the contribution.

Star

-----Original Message-----
From: Phillips, Chris J (Plano, TX) [mailto:chrisp@hpe.com] 
Sent: Thursday, January 12, 2017 4:16 PM
To: Zeng, Star <star.zeng@intel.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: RE: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length

Star,

Yes, please help push the patches.  This one, and the following with subject:
MdePkg: Add comments for SMBIOS Type 3 structure to cover SKU Number
ShellPkg: Update smbiosview command to display Type 3 values
Nt32Pkg: Fixes to correctly set SMBIOS Type 3

Thanks,
Chris

-----Original Message-----
From: Zeng, Star [mailto:star.zeng@intel.com]
Sent: Wednesday, January 11, 2017 4:08 AM
To: Phillips, Chris J (Plano, TX) <chrisp@hpe.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; star.zeng@intel.com
Subject: Re: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length

Chris,

Since no other comments received, do you need me to help push the SMBIOS related patches?

Thanks,
Star

On 2017/1/11 9:36, Zeng, Star wrote:
> 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: Wednesday, January 11, 2017 12:49 AM
> To: edk2-devel@lists.01.org
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com>
> Subject: [edk2] [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS 
> Type 2 Length
>
> When running Nt32Pkg, SMBIOS Type 2 had the wrong Length.
> Fixed the code to use the correct structure in sizeof, and properly account for ContainedObjectHandles.
> Also updated variable names with Assert -> Asset
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Chris Phillips <chrisp@hpe.com>
> ---
>  .../MiscBaseBoardManufacturerFunction.c            | 32 +++++++++++++---------
>  1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git
> a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> index 303726c3fd..765627a8e6 100644
> ---
> a/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
> +++ b/Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.
> +++ c
> @@ -3,6 +3,7 @@
>    SMBIOS type 2.
>
>  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,7 +32,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    UINTN                           ManuStrLen;
>    UINTN                           ProductStrLen;
>    UINTN                           VerStrLen;
> -  UINTN                           AssertTagStrLen;
> +  UINTN                           AssetTagStrLen;
>    UINTN                           SerialNumStrLen;
>    UINTN                           ChassisStrLen;
>    EFI_STATUS                      Status;
> @@ -39,7 +40,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    EFI_STRING                      Product;
>    EFI_STRING                      Version;
>    EFI_STRING                      SerialNumber;
> -  EFI_STRING                      AssertTag;
> +  EFI_STRING                      AssetTag;
>    EFI_STRING                      Chassis;
>    STRING_REF                      TokenToGet;
>    EFI_SMBIOS_HANDLE               SmbiosHandle;
> @@ -84,9 +85,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    }
>
>    TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_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;
>    }
>
> @@ -101,11 +102,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    //
>    // Two zeros following the last string.
>    //
> -  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + 
> ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen +
> 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
> -  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 +
> AssertTagStrLen + 1 + ChassisStrLen +1 + 1);
> +  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof
> + (UINT16) bytes for ContainedObjectHandles[1]  //  SmbiosRecord = 
> + AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + 
> + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen
> + +
> + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1); 
> + ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16)
> + + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 +
> + SerialNumStrLen +
> + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);
>
>    SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;
> -  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);
> +  //
> +  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof
> + (UINT16) bytes for ContainedObjectHandles[1]  //
> + SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof
> + (UINT16);
>    //
>    // Make handle chosen by smbios protocol.add automatically.
>    //
> @@ -127,7 +133,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>    //
>    SmbiosRecord->SerialNumber = 4;
>    //
> -  // AssertTag will be the 5th optional string following the formatted structure.
> +  // AssetTag will be the 5th optional string following the formatted structure.
>    //
>    SmbiosRecord->AssetTag = 5;
>
> @@ -142,15 +148,15 @@
> MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
>
>    OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
>    //
> -  // Since we fill NumberOfContainedObjectHandles = 0 for simple, 
> just after this filed to fill string
> +  // Since we fill NumberOfContainedObjectHandles = 0, just after 
> + this field to fill string
>    //
> -  OptionalStrStart -= 2;
> +  OptionalStrStart -= sizeof (UINT16);
>    UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
>    UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
>    UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
>    UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen +
> 1 + ProductStrLen + 1 + VerStrLen + 1);
> -  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + 
> ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
> -  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + 
> ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 
> AssertTagStrLen + 1);
> +  UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 + 
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1); 
> + UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + 
> + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + 
> + AssetTagStrLen + 1);
>    //
>    // Now we have got the full smbios record, call smbios protocol to add this record.
>    //
> --
> 2.11.0.windows.1
>
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-12  9:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-10 16:48 [PATCH v2] Nt32Pkg: Fix code to correctly set SMBIOS Type 2 Length Chris Phillips
2017-01-11  1:36 ` Zeng, Star
2017-01-11 10:07   ` Zeng, Star
2017-01-12  8:15     ` Phillips, Chris J (Plano, TX)
2017-01-12  9:06       ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox