]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c
MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY buffer
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / RuntimeDxe / VariableParsing.c
index d6bb916e68e73b61737107df09f710350375be42..870c9e3742c8cb35a94a8369ba1d45ce3277508e 100644 (file)
@@ -660,13 +660,14 @@ Done:
   the transaction. Data is allocated by this routine, but never\r
   freed.\r
 \r
-  @param[in] VariableName   Name of the Variable to track.\r
-  @param[in] VendorGuid     Guid of the Variable to track.\r
-  @param[in] Volatile       TRUE if volatile FALSE if non-volatile.\r
-  @param[in] Read           TRUE if GetVariable() was called.\r
-  @param[in] Write          TRUE if SetVariable() was called.\r
-  @param[in] Delete         TRUE if deleted via SetVariable().\r
-  @param[in] Cache          TRUE for a cache hit.\r
+  @param[in]      VariableName   Name of the Variable to track.\r
+  @param[in]      VendorGuid     Guid of the Variable to track.\r
+  @param[in]      Volatile       TRUE if volatile FALSE if non-volatile.\r
+  @param[in]      Read           TRUE if GetVariable() was called.\r
+  @param[in]      Write          TRUE if SetVariable() was called.\r
+  @param[in]      Delete         TRUE if deleted via SetVariable().\r
+  @param[in]      Cache          TRUE for a cache hit.\r
+  @param[in,out]  VariableInfo   Pointer to a pointer of VARIABLE_INFO_ENTRY structures.\r
 \r
 **/\r
 VOID\r
@@ -677,35 +678,38 @@ UpdateVariableInfo (
   IN  BOOLEAN                 Read,\r
   IN  BOOLEAN                 Write,\r
   IN  BOOLEAN                 Delete,\r
-  IN  BOOLEAN                 Cache\r
+  IN  BOOLEAN                 Cache,\r
+  IN OUT VARIABLE_INFO_ENTRY  **VariableInfo\r
   )\r
 {\r
   VARIABLE_INFO_ENTRY   *Entry;\r
 \r
   if (FeaturePcdGet (PcdVariableCollectStatistics)) {\r
-\r
+    if (VariableName == NULL || VendorGuid == NULL || VariableInfo == NULL) {\r
+      return;\r
+    }\r
     if (AtRuntime ()) {\r
       // Don't collect statistics at runtime.\r
       return;\r
     }\r
 \r
-    if (gVariableInfo == NULL) {\r
+    if (*VariableInfo == NULL) {\r
       //\r
       // On the first call allocate a entry and place a pointer to it in\r
       // the EFI System Table.\r
       //\r
-      gVariableInfo = AllocateZeroPool (sizeof (VARIABLE_INFO_ENTRY));\r
-      ASSERT (gVariableInfo != NULL);\r
-\r
-      CopyGuid (&gVariableInfo->VendorGuid, VendorGuid);\r
-      gVariableInfo->Name = AllocateZeroPool (StrSize (VariableName));\r
-      ASSERT (gVariableInfo->Name != NULL);\r
-      StrCpyS (gVariableInfo->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
-      gVariableInfo->Volatile = Volatile;\r
+      *VariableInfo = AllocateZeroPool (sizeof (VARIABLE_INFO_ENTRY));\r
+      ASSERT (*VariableInfo != NULL);\r
+\r
+      CopyGuid (&(*VariableInfo)->VendorGuid, VendorGuid);\r
+      (*VariableInfo)->Name = AllocateZeroPool (StrSize (VariableName));\r
+      ASSERT ((*VariableInfo)->Name != NULL);\r
+      StrCpyS ((*VariableInfo)->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
+      (*VariableInfo)->Volatile = Volatile;\r
     }\r
 \r
 \r
-    for (Entry = gVariableInfo; Entry != NULL; Entry = Entry->Next) {\r
+    for (Entry = (*VariableInfo); Entry != NULL; Entry = Entry->Next) {\r
       if (CompareGuid (VendorGuid, &Entry->VendorGuid)) {\r
         if (StrCmp (VariableName, Entry->Name) == 0) {\r
           if (Read) {\r
@@ -739,7 +743,6 @@ UpdateVariableInfo (
         StrCpyS (Entry->Next->Name, StrSize(VariableName)/sizeof(CHAR16), VariableName);\r
         Entry->Next->Volatile = Volatile;\r
       }\r
-\r
     }\r
   }\r
 }\r