]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c
UefiCpuPkg: Remove double \r
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscBaseBoardManufacturerFunction.c
index 6076e93b8e3fc3b2168dbb613c83843a9d7f2555..c414cf653131bc0aa4603df6cbe9797fc5d63151 100644 (file)
@@ -2,14 +2,9 @@
   BaseBoard manufacturer information boot time changes.\r
   SMBIOS type 2.\r
   \r
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2017 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -31,7 +26,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   UINTN                           ManuStrLen;\r
   UINTN                           ProductStrLen;\r
   UINTN                           VerStrLen;\r
-  UINTN                           AssertTagStrLen;\r
+  UINTN                           AssetTagStrLen;\r
   UINTN                           SerialNumStrLen;\r
   UINTN                           ChassisStrLen;\r
   EFI_STATUS                      Status;\r
@@ -39,7 +34,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   EFI_STRING                      Product;\r
   EFI_STRING                      Version;\r
   EFI_STRING                      SerialNumber;\r
-  EFI_STRING                      AssertTag;\r
+  EFI_STRING                      AssetTag;\r
   EFI_STRING                      Chassis;\r
   STRING_REF                      TokenToGet;\r
   EFI_SMBIOS_HANDLE               SmbiosHandle;\r
@@ -84,9 +79,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   }\r
 \r
   TokenToGet = STRING_TOKEN (STR_MISC_BASE_BOARD_ASSET_TAG);\r
-  AssertTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
-  AssertTagStrLen = StrLen(AssertTag);\r
-  if (AssertTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+  AssetTag = HiiGetPackageString(&gEfiCallerIdGuid, TokenToGet, NULL);\r
+  AssetTagStrLen = StrLen(AssetTag);\r
+  if (AssetTagStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
@@ -101,11 +96,16 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //\r
   // Two zeros following the last string.\r
   //\r
-  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r
-  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE3) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1 + ChassisStrLen +1 + 1);\r
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16) + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1 + ChassisStrLen + 1 + 1);\r
 \r
   SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION;\r
-  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2);\r
+  //\r
+  // Since we fill NumberOfContainedObjectHandles = 0, remove sizeof (UINT16) bytes for ContainedObjectHandles[1]\r
+  //\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE2) - sizeof (UINT16);\r
   //\r
   // Make handle chosen by smbios protocol.add automatically.\r
   //\r
@@ -127,7 +127,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   //\r
   SmbiosRecord->SerialNumber = 4;  \r
   //\r
-  // AssertTag will be the 5th optional string following the formatted structure.\r
+  // AssetTag will be the 5th optional string following the formatted structure.\r
   //\r
   SmbiosRecord->AssetTag = 5;  \r
 \r
@@ -142,25 +142,19 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   \r
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
   //\r
-  // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string\r
+  // Since we fill NumberOfContainedObjectHandles = 0, just after this field to fill string\r
   //\r
-  OptionalStrStart -= 2;\r
+  OptionalStrStart -= sizeof (UINT16);\r
   UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);\r
   UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);\r
   UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);\r
   UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);\r
-  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r
-  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);\r
+  UnicodeStrToAsciiStr(AssetTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);\r
+  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssetTagStrLen + 1);\r
   //\r
   // Now we have got the full smbios record, call smbios protocol to add this record.\r
   //\r
-  SmbiosHandle = 0;\r
-  Status = Smbios-> Add(\r
-                      Smbios, \r
-                      NULL,\r
-                      &SmbiosHandle, \r
-                      (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r
-                      );\r
+  Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
 \r
   FreePool(SmbiosRecord);\r
   return Status;\r