]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg VariablePei: Merge from VariablePei in SecurityPkg
authorStar Zeng <star.zeng@intel.com>
Wed, 1 Jul 2015 03:03:26 +0000 (03:03 +0000)
committerlzeng14 <lzeng14@Edk2>
Wed, 1 Jul 2015 03:03:26 +0000 (03:03 +0000)
What to do:
1. Merge from VariablePei in SecurityPkg to VariablePei in MdeModulePkg.

Why to do:
1. Remove code duplication and reduce maintenance effort.
The code logic of VariablePei in SecurityPkg is same with VariablePei
in MdeModulePkg.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17756 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/Variable/Pei/PeiVariable.uni
MdeModulePkg/Universal/Variable/Pei/Variable.c
MdeModulePkg/Universal/Variable/Pei/Variable.h
MdeModulePkg/Universal/Variable/Pei/VariablePei.inf

index 830143bb2986dea174a32c5b11b2642c9c920293..7c11eff3c1f34dd93025df9d11563621b9389759 100644 (file)
Binary files a/MdeModulePkg/Universal/Variable/Pei/PeiVariable.uni and b/MdeModulePkg/Universal/Variable/Pei/PeiVariable.uni differ
index 97c86f2febe71cd41075f3d099c88ec17a13c27e..c68a41ddfe7dcb57b8479d54241774c8ad49af6d 100644 (file)
@@ -1,9 +1,8 @@
 /** @file\r
-\r
   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 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -34,8 +33,8 @@ EFI_PEI_PPI_DESCRIPTOR     mPpiListVariable = {
 \r
 /**\r
   Provide the functionality of the variable services.\r
-  \r
-  @param  FileHandle   Handle of the file being invoked. \r
+\r
+  @param  FileHandle   Handle of the file being invoked.\r
                        Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().\r
   @param  PeiServices  General purpose services available to every PEIM.\r
 \r
@@ -114,27 +113,65 @@ IsValidVariableHeader (
   return TRUE;\r
 }\r
 \r
+/**\r
+  This code gets the size of variable header.\r
+\r
+  @param AuthFlag   Authenticated variable flag.\r
+\r
+  @return Size of variable header in bytes in type UINTN.\r
+\r
+**/\r
+UINTN\r
+GetVariableHeaderSize (\r
+  IN  BOOLEAN       AuthFlag\r
+  )\r
+{\r
+  UINTN Value;\r
+\r
+  if (AuthFlag) {\r
+    Value = sizeof (AUTHENTICATED_VARIABLE_HEADER);\r
+  } else {\r
+    Value = sizeof (VARIABLE_HEADER);\r
+  }\r
+\r
+  return Value;\r
+}\r
 \r
 /**\r
   This code gets the size of name of variable.\r
 \r
   @param  Variable  Pointer to the Variable Header.\r
+  @param  AuthFlag  Authenticated variable flag.\r
 \r
   @return Size of variable in bytes in type UINTN.\r
 \r
 **/\r
 UINTN\r
 NameSizeOfVariable (\r
-  IN  VARIABLE_HEADER   *Variable\r
+  IN  VARIABLE_HEADER   *Variable,\r
+  IN  BOOLEAN           AuthFlag\r
   )\r
 {\r
-  if (Variable->State    == (UINT8) (-1) ||\r
-      Variable->DataSize == (UINT32) (-1) ||\r
-      Variable->NameSize == (UINT32) (-1) ||\r
-      Variable->Attributes == (UINT32) (-1)) {\r
-    return 0;\r
+  AUTHENTICATED_VARIABLE_HEADER *AuthVariable;\r
+\r
+  AuthVariable = (AUTHENTICATED_VARIABLE_HEADER *) Variable;\r
+  if (AuthFlag) {\r
+    if (AuthVariable->State == (UINT8) (-1) ||\r
+       AuthVariable->DataSize == (UINT32) (-1) ||\r
+       AuthVariable->NameSize == (UINT32) (-1) ||\r
+       AuthVariable->Attributes == (UINT32) (-1)) {\r
+      return 0;\r
+    }\r
+    return (UINTN) AuthVariable->NameSize;\r
+  } else {\r
+    if (Variable->State == (UINT8) (-1) ||\r
+       Variable->DataSize == (UINT32) (-1) ||\r
+       Variable->NameSize == (UINT32) (-1) ||\r
+       Variable->Attributes == (UINT32) (-1)) {\r
+      return 0;\r
+    }\r
+    return (UINTN) Variable->NameSize;\r
   }\r
-  return (UINTN) Variable->NameSize;\r
 }\r
 \r
 \r
@@ -142,46 +179,88 @@ NameSizeOfVariable (
   This code gets the size of data of variable.\r
 \r
   @param  Variable  Pointer to the Variable Header.\r
+  @param  AuthFlag  Authenticated variable flag.\r
 \r
   @return Size of variable in bytes in type UINTN.\r
 \r
 **/\r
 UINTN\r
 DataSizeOfVariable (\r
-  IN  VARIABLE_HEADER   *Variable\r
+  IN  VARIABLE_HEADER   *Variable,\r
+  IN  BOOLEAN           AuthFlag\r
   )\r
 {\r
-  if (Variable->State    == (UINT8)  (-1) ||\r
-      Variable->DataSize == (UINT32) (-1) ||\r
-      Variable->NameSize == (UINT32) (-1) ||\r
-      Variable->Attributes == (UINT32) (-1)) {\r
-    return 0;\r
+  AUTHENTICATED_VARIABLE_HEADER *AuthVariable;\r
+\r
+  AuthVariable = (AUTHENTICATED_VARIABLE_HEADER *) Variable;\r
+  if (AuthFlag) {\r
+    if (AuthVariable->State == (UINT8) (-1) ||\r
+       AuthVariable->DataSize == (UINT32) (-1) ||\r
+       AuthVariable->NameSize == (UINT32) (-1) ||\r
+       AuthVariable->Attributes == (UINT32) (-1)) {\r
+      return 0;\r
+    }\r
+    return (UINTN) AuthVariable->DataSize;\r
+  } else {\r
+    if (Variable->State == (UINT8) (-1) ||\r
+       Variable->DataSize == (UINT32) (-1) ||\r
+       Variable->NameSize == (UINT32) (-1) ||\r
+       Variable->Attributes == (UINT32) (-1)) {\r
+      return 0;\r
+    }\r
+    return (UINTN) Variable->DataSize;\r
   }\r
-  return (UINTN) Variable->DataSize;\r
 }\r
 \r
 /**\r
   This code gets the pointer to the variable name.\r
 \r
   @param   Variable  Pointer to the Variable Header.\r
+  @param   AuthFlag  Authenticated variable flag.\r
 \r
   @return  A CHAR16* pointer to Variable Name.\r
 \r
 **/\r
 CHAR16 *\r
 GetVariableNamePtr (\r
-  IN  VARIABLE_HEADER   *Variable\r
+  IN VARIABLE_HEADER    *Variable,\r
+  IN BOOLEAN            AuthFlag\r
   )\r
 {\r
-  return (CHAR16 *) (Variable + 1);\r
+  return (CHAR16 *) ((UINTN) Variable + GetVariableHeaderSize (AuthFlag));\r
 }\r
 \r
+/**\r
+  This code gets the pointer to the variable guid.\r
+\r
+  @param Variable   Pointer to the Variable Header.\r
+  @param AuthFlag   Authenticated variable flag.\r
+\r
+  @return A EFI_GUID* pointer to Vendor Guid.\r
+\r
+**/\r
+EFI_GUID *\r
+GetVendorGuidPtr (\r
+  IN VARIABLE_HEADER    *Variable,\r
+  IN BOOLEAN            AuthFlag\r
+  )\r
+{\r
+  AUTHENTICATED_VARIABLE_HEADER *AuthVariable;\r
+\r
+  AuthVariable = (AUTHENTICATED_VARIABLE_HEADER *) Variable;\r
+  if (AuthFlag) {\r
+    return &AuthVariable->VendorGuid;\r
+  } else {\r
+    return &Variable->VendorGuid;\r
+  }\r
+}\r
 \r
 /**\r
   This code gets the pointer to the variable data.\r
 \r
   @param   Variable         Pointer to the Variable Header.\r
   @param   VariableHeader   Pointer to the Variable Header that has consecutive content.\r
+  @param   AuthFlag         Authenticated variable flag.\r
 \r
   @return  A UINT8* pointer to Variable Data.\r
 \r
@@ -189,17 +268,18 @@ GetVariableNamePtr (
 UINT8 *\r
 GetVariableDataPtr (\r
   IN  VARIABLE_HEADER   *Variable,\r
-  IN  VARIABLE_HEADER   *VariableHeader\r
+  IN  VARIABLE_HEADER   *VariableHeader,\r
+  IN  BOOLEAN           AuthFlag\r
   )\r
 {\r
   UINTN Value;\r
-  \r
+\r
   //\r
   // Be careful about pad size for alignment\r
   //\r
-  Value =  (UINTN) GetVariableNamePtr (Variable);\r
-  Value += NameSizeOfVariable (VariableHeader);\r
-  Value += GET_PAD_SIZE (NameSizeOfVariable (VariableHeader));\r
+  Value =  (UINTN) GetVariableNamePtr (Variable, AuthFlag);\r
+  Value += NameSizeOfVariable (VariableHeader, AuthFlag);\r
+  Value += GET_PAD_SIZE (NameSizeOfVariable (VariableHeader, AuthFlag));\r
 \r
   return (UINT8 *) Value;\r
 }\r
@@ -226,9 +306,9 @@ GetNextVariablePtr (
   EFI_PHYSICAL_ADDRESS  SpareAddress;\r
   UINTN                 Value;\r
 \r
-  Value =  (UINTN) GetVariableDataPtr (Variable, VariableHeader);\r
-  Value += DataSizeOfVariable (VariableHeader);\r
-  Value += GET_PAD_SIZE (DataSizeOfVariable (VariableHeader));\r
+  Value =  (UINTN) GetVariableDataPtr (Variable, VariableHeader, StoreInfo->AuthFlag);\r
+  Value += DataSizeOfVariable (VariableHeader, StoreInfo->AuthFlag);\r
+  Value += GET_PAD_SIZE (DataSizeOfVariable (VariableHeader, StoreInfo->AuthFlag));\r
   //\r
   // Be careful about pad size for alignment\r
   //\r
@@ -263,7 +343,8 @@ GetVariableStoreStatus (
   IN VARIABLE_STORE_HEADER *VarStoreHeader\r
   )\r
 {\r
-  if (CompareGuid (&VarStoreHeader->Signature, &gEfiVariableGuid) &&\r
+  if ((CompareGuid (&VarStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) ||\r
+       CompareGuid (&VarStoreHeader->Signature, &gEfiVariableGuid)) &&\r
       VarStoreHeader->Format == VARIABLE_STORE_FORMATTED &&\r
       VarStoreHeader->State == VARIABLE_STORE_HEALTHY\r
       ) {\r
@@ -383,7 +464,10 @@ CompareWithValidVariable (
   OUT VARIABLE_POINTER_TRACK        *PtrTrack\r
   )\r
 {\r
-  VOID  *Point;\r
+  VOID      *Point;\r
+  EFI_GUID  *TempVendorGuid;\r
+\r
+  TempVendorGuid = GetVendorGuidPtr (VariableHeader, StoreInfo->AuthFlag);\r
 \r
   if (VariableName[0] == 0) {\r
     PtrTrack->CurrPtr = Variable;\r
@@ -394,14 +478,14 @@ CompareWithValidVariable (
     // Instead we compare the GUID a UINT32 at a time and branch\r
     // on the first failed comparison.\r
     //\r
-    if ((((INT32 *) VendorGuid)[0] == ((INT32 *) &VariableHeader->VendorGuid)[0]) &&\r
-        (((INT32 *) VendorGuid)[1] == ((INT32 *) &VariableHeader->VendorGuid)[1]) &&\r
-        (((INT32 *) VendorGuid)[2] == ((INT32 *) &VariableHeader->VendorGuid)[2]) &&\r
-        (((INT32 *) VendorGuid)[3] == ((INT32 *) &VariableHeader->VendorGuid)[3])\r
+    if ((((INT32 *) VendorGuid)[0] == ((INT32 *) TempVendorGuid)[0]) &&\r
+        (((INT32 *) VendorGuid)[1] == ((INT32 *) TempVendorGuid)[1]) &&\r
+        (((INT32 *) VendorGuid)[2] == ((INT32 *) TempVendorGuid)[2]) &&\r
+        (((INT32 *) VendorGuid)[3] == ((INT32 *) TempVendorGuid)[3])\r
         ) {\r
-      ASSERT (NameSizeOfVariable (VariableHeader) != 0);\r
-      Point = (VOID *) GetVariableNamePtr (Variable);\r
-      if (CompareVariableName (StoreInfo, VariableName, Point, NameSizeOfVariable (VariableHeader))) {\r
+      ASSERT (NameSizeOfVariable (VariableHeader, StoreInfo->AuthFlag) != 0);\r
+      Point = (VOID *) GetVariableNamePtr (Variable, StoreInfo->AuthFlag);\r
+      if (CompareVariableName (StoreInfo, VariableName, Point, NameSizeOfVariable (VariableHeader, StoreInfo->AuthFlag))) {\r
         PtrTrack->CurrPtr = Variable;\r
         return EFI_SUCCESS;\r
       }\r
@@ -435,12 +519,20 @@ GetVariableStore (
 \r
   StoreInfo->IndexTable = NULL;\r
   StoreInfo->FtwLastWriteData = NULL;\r
+  StoreInfo->AuthFlag = FALSE;\r
   VariableStoreHeader = NULL;\r
   switch (Type) {\r
     case VariableStoreTypeHob:\r
-      GuidHob     = GetFirstGuidHob (&gEfiVariableGuid);\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
       break;\r
 \r
@@ -451,8 +543,8 @@ GetVariableStore (
         //\r
 \r
         NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);\r
-        NvStorageBase = (EFI_PHYSICAL_ADDRESS) (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \r
-                                                PcdGet64 (PcdFlashNvStorageVariableBase64) : \r
+        NvStorageBase = (EFI_PHYSICAL_ADDRESS) (PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ?\r
+                                                PcdGet64 (PcdFlashNvStorageVariableBase64) :\r
                                                 PcdGet32 (PcdFlashNvStorageVariableBase)\r
                                                );\r
         //\r
@@ -496,6 +588,8 @@ GetVariableStore (
 \r
         VariableStoreHeader = (VARIABLE_STORE_HEADER *) ((UINT8 *) FvHeader + FvHeader->HeaderLength);\r
 \r
+        StoreInfo->AuthFlag = (BOOLEAN) (CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid));\r
+\r
         GuidHob = GetFirstGuidHob (&gEfiVariableIndexTableGuid);\r
         if (GuidHob != NULL) {\r
           StoreInfo->IndexTable = GET_GUID_HOB_DATA (GuidHob);\r
@@ -503,7 +597,7 @@ GetVariableStore (
           //\r
           // If it's the first time to access variable region in flash, create a guid hob to record\r
           // VAR_ADDED type variable info.\r
-          // Note that as the resource of PEI phase is limited, only store the limited number of \r
+          // Note that as the resource of PEI phase is limited, only store the limited number of\r
           // VAR_ADDED type variables to reduce access time.\r
           //\r
           StoreInfo->IndexTable = (VARIABLE_INDEX_TABLE *) BuildGuidHob (&gEfiVariableIndexTableGuid, sizeof (VARIABLE_INDEX_TABLE));\r
@@ -551,9 +645,9 @@ GetVariableHeader (
     return FALSE;\r
   }\r
 \r
-   //\r
-   // First assume variable header pointed by Variable is consecutive.\r
-   //\r
+  //\r
+  // First assume variable header pointed by Variable is consecutive.\r
+  //\r
   *VariableHeader = Variable;\r
 \r
   if (StoreInfo->FtwLastWriteData != NULL) {\r
@@ -566,7 +660,7 @@ GetVariableHeader (
       //\r
       return FALSE;\r
     }\r
-    if (((UINTN) Variable < (UINTN) TargetAddress) && (((UINTN) Variable + sizeof (VARIABLE_HEADER)) > (UINTN) TargetAddress)) {\r
+    if (((UINTN) Variable < (UINTN) TargetAddress) && (((UINTN) Variable + GetVariableHeaderSize (StoreInfo->AuthFlag)) > (UINTN) TargetAddress)) {\r
       //\r
       // Variable header pointed by Variable is inconsecutive,\r
       // create a guid hob to combine the two partial variable header content together.\r
@@ -575,7 +669,7 @@ GetVariableHeader (
       if (GuidHob != NULL) {\r
         *VariableHeader = (VARIABLE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
       } else {\r
-        *VariableHeader = (VARIABLE_HEADER *) BuildGuidHob (&gEfiCallerIdGuid, sizeof (VARIABLE_HEADER));\r
+        *VariableHeader = (VARIABLE_HEADER *) BuildGuidHob (&gEfiCallerIdGuid, GetVariableHeaderSize (StoreInfo->AuthFlag));\r
         PartialHeaderSize = (UINTN) TargetAddress - (UINTN) Variable;\r
         //\r
         // Partial content is in NV storage.\r
@@ -584,7 +678,7 @@ GetVariableHeader (
         //\r
         // Another partial content is in spare block.\r
         //\r
-        CopyMem ((UINT8 *) *VariableHeader + PartialHeaderSize, (UINT8 *) (UINTN) SpareAddress, sizeof (VARIABLE_HEADER) - PartialHeaderSize);\r
+        CopyMem ((UINT8 *) *VariableHeader + PartialHeaderSize, (UINT8 *) (UINTN) SpareAddress, GetVariableHeaderSize (StoreInfo->AuthFlag) - PartialHeaderSize);\r
       }\r
     }\r
   } else {\r
@@ -619,7 +713,7 @@ GetVariableNameOrData (
   EFI_PHYSICAL_ADDRESS  TargetAddress;\r
   EFI_PHYSICAL_ADDRESS  SpareAddress;\r
   UINTN                 PartialSize;\r
\r
+\r
   if (StoreInfo->FtwLastWriteData != NULL) {\r
     TargetAddress = StoreInfo->FtwLastWriteData->TargetAddress;\r
     SpareAddress = StoreInfo->FtwLastWriteData->SpareAddress;\r
@@ -826,7 +920,7 @@ FindVariable (
     Status = FindVariableEx (\r
                StoreInfo,\r
                VariableName,\r
-               VendorGuid, \r
+               VendorGuid,\r
                PtrTrack\r
                );\r
     if (!EFI_ERROR (Status)) {\r
@@ -840,7 +934,7 @@ FindVariable (
 /**\r
   This service retrieves a variable's value using its name and GUID.\r
 \r
-  Read the specified variable from the UEFI variable store. If the Data \r
+  Read the specified variable from the UEFI variable store. If the Data\r
   buffer is too small to hold the contents of the variable, the error\r
   EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer\r
   size to obtain the data.\r
@@ -856,8 +950,8 @@ FindVariable (
 \r
   @retval EFI_SUCCESS           The variable was read successfully.\r
   @retval EFI_NOT_FOUND         The variable could not be found.\r
-  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data. \r
-                                DataSize is updated with the size required for \r
+  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data.\r
+                                DataSize is updated with the size required for\r
                                 the specified variable.\r
   @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.\r
   @retval EFI_DEVICE_ERROR      The variable could not be retrieved because of a device error.\r
@@ -898,13 +992,13 @@ PeiGetVariable (
   //\r
   // Get data size\r
   //\r
-  VarDataSize = DataSizeOfVariable (VariableHeader);\r
+  VarDataSize = DataSizeOfVariable (VariableHeader, StoreInfo.AuthFlag);\r
   if (*DataSize >= VarDataSize) {\r
     if (Data == NULL) {\r
       return EFI_INVALID_PARAMETER;\r
     }\r
 \r
-    GetVariableNameOrData (&StoreInfo, GetVariableDataPtr (Variable.CurrPtr, VariableHeader), VarDataSize, Data);\r
+    GetVariableNameOrData (&StoreInfo, GetVariableDataPtr (Variable.CurrPtr, VariableHeader, StoreInfo.AuthFlag), VarDataSize, Data);\r
 \r
     if (Attributes != NULL) {\r
       *Attributes = VariableHeader->Attributes;\r
@@ -921,11 +1015,11 @@ PeiGetVariable (
 /**\r
   Return the next variable name and GUID.\r
 \r
-  This function is called multiple times to retrieve the VariableName \r
-  and VariableGuid of all variables currently available in the system. \r
-  On each call, the previous results are passed into the interface, \r
-  and, on return, the interface returns the data for the next \r
-  interface. When the entire variable list has been returned, \r
+  This function is called multiple times to retrieve the VariableName\r
+  and VariableGuid of all variables currently available in the system.\r
+  On each call, the previous results are passed into the interface,\r
+  and, on return, the interface returns the data for the next\r
+  interface. When the entire variable list has been returned,\r
   EFI_NOT_FOUND is returned.\r
 \r
   @param  This              A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
@@ -934,7 +1028,7 @@ PeiGetVariable (
                             On return, the size of the variable name buffer.\r
   @param  VariableName      On entry, a pointer to a null-terminated string that is the variable's name.\r
                             On return, points to the next variable's null-terminated name string.\r
-  @param  VariableGuid      On entry, a pointer to an EFI_GUID that is the variable's GUID. \r
+  @param  VariableGuid      On entry, a pointer to an EFI_GUID that is the variable's GUID.\r
                             On return, a pointer to the next variable's GUID.\r
 \r
   @retval EFI_SUCCESS           The variable was read successfully.\r
@@ -1013,7 +1107,7 @@ PeiGetNextVariableName (
         }\r
       }\r
       //\r
-      // Capture the case that \r
+      // Capture the case that\r
       // 1. current storage is the last one, or\r
       // 2. no further storage\r
       //\r
@@ -1035,8 +1129,8 @@ PeiGetNextVariableName (
         //\r
         Status = FindVariableEx (\r
                    &StoreInfo,\r
-                   GetVariableNamePtr (Variable.CurrPtr),\r
-                   &VariableHeader->VendorGuid,\r
+                   GetVariableNamePtr (Variable.CurrPtr, StoreInfo.AuthFlag),\r
+                   GetVendorGuidPtr (VariableHeader, StoreInfo.AuthFlag),\r
                    &VariablePtrTrack\r
                    );\r
         if (!EFI_ERROR (Status) && VariablePtrTrack.CurrPtr != Variable.CurrPtr) {\r
@@ -1053,8 +1147,8 @@ PeiGetNextVariableName (
          ) {\r
         Status = FindVariableEx (\r
                    &StoreInfoForHob,\r
-                   GetVariableNamePtr (Variable.CurrPtr),\r
-                   &VariableHeader->VendorGuid, \r
+                   GetVariableNamePtr (Variable.CurrPtr, StoreInfo.AuthFlag),\r
+                   GetVendorGuidPtr (VariableHeader, StoreInfo.AuthFlag),\r
                    &VariableInHob\r
                    );\r
         if (!EFI_ERROR (Status)) {\r
@@ -1063,13 +1157,13 @@ PeiGetNextVariableName (
         }\r
       }\r
 \r
-      VarNameSize = NameSizeOfVariable (VariableHeader);\r
+      VarNameSize = NameSizeOfVariable (VariableHeader, StoreInfo.AuthFlag);\r
       ASSERT (VarNameSize != 0);\r
 \r
       if (VarNameSize <= *VariableNameSize) {\r
-        GetVariableNameOrData (&StoreInfo, (UINT8 *) GetVariableNamePtr (Variable.CurrPtr), VarNameSize, (UINT8 *) VariableName);\r
+        GetVariableNameOrData (&StoreInfo, (UINT8 *) GetVariableNamePtr (Variable.CurrPtr, StoreInfo.AuthFlag), VarNameSize, (UINT8 *) VariableName);\r
 \r
-        CopyMem (VariableGuid, &VariableHeader->VendorGuid, sizeof (EFI_GUID));\r
+        CopyMem (VariableGuid, GetVendorGuidPtr (VariableHeader, StoreInfo.AuthFlag), sizeof (EFI_GUID));\r
 \r
         Status = EFI_SUCCESS;\r
       } else {\r
index 55277b04f162595df1375008de030732b370a9ac..580d69fb42c539666c67e4a25f0d8576267c9bff 100644 (file)
@@ -1,9 +1,8 @@
 /** @file\r
-\r
   The internal header file includes the common header files, defines\r
   internal structure and functions used by PeiVariable module.\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -48,6 +47,7 @@ typedef struct {
   // in spare block.\r
   //\r
   FAULT_TOLERANT_WRITE_LAST_WRITE_DATA    *FtwLastWriteData;\r
+  BOOLEAN                                 AuthFlag;\r
 } VARIABLE_STORE_INFO;\r
 \r
 //\r
@@ -55,8 +55,8 @@ typedef struct {
 //\r
 /**\r
   Provide the functionality of the variable services.\r
-  \r
-  @param  FileHandle  Handle of the file being invoked. \r
+\r
+  @param  FileHandle  Handle of the file being invoked.\r
                       Type EFI_PEI_FILE_HANDLE is defined in FfsFindNextFile().\r
   @param  PeiServices  General purpose services available to every PEIM.\r
 \r
@@ -74,7 +74,7 @@ PeimInitializeVariableServices (
 /**\r
   This service retrieves a variable's value using its name and GUID.\r
 \r
-  Read the specified variable from the UEFI variable store. If the Data \r
+  Read the specified variable from the UEFI variable store. If the Data\r
   buffer is too small to hold the contents of the variable, the error\r
   EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer\r
   size to obtain the data.\r
@@ -90,8 +90,8 @@ PeimInitializeVariableServices (
 \r
   @retval EFI_SUCCESS           The variable was read successfully.\r
   @retval EFI_NOT_FOUND         The variable could not be found.\r
-  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data. \r
-                                DataSize is updated with the size required for \r
+  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting data.\r
+                                DataSize is updated with the size required for\r
                                 the specified variable.\r
   @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data is NULL.\r
   @retval EFI_DEVICE_ERROR      The variable could not be retrieved because of a device error.\r
@@ -111,11 +111,11 @@ PeiGetVariable (
 /**\r
   Return the next variable name and GUID.\r
 \r
-  This function is called multiple times to retrieve the VariableName \r
-  and VariableGuid of all variables currently available in the system. \r
-  On each call, the previous results are passed into the interface, \r
-  and, on return, the interface returns the data for the next \r
-  interface. When the entire variable list has been returned, \r
+  This function is called multiple times to retrieve the VariableName\r
+  and VariableGuid of all variables currently available in the system.\r
+  On each call, the previous results are passed into the interface,\r
+  and, on return, the interface returns the data for the next\r
+  interface. When the entire variable list has been returned,\r
   EFI_NOT_FOUND is returned.\r
 \r
   @param  This              A pointer to this instance of the EFI_PEI_READ_ONLY_VARIABLE2_PPI.\r
@@ -124,7 +124,7 @@ PeiGetVariable (
   @param  VariableName      On entry, a pointer to a null-terminated string that is the variable's name.\r
                             On return, points to the next variable's null-terminated name string.\r
 \r
-  @param  VariableGuid      On entry, a pointer to an UEFI _GUID that is the variable's GUID. \r
+  @param  VariableGuid      On entry, a pointer to an UEFI _GUID that is the variable's GUID.\r
                             On return, a pointer to the next variable's GUID.\r
 \r
   @retval EFI_SUCCESS           The variable was read successfully.\r
index 6404562d4f1b4ccdd83c79ec03de7d86a1c14a6e..72a440dcd187ca1c2dedb013e7acd3645a6f7f9f 100644 (file)
@@ -1,7 +1,9 @@
 ## @file\r
-#  Implement ReadOnly Variable Services required by PEIM and install PEI ReadOnly Varaiable2 PPI.\r
+#  Implements ReadOnly Variable Services required by PEIM and installs PEI ReadOnly Varaiable2 PPI.\r
 #\r
-#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+#  This module implements ReadOnly Variable Services required by PEIM and installs PEI ReadOnly Varaiable2 PPI.\r
+#\r
+#  Copyright (c) 2006 - 2015, 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
@@ -47,6 +49,9 @@
 [Guids]\r
   ## CONSUMES             ## GUID # Variable store header\r
   ## SOMETIMES_CONSUMES   ## HOB\r
+  gEfiAuthenticatedVariableGuid\r
+  ## SOMETIMES_CONSUMES   ## GUID # Variable store header\r
+  ## SOMETIMES_CONSUMES   ## HOB\r
   gEfiVariableGuid\r
   ## SOMETIMES_PRODUCES   ## HOB\r
   ## SOMETIMES_CONSUMES   ## HOB\r