]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the issue that if OEM SMBIOS data includes string, it will cause SmbiosFldMiscTyp...
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 9 Jun 2010 02:04:12 +0000 (02:04 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 9 Jun 2010 02:04:12 +0000 (02:04 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10569 6f19259b-4bc3-4df7-8a09-765794883524

EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/MiscConv.c
EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Thunk.h

index 3adaeffb5d030c574f3c0aa1ce57367d908cd1af..10208cecb4d551c9f6e6d93b78b33b729e25a588 100644 (file)
@@ -2,7 +2,7 @@
   Common filling functions used in translating Datahub's record\r
   to PI SMBIOS's record.\r
   \r
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>\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
@@ -158,6 +158,49 @@ SmbiosEnlargeStructureBuffer (
   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
index 3358a9667222c1d9443e00caf2641c7641fc503b..5c62cc6b537957b4da2426299ee220a19e44ddb9 100644 (file)
@@ -2391,30 +2391,28 @@ SmbiosFldMiscTypeOEM (
   ASSERT_EFI_ERROR (Status);\r
   \r
   if (StructureSize < RecordDataSize) {\r
-    Status = SmbiosEnlargeStructureBuffer (\r
-               StructureNode,\r
-               ((EFI_SMBIOS_TABLE_HEADER *)RecordData)->Length,\r
-               StructureSize,\r
-               RecordDataSize\r
-               );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
+    //\r
+    // Create new SMBIOS table entry\r
+    //\r
+    SmbiosUpdateStructureBuffer (\r
+      StructureNode,\r
+      RecordData\r
+      );\r
+  } else {\r
+    //\r
+    // Copy the entire data (including the Smbios structure header),\r
+    // but preserve the handle that is already allocated.\r
+    //\r
+    Handle = StructureNode->Structure->Handle;\r
+    CopyMem (\r
+      StructureNode->Structure,\r
+      RecordData,\r
+      RecordDataSize\r
+      );\r
+    StructureNode->Structure->Handle = Handle;\r
+    StructureNode->StructureSize = RecordDataSize;\r
   }\r
   \r
-  //\r
-  // Copy the entire data (including the Smbios structure header),\r
-  // but preserve the handle that is already allocated.\r
-  //\r
-  Handle = StructureNode->Structure->Handle;\r
-  CopyMem (\r
-    StructureNode->Structure,\r
-    RecordData,\r
-    RecordDataSize\r
-    );\r
-  StructureNode->Structure->Handle = Handle;\r
-  StructureNode->StructureSize = RecordDataSize;\r
-  \r
   if (NewRecordData != NULL) {\r
     FreePool (NewRecordData);\r
   }\r
index a35db23370874a117c5bafbefb021ba75498373d..a2f477dafa86275a75021dc93861befadf590200 100644 (file)
@@ -264,6 +264,20 @@ SmbiosEnlargeStructureBuffer (
   UINTN                         NewBufferSize\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
 /**\r
   Fill a standard Smbios string field. \r
   \r