]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
EdkCompatibilityPkg: Remove EdkCompatibilityPkg
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / PiSmbiosRecordOnDataHubSmbiosRecordThunk / ConvLib.c
diff --git a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
deleted file mode 100644 (file)
index 10208ce..0000000
+++ /dev/null
@@ -1,829 +0,0 @@
-/** @file\r
-  Common filling functions used in translating Datahub's record\r
-  to PI SMBIOS's record.\r
-  \r
-Copyright (c) 2009 - 2010, 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
-\r
-**/\r
-\r
-#include "Thunk.h"\r
-\r
-/**\r
-  Field Filling Function for Cache SubClass record type 5&6 -- Cache SRAM type.\r
-  Offset is mandatory\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_SUCCESS   Success fill RecordData into SMBIOS's record buffer.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldCacheType5 (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_CACHE_SRAM_TYPE_DATA SramData;\r
-  UINT32                   Temp;\r
-\r
-  SramData = *(EFI_CACHE_SRAM_TYPE_DATA*)RecordData;\r
-\r
-  //\r
-  // Swap two fields because of inconsistency between smbios and datahub specs\r
-  //\r
-  Temp                  = SramData.Asynchronous;\r
-  SramData.Asynchronous = SramData.Synchronous;\r
-  SramData.Synchronous  = Temp;\r
-  \r
-  //\r
-  // Truncate the data to word\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (StructureNode->Structure) + Offset,\r
-    (EFI_CACHE_SRAM_TYPE_DATA *) &SramData,\r
-    2\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Field Filling Function for Cache SubClass record type 10 -- Cache Config.\r
-  Offset is mandatory\r
-\r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_SUCCESS   Success fill RecordData into SMBIOS's record buffer.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldCacheType10 (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-\r
-  UINT16  CacheConfig;\r
-\r
-  CopyMem (&CacheConfig, RecordData, 2);\r
-\r
-  if ((CacheConfig & 0x07) == 0) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  //\r
-  // Truncate the data to 2 bytes and make cache level zero-based.\r
-  //\r
-  CacheConfig--;\r
-  CopyMem (\r
-    (UINT8 *) (StructureNode->Structure) + Offset,\r
-    &CacheConfig,\r
-    2\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Enlarge the structure buffer of a structure node in SMBIOS database.\r
-  The function maybe lead the structure pointer for SMBIOS record changed.\r
-  \r
-  @param StructureNode The structure node whose structure buffer is to be enlarged.\r
-  @param NewLength     The new length of SMBIOS record which does not include unformat area.\r
-  @param OldBufferSize The old size of SMBIOS record buffer.\r
-  @param NewBufferSize The new size is targeted for enlarged.\r
-  \r
-  @retval EFI_OUT_OF_RESOURCES  No more memory to allocate new record\r
-  @retval EFI_SUCCESS           Success to enlarge the record buffer size.\r
-**/\r
-EFI_STATUS\r
-SmbiosEnlargeStructureBuffer (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE *StructureNode,\r
-  UINT8                         NewLength,\r
-  UINTN                         OldBufferSize,\r
-  UINTN                         NewBufferSize\r
-  )\r
-{\r
-  EFI_SMBIOS_TABLE_HEADER   *NewRecord;\r
-  EFI_SMBIOS_PROTOCOL       *Smbios;\r
-  EFI_STATUS                Status;\r
-  UINT8                     CountOfString;\r
-  \r
-  NewRecord = NULL;\r
-  Smbios    = GetSmbiosProtocol();\r
-  ASSERT (Smbios != NULL);\r
-  \r
-  NewRecord = (EFI_SMBIOS_TABLE_HEADER*) AllocateZeroPool (NewBufferSize);\r
-  if (NewRecord == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (NewRecord, StructureNode->Structure, OldBufferSize);\r
-  \r
-  \r
-  Status = Smbios->Remove (Smbios, StructureNode->SmbiosHandle);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  //\r
-  // try to use original handle to enlarge the buffer.\r
-  //\r
-  NewRecord->Length = NewLength;\r
-  Status = Smbios->Add (Smbios, NULL, &StructureNode->SmbiosHandle, NewRecord);\r
-  ASSERT_EFI_ERROR (Status);\r
-  FreePool (NewRecord);\r
-  \r
-  StructureNode->Structure = GetSmbiosBufferFromHandle (\r
-                               StructureNode->SmbiosHandle, \r
-                               StructureNode->SmbiosType, \r
-                               NULL\r
-                               );\r
-  GetSmbiosStructureSize (\r
-    StructureNode->Structure,\r
-    &StructureNode->StructureSize,\r
-    &CountOfString\r
-    );\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Update the structure buffer of a structure node in SMBIOS database.\r
-  The function lead the structure pointer for SMBIOS record changed.\r
-  \r
-  @param StructureNode The structure node whose structure buffer is to be enlarged.\r
-  @param NewRecord     The new SMBIOS record.\r
-  \r
-**/\r
-VOID\r
-SmbiosUpdateStructureBuffer (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE *StructureNode,\r
-  IN EFI_SMBIOS_TABLE_HEADER    *NewRecord\r
-  )\r
-{\r
-  EFI_SMBIOS_PROTOCOL       *Smbios;\r
-  EFI_STATUS                Status;\r
-  UINT8                     CountOfString;\r
-  \r
-  Smbios    = GetSmbiosProtocol();\r
-  ASSERT (Smbios != NULL);\r
-  \r
-  Status = Smbios->Remove (Smbios, StructureNode->SmbiosHandle);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  //\r
-  // try to use original handle to enlarge the buffer.\r
-  //\r
-  Status = Smbios->Add (Smbios, NULL, &StructureNode->SmbiosHandle, NewRecord);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  StructureNode->Structure = GetSmbiosBufferFromHandle (\r
-                               StructureNode->SmbiosHandle, \r
-                               StructureNode->SmbiosType, \r
-                               NULL\r
-                               );\r
-  GetSmbiosStructureSize (\r
-    StructureNode->Structure,\r
-    &StructureNode->StructureSize,\r
-    &CountOfString\r
-    );\r
-  return ;\r
-}\r
-\r
-/**\r
-  Fill a standard Smbios string field. \r
-  \r
-  This function will convert the unicode string to single byte chars, and only\r
-  English language is supported.\r
-  This function changes the Structure pointer value of the structure node, \r
-  which should be noted by Caller.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER   RecordDataSize is too larger\r
-  @retval EFI_OUT_OF_RESOURCES    No memory to allocate new buffer for string\r
-  @retval EFI_SUCCESS             Sucess append string for a SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldString (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_STATUS              Status;\r
-  UINT16                  *Data;\r
-  CHAR8                   AsciiData[SMBIOS_STRING_MAX_LENGTH];\r
-  UINT8                   CountOfStrings;\r
-  UINTN                   OrigStringNumber;\r
-  EFI_SMBIOS_PROTOCOL     *Smbios;\r
-  EFI_SMBIOS_HANDLE       SmbiosHandle;\r
-  UINT32                  OrigStructureSize;\r
-  UINTN                   NewStructureSize;\r
-  EFI_SMBIOS_TABLE_HEADER *NewRecord;\r
-  UINT32                  StringLength;\r
-  \r
-  Status            = EFI_SUCCESS;\r
-  OrigStringNumber  = 0;\r
-  OrigStructureSize = 0;\r
-\r
-  //\r
-  // if we have a NULL token,\r
-  //\r
-  if (0 == *((STRING_REF *) RecordData)) {\r
-    *(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = 0;\r
-    return EFI_SUCCESS;\r
-  }\r
-  \r
-  //\r
-  // Get the String from the Hii Database\r
-  //\r
-  Data = HiiGetPackageString (\r
-             &(StructureNode->ProducerName),\r
-             *((EFI_STRING_ID *) RecordData),\r
-             NULL\r
-             );\r
-  if (Data == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  StringLength = (UINT32)StrLen (Data);\r
-  //\r
-  // Count the string size including the terminating 0.\r
-  //\r
-  if (StringLength == 0) {\r
-    *(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = 0;\r
-    FreePool (Data);\r
-    return EFI_SUCCESS;\r
-  }\r
-  \r
-  if (StringLength > SMBIOS_STRING_MAX_LENGTH) {\r
-    //\r
-    // Too long a string\r
-    //\r
-    FreePool (Data);\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-    \r
-  Smbios = GetSmbiosProtocol();\r
-  ASSERT (Smbios != NULL);\r
-  \r
-  //\r
-  // Convert Unicode string to Ascii string which only supported by SMBIOS.\r
-  //\r
-  ZeroMem (AsciiData, SMBIOS_STRING_MAX_LENGTH);\r
-  UnicodeStrToAsciiStr (Data, AsciiData);\r
-  \r
-  //\r
-  // if the field at offset is already filled with some value,\r
-  // find out the string it points to\r
-  //\r
-  OrigStringNumber = *(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset);\r
-  if (OrigStringNumber != 0) {\r
-    DEBUG ((EFI_D_ERROR, "[SMBIOSThunk] Update %dth string for type[%d],offset[0x%x],handle[0x%x] to [%s]\n", \r
-            OrigStringNumber, StructureNode->SmbiosType, Offset, StructureNode->SmbiosHandle, AsciiData));  \r
-    \r
-    //\r
-    // If original string number is not zero, just update string\r
-    //\r
-    Status = Smbios->UpdateString (Smbios, &StructureNode->SmbiosHandle, &OrigStringNumber, AsciiData);\r
-    if (EFI_ERROR (Status)) {\r
-      DEBUG ((EFI_D_ERROR, "[SMBIOSThunk] Fail to update %dth string in offset 0x%x for handle:0x%x type:0x%x\n", \r
-             OrigStringNumber, Offset, StructureNode->SmbiosHandle, StructureNode->SmbiosType));\r
-      ASSERT_EFI_ERROR (Status);\r
-      return Status;\r
-    }\r
-  } else {\r
-    //\r
-    // If the string has not been filled in SMBIOS database, remove it and add again\r
-    // with string appended.\r
-    //\r
-    Status = GetSmbiosStructureSize (StructureNode->Structure, &OrigStructureSize, &CountOfStrings);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    if (CountOfStrings == 0) {\r
-      NewStructureSize = OrigStructureSize + StringLength;\r
-    } else {\r
-      NewStructureSize = OrigStructureSize + StringLength + 1;\r
-    }\r
-    \r
-    NewRecord = AllocateZeroPool (NewStructureSize);\r
-    if (NewRecord == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    CopyMem (NewRecord, StructureNode->Structure, OrigStructureSize);\r
-    \r
-    //\r
-    // Copy new string into tail of original SMBIOS record buffer.\r
-    //\r
-    if (CountOfStrings == 0) {\r
-      AsciiStrCpy ((CHAR8 *)NewRecord + OrigStructureSize - 2, AsciiData);\r
-    } else {\r
-      AsciiStrCpy ((CHAR8 *)NewRecord + OrigStructureSize - 1, AsciiData);\r
-    }\r
-    DEBUG ((EFI_D_ERROR, "[SMBIOSThunk] Type(%d) offset(0x%x) StringNumber:%d\n", \r
-            StructureNode->SmbiosType, Offset, CountOfStrings + 1));\r
-    //\r
-    // Update string reference number\r
-    //\r
-    *(UINT8 *) ((UINT8 *) NewRecord + Offset) = (UINT8) (CountOfStrings + 1);\r
-    SmbiosHandle = StructureNode->SmbiosHandle;\r
-    \r
-    //\r
-    // Remove original SMBIOS record and add new one\r
-    //\r
-    Status = Smbios->Remove (Smbios, StructureNode->SmbiosHandle);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    //\r
-    // Add new SMBIOS record\r
-    //\r
-    Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, NewRecord);\r
-    ASSERT_EFI_ERROR (Status);\r
-    \r
-    StructureNode->SmbiosHandle = SmbiosHandle;\r
-    \r
-    FreePool (NewRecord);\r
-  }\r
-  \r
-  //\r
-  // The SMBIOS record buffer maybe re-allocated in SMBIOS database,\r
-  // so update cached buffer pointer in DataHub structure list.\r
-  //\r
-  StructureNode->Structure = GetSmbiosBufferFromHandle (\r
-                               StructureNode->SmbiosHandle, \r
-                               StructureNode->SmbiosType,\r
-                               NULL\r
-                               );\r
-  ASSERT (StructureNode->Structure != NULL);\r
-  \r
-  //\r
-  // The string update action maybe lead the record is re-allocated in SMBIOS database\r
-  // so update cached record pointer\r
-  //\r
-  Status = GetSmbiosStructureSize (StructureNode->Structure, &StructureNode->StructureSize, &CountOfStrings);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Find a handle that matches the Link Data and the target Smbios type.\r
-  \r
-  @param  TargetType     the Smbios type\r
-  @param  SubClass       the SubClass\r
-  @param  LinkData       Specifies Instance, SubInstance and ProducerName\r
-  @param  Handle         the HandleNum found  \r
-  \r
-  @retval EFI_NOT_FOUND Can not find the record according to handle\r
-  @retval EFI_SUCCESS   Success to find the handle\r
-**/\r
-EFI_STATUS\r
-SmbiosFindHandle (\r
-  IN      UINT8               TargetType,\r
-  IN      EFI_GUID            *SubClass,\r
-  IN      EFI_INTER_LINK_DATA *LinkData,\r
-  IN OUT  UINT16              *HandleNum\r
-  )\r
-{\r
-  LIST_ENTRY        *Link;\r
-  SMBIOS_STRUCTURE_NODE *StructureNode;\r
-\r
-  StructureNode = NULL;\r
-\r
-  //\r
-  // Find out the matching handle\r
-  //\r
-  for (Link = mStructureList.ForwardLink; Link != &mStructureList; Link = Link->ForwardLink) {\r
-    StructureNode = CR (Link, SMBIOS_STRUCTURE_NODE, Link, SMBIOS_STRUCTURE_NODE_SIGNATURE);\r
-    if (StructureNode->Structure->Type == TargetType &&\r
-        CompareGuid (&(StructureNode->SubClass), SubClass) &&\r
-        StructureNode->Instance == LinkData->Instance &&\r
-        StructureNode->SubInstance == LinkData->SubInstance\r
-        ) {\r
-      break;\r
-    }\r
-  }\r
-\r
-  if (Link == &mStructureList || StructureNode == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  } else {\r
-    *HandleNum = StructureNode->Structure->Handle;\r
-    return EFI_SUCCESS;\r
-  }\r
-}\r
-\r
-/**\r
-  Fill the inter link field for a SMBIOS recorder.\r
-  \r
-  Some SMBIOS recorder need to reference the handle of another SMBIOS record. But\r
-  maybe another SMBIOS record has not been added, so put the InterLink request into\r
-  a linked list and the interlink will be fixedup when a new SMBIOS record is added.\r
-  \r
-  @param StructureNode        Point to SMBIOS_STRUCTURE_NODE which reference another record's handle\r
-  @param LinkSmbiosNodeOffset The offset in this record for holding the handle of another SMBIOS record\r
-  @param LinkSmbiosType       The type of SMBIOS record want to be linked.\r
-  @param InterLink            Point to EFI_INTER_LINK_DATA will be put linked list.\r
-  @param SubClassGuid         The guid of subclass for linked SMBIOS record.\r
-  \r
-  @retval EFI_SUCESS  The linked record is found and no need fixup in future.\r
-  @retval !EFI_SUCESS The linked record can not be found and InterLink is put a fixing-p linked list.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldInterLink (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT16                    LinkSmbiosNodeOffset,\r
-  IN      UINT8                     LinkSmbiosType,\r
-  IN      EFI_INTER_LINK_DATA       *InterLink,\r
-  IN      EFI_GUID                  *SubClassGuid\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  SMBIOS_LINK_DATA_FIXUP_NODE *LinkDataFixupNode;\r
-  UINT16                      StructureHandle;\r
-\r
-  Status            = EFI_SUCCESS;\r
-  LinkDataFixupNode = NULL;\r
-\r
-  Status = SmbiosFindHandle (\r
-            LinkSmbiosType, // Smbios type\r
-            SubClassGuid,\r
-            InterLink,\r
-            &StructureHandle\r
-            );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Set the handle\r
-    //\r
-    CopyMem (\r
-      (UINT8 *) (StructureNode->Structure) + LinkSmbiosNodeOffset,\r
-      &StructureHandle,\r
-      sizeof (EFI_SMBIOS_HANDLE)\r
-      );\r
-  } else {\r
-    //\r
-    // Hang this in the link data fixup node\r
-    //\r
-    LinkDataFixupNode = AllocateZeroPool (sizeof (SMBIOS_LINK_DATA_FIXUP_NODE));\r
-    if (LinkDataFixupNode == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-\r
-    LinkDataFixupNode->Signature  = SMBIOS_LINK_DATA_FIXUP_NODE_SIGNATURE;\r
-    LinkDataFixupNode->Offset     = LinkSmbiosNodeOffset;\r
-    LinkDataFixupNode->TargetType = LinkSmbiosType;\r
-    CopyMem (\r
-      &LinkDataFixupNode->SubClass,\r
-      SubClassGuid,\r
-      sizeof (EFI_GUID)\r
-      );\r
-    CopyMem (\r
-      &LinkDataFixupNode->LinkData,\r
-      InterLink,\r
-      sizeof (EFI_INTER_LINK_DATA)\r
-      );\r
-    InsertTailList (\r
-      &StructureNode->LinkDataFixup,\r
-      &(LinkDataFixupNode->Link)\r
-      );\r
-  }\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Field Filling Function. Transform an EFI_EXP_BASE10_DATA to a word, with 'Mega'\r
-  as the unit.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER  RecordDataSize is invalid. \r
-  @retval EFI_SUCCESS            RecordData is successed to be filled into given SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldBase10ToWordWithMega (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_EXP_BASE10_DATA *Base10Data;\r
-  INT16               Value;\r
-  INT16               Exponent;\r
-\r
-  if (RecordDataSize != sizeof (EFI_EXP_BASE10_DATA)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Base10Data  = RecordData;\r
-  Value       = Base10Data->Value;\r
-  Exponent    = Base10Data->Exponent;\r
-\r
-  Exponent -= 6;\r
-  while (Exponent != 0) {\r
-    if (Exponent > 0) {\r
-      Value = (INT16) (Value * 10);\r
-      Exponent--;\r
-    } else {\r
-      Value = (INT16) (Value / 10);\r
-      Exponent++;\r
-    }\r
-  }\r
-\r
-  CopyMem (\r
-    (UINT8 *) (StructureNode->Structure) + Offset,\r
-    &Value,\r
-    2\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a word, with 'Kilo'\r
-  as the unit. Granularity implemented for Cache Size.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER  RecordDataSize is invalid. \r
-  @retval EFI_SUCCESS            RecordData is successed to be filled into given SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldBase2ToWordWithKilo (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_EXP_BASE2_DATA  *Base2Data;\r
-  UINT32              Value;\r
-  UINT16              Exponent;\r
-\r
-  if (RecordDataSize != sizeof (EFI_EXP_BASE2_DATA)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Base2Data = RecordData;\r
-  Value     = Base2Data->Value;\r
-  Exponent  = Base2Data->Exponent;\r
-\r
-  Exponent -= 10;\r
-  Value <<= Exponent;\r
-  \r
-  //\r
-  // Implement cache size granularity\r
-  //\r
-  if(Value >= 0x8000) {\r
-    Value >>= 6;\r
-    Value |=  0x8000;\r
-  }\r
-  \r
-  CopyMem (\r
-    (UINT8 *) (StructureNode->Structure) + Offset,\r
-    &Value,\r
-    2\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a byte, with '64k'\r
-  as the unit.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER  RecordDataSize is invalid. \r
-  @retval EFI_SUCCESS            RecordData is successed to be filled into given SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldBase2ToByteWith64K (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_EXP_BASE2_DATA  *Base2Data;\r
-  UINT16              Value;\r
-  UINT16              Exponent;\r
-\r
-  if (RecordDataSize != sizeof (EFI_EXP_BASE2_DATA)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Base2Data = RecordData;\r
-  Value     = Base2Data->Value;\r
-  Exponent  = Base2Data->Exponent;\r
-  Exponent -= 16;\r
-  Value <<= Exponent;\r
-\r
-  CopyMem (\r
-    (UINT8 *) (StructureNode->Structure) + Offset,\r
-    &Value,\r
-    1\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Field Filling Function. Transform an EFI_EXP_BASE2_DATA to a word, with 10exp-9\r
-  as the unit.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER  RecordDataSize is invalid. \r
-  @retval EFI_SUCCESS            RecordData is successed to be filled into given SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldBase10ToByteWithNano (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_EXP_BASE10_DATA *Base10Data;\r
-  INT16               Value;\r
-  INT16               Exponent;\r
-\r
-  if (RecordDataSize != sizeof (EFI_EXP_BASE2_DATA)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  Base10Data  = RecordData;\r
-  Value       = Base10Data->Value;\r
-  Exponent    = Base10Data->Exponent;\r
-\r
-  Exponent += 9;\r
-  while (Exponent != 0) {\r
-    if (Exponent > 0) {\r
-      Value = (INT16) (Value * 10);\r
-      Exponent--;\r
-    } else {\r
-      Value = (INT16) (Value / 10);\r
-      Exponent++;\r
-    }\r
-  }\r
-\r
-  * (UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) Value;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Field Filling Function: truncate record data to byte and fill in the\r
-  field as indicated by Offset.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER  RecordDataSize is invalid. \r
-  @retval EFI_SUCCESS            RecordData is successed to be filled into given SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldTruncateToByte (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  // Truncate the data to 8 bits\r
-  //\r
-  *(UINT8 *) ((UINT8 *) (StructureNode->Structure) + Offset) = (UINT8) (*(UINT8 *) RecordData);\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Field Filling Function: truncate record data to byte and fill in the\r
-  field as indicated by Offset.\r
-  \r
-  @param StructureNode    Pointer to SMBIOS_STRUCTURE_NODE which is current processed.\r
-  @param Offset           Offset of SMBIOS record which RecordData will be filled.\r
-  @param RecordData       RecordData buffer will be filled.\r
-  @param RecordDataSize   The size of RecordData buffer.\r
-  \r
-  @retval EFI_INVALID_PARAMETER  RecordDataSize is invalid. \r
-  @retval EFI_SUCCESS            RecordData is successed to be filled into given SMBIOS record.\r
-**/\r
-EFI_STATUS\r
-SmbiosFldTruncateToWord (\r
-  IN OUT  SMBIOS_STRUCTURE_NODE     *StructureNode,\r
-  IN      UINT32                    Offset,\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  EFI_STATUS  Status;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  //\r
-  // Truncate the data to 8 bits\r
-  //\r
-  CopyMem (\r
-    (UINT8 *) (StructureNode->Structure) + Offset,\r
-    RecordData,\r
-    2\r
-    );\r
-\r
-  return Status;\r
-}\r
-\r
-/**\r
-  Check if OEM structure has included 2 trailing 0s in data record.\r
-  \r
-  @param RecordData       Point to record data will be checked.\r
-  @param RecordDataSize   The size of record data.\r
-  \r
-  @retval 0    2 trailing 0s exist in unformatted section\r
-  @retval 1    1 trailing 0 exists at the end of unformatted section\r
-  @retval -1   There is no 0 at the end of unformatted section\r
-**/\r
-INT8\r
-SmbiosCheckTrailingZero (\r
-  IN      VOID                      *RecordData,\r
-  IN      UINT32                    RecordDataSize\r
-  )\r
-{\r
-  SMBIOS_STRUCTURE  *Smbios;\r
-  CHAR8             *Start;\r
-  CHAR8             *End;\r
-  \r
-  Smbios = (SMBIOS_STRUCTURE *) RecordData;\r
-  \r
-  //\r
-  // Skip over formatted section\r
-  //\r
-  Start = (CHAR8 *) ((UINT8 *) Smbios + Smbios->Length);\r
-  End   = (CHAR8 *) RecordData + RecordDataSize;\r
-  \r
-  //\r
-  // Unformatted section exists\r
-  //\r
-  while (Start < End - 1) {\r
-    //\r
-    // Avoid unaligned issue on IPF\r
-    //\r
-    if ((*Start == 0) && (*(Start + 1) == 0)) {\r
-      //\r
-      // 2 trailing 0s exist in unformatted section\r
-      //\r
-      return 0;\r
-    }\r
-    Start++;\r
-  }\r
-  \r
-  if (Start == End - 1) {\r
-    //\r
-    // Check if there has been already 1 trailing 0\r
-    //\r
-    if (*Start == 0) {\r
-      return 1;\r
-    } \r
-  }\r
-  \r
-  //\r
-  // There is no 0 at the end of unformatted section\r
-  //\r
-  return -1;\r
-}\r