]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/Pei/Variable.c
MdeModulePkg Variable: Fix comment typo 'end' to 'start'
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Pei / Variable.c
index 1bcab3b770a5d4d3b40365601e5424d14f6e8100..77b3eaeb210ddfcf91e249d6ce1304f0638098be 100644 (file)
@@ -57,7 +57,7 @@ PeimInitializeVariableServices (
 \r
   @param VarStoreHeader  Pointer to the Variable Store Header.\r
 \r
-  @return Pointer to the first variable header\r
+  @return Pointer to the first variable header.\r
 \r
 **/\r
 VARIABLE_HEADER *\r
@@ -66,18 +66,22 @@ GetStartPointer (
   )\r
 {\r
   //\r
-  // The end of variable store\r
+  // The start of variable store\r
   //\r
   return (VARIABLE_HEADER *) HEADER_ALIGN (VarStoreHeader + 1);\r
 }\r
 \r
 \r
 /**\r
-  This code gets the pointer to the last variable memory pointer byte.\r
 \r
-  @param  VarStoreHeader  Pointer to the Variable Store Header.\r
+  Gets the pointer to the end of the variable storage area.\r
+\r
+  This function gets pointer to the end of the variable storage\r
+  area, according to the input variable store header.\r
+\r
+  @param VarStoreHeader  Pointer to the Variable Store Header.\r
 \r
-  @return VARIABLE_HEADER* pointer to last unavailable Variable Header.\r
+  @return Pointer to the end of the variable storage area.\r
 \r
 **/\r
 VARIABLE_HEADER *\r
@@ -498,6 +502,9 @@ CompareWithValidVariable (
 /**\r
   Get HOB variable store.\r
 \r
+  @param[out] StoreInfo             Return the store info.\r
+  @param[out] VariableStoreHeader   Return variable store header.\r
+\r
 **/\r
 VOID\r
 GetHobVariableStore (\r
@@ -507,6 +514,30 @@ GetHobVariableStore (
 {\r
   EFI_HOB_GUID_TYPE              *GuidHob;\r
 \r
+  //\r
+  // Make sure there is no more than one Variable HOB.\r
+  //\r
+  DEBUG_CODE (\r
+    GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);\r
+    if (GuidHob != NULL) {\r
+      if ((GetNextGuidHob (&gEfiAuthenticatedVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {\r
+        DEBUG ((DEBUG_ERROR, "ERROR: Found two Auth Variable HOBs\n"));\r
+        ASSERT (FALSE);\r
+      } else if (GetFirstGuidHob (&gEfiVariableGuid) != NULL) {\r
+        DEBUG ((DEBUG_ERROR, "ERROR: Found one Auth + one Normal Variable HOBs\n"));\r
+        ASSERT (FALSE);\r
+      }\r
+    } else {\r
+      GuidHob = GetFirstGuidHob (&gEfiVariableGuid);\r
+      if (GuidHob != NULL) {\r
+        if ((GetNextGuidHob (&gEfiVariableGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {\r
+          DEBUG ((DEBUG_ERROR, "ERROR: Found two Normal Variable HOBs\n"));\r
+          ASSERT (FALSE);\r
+        }\r
+      }\r
+    }\r
+  );\r
+\r
   GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);\r
   if (GuidHob != NULL) {\r
     *VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r