]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix bug where { NULL } did not terminate with a double NULL. Add support for passing...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 26 Jan 2012 08:49:22 +0000 (08:49 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 26 Jan 2012 08:49:22 +0000 (08:49 +0000)
signed-off-by: andrewfish

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12955 6f19259b-4bc3-4df7-8a09-765794883524

EmulatorPkg/CpuRuntimeDxe/Cpu.c

index 7be4146b4926b92a25c70b7a95c07ad42ad776ae..fc8d325ffc26a7488fca033d4cac6f2af1aeebd0 100644 (file)
@@ -137,12 +137,30 @@ CHAR8 *mCpuSmbiosType4Strings[] = {
 \r
 \r
 /**\r
-  Logs SMBIOS record.\r
-\r
-  Note: This should be a genric library function.\r
+  Create SMBIOS record.\r
+\r
+  Converts a fixed SMBIOS structure and an array of pointers to strings into\r
+  an SMBIOS record where the strings are cat'ed on the end of the fixed record\r
+  and terminated via a double NULL and add to SMBIOS table.\r
+\r
+  SMBIOS_TABLE_TYPE32 gSmbiosType12 = {\r
+    { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },\r
+    1 // StringCount\r
+  };\r
+  CHAR8 *gSmbiosType12Strings[] = {\r
+    "Not Found",\r
+    NULL\r
+  };\r
+  \r
+  ...\r
+  LogSmbiosData (\r
+    (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12, \r
+    gSmbiosType12Strings\r
+    );\r
 \r
-  @param  Template    Fixed SMBIOS structure\r
-  @param  StringPack  Array of strings to convert to an SMBIOS string pack. \r
+  @param  Template    Fixed SMBIOS structure, required.\r
+  @param  StringArray Array of strings to convert to an SMBIOS string pack. \r
+                      NULL is OK.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -170,12 +188,21 @@ LogSmbiosData (
 \r
   // Calculate the size of the fixed record and optional string pack\r
   Size = Template->Length;\r
-  for (Index = 0; StringPack[Index] != NULL; Index++) {\r
-    StringSize = AsciiStrSize (StringPack[Index]);\r
-    Size += StringSize;\r
+  if (StringPack == NULL) {\r
+    // At least a double null is required\r
+    Size += 2;\r
+  } else {\r
+    for (Index = 0; StringPack[Index] != NULL; Index++) {\r
+      StringSize = AsciiStrSize (StringPack[Index]);\r
+      Size += StringSize;\r
+    }\r
+    if (StringPack[0] == NULL) {\r
+      // At least a double null is required\r
+      Size += 1;\r
+    }\r
+    // Don't forget the terminating double null\r
+    Size += 1;\r
   }\r
-  // Don't forget the terminating double null\r
-  Size += 1;\r
 \r
   // Copy over Template\r
   Record = (EFI_SMBIOS_TABLE_HEADER *)AllocateZeroPool (Size);\r