]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Variable/Pei/Variable.c
MdeModulePkg Variable: Abstract GetHobVariableStore function
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / Pei / Variable.c
index 4060f4711dd07dd4ea533971ee099895f809b585..1bcab3b770a5d4d3b40365601e5424d14f6e8100 100644 (file)
@@ -2,7 +2,7 @@
   Implement ReadOnly Variable Services required by PEIM and install\r
   PEI ReadOnly Varaiable2 PPI. These services operates the non volatile storage space.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, 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
@@ -495,6 +495,31 @@ CompareWithValidVariable (
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Get HOB variable store.\r
+\r
+**/\r
+VOID\r
+GetHobVariableStore (\r
+  OUT VARIABLE_STORE_INFO        *StoreInfo,\r
+  OUT VARIABLE_STORE_HEADER      **VariableStoreHeader\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE              *GuidHob;\r
+\r
+  GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);\r
+  if (GuidHob != NULL) {\r
+    *VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
+    StoreInfo->AuthFlag = TRUE;\r
+  } else {\r
+    GuidHob = GetFirstGuidHob (&gEfiVariableGuid);\r
+    if (GuidHob != NULL) {\r
+      *VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
+      StoreInfo->AuthFlag = FALSE;\r
+    }\r
+  }\r
+}\r
+\r
 /**\r
   Return the variable store header and the store info based on the Index.\r
 \r
@@ -523,17 +548,8 @@ GetVariableStore (
   VariableStoreHeader = NULL;\r
   switch (Type) {\r
     case VariableStoreTypeHob:\r
-      GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);\r
-      if (GuidHob != NULL) {\r
-        VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
-        StoreInfo->AuthFlag = TRUE;\r
-      } else {\r
-        GuidHob = GetFirstGuidHob (&gEfiVariableGuid);\r
-        if (GuidHob != NULL) {\r
-          VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
-          StoreInfo->AuthFlag = FALSE;\r
-        }\r
-      }\r
+      GetHobVariableStore (StoreInfo, &VariableStoreHeader);\r
+\r
       break;\r
 \r
     case VariableStoreTypeNv:\r