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
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
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
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