Change IPF version AuthVariable driver to support multiple-platform feature.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Nov 2011 02:40:28 +0000 (02:40 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 17 Nov 2011 02:40:28 +0000 (02:40 +0000)
Signed-off-by: rni2
Reviewed-by: erictian
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12730 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h

index dc161c9a9a047592940e68366886200f49cd5213..f6eece98d7e5af4c013abf4fa4c2beb9828bae37 100644 (file)
@@ -57,6 +57,7 @@
   PcdLib\r
   ExtendedSalLib\r
   BaseCryptLib\r
   PcdLib\r
   ExtendedSalLib\r
   BaseCryptLib\r
+  HobLib\r
 \r
 [Protocols]\r
   gEfiFirmwareVolumeBlockProtocolGuid           # PROTOCOL SOMETIMES_CONSUMED\r
 \r
 [Protocols]\r
   gEfiFirmwareVolumeBlockProtocolGuid           # PROTOCOL SOMETIMES_CONSUMED\r
index 0cf8141ce64fc5b382f6e124d6e7491a823e0503..0f1d6456225051115dbb4d281ec32370b52789ee 100644 (file)
@@ -223,6 +223,8 @@ VariableServiceInitialize (
   Status = AutenticatedVariableServiceInitialize ();\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   Status = AutenticatedVariableServiceInitialize ();\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  FlushHob2Nv ();\r
+\r
   //\r
   // Register All the Functions with Extended SAL Variable Services Class\r
   //\r
   //\r
   // Register All the Functions with Extended SAL Variable Services Class\r
   //\r
index 2be925d2366ad84b976f2d62aebf3606aaee288d..d0269c9da744d9e8112c99d2f1ee131592bdbc3b 100644 (file)
@@ -2938,6 +2938,58 @@ ReclaimForOS(
   }\r
 }\r
 \r
   }\r
 }\r
 \r
+/**\r
+  Flush the HOB variable to NV variable storage.\r
+**/\r
+VOID\r
+FlushHob2Nv (\r
+  VOID\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  VOID                            *GuidHob;\r
+  VARIABLE_STORE_HEADER           *VariableStoreHeader;\r
+  VARIABLE_HEADER                 *VariableHeader;\r
+  //\r
+  // Get HOB variable store.\r
+  //\r
+  GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);\r
+  if (GuidHob != NULL) {\r
+    VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);\r
+    if (CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) &&\r
+        (VariableStoreHeader->Format == VARIABLE_STORE_FORMATTED) &&\r
+        (VariableStoreHeader->State == VARIABLE_STORE_HEALTHY)\r
+       ) {\r
+      DEBUG ((EFI_D_INFO, "HOB Variable Store appears to be valid.\n"));\r
+      //\r
+      // Flush the HOB variable to NV Variable storage.\r
+      //\r
+      for ( VariableHeader = (VARIABLE_HEADER *) HEADER_ALIGN (VariableStoreHeader + 1)\r
+          ; (VariableHeader < (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) VariableStoreHeader + VariableStoreHeader->Size)\r
+            &&\r
+            (VariableHeader->StartId == VARIABLE_DATA))\r
+          ; VariableHeader = (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) (VariableHeader + 1)\r
+                           + VariableHeader->NameSize + GET_PAD_SIZE (VariableHeader->NameSize)\r
+                           + VariableHeader->DataSize + GET_PAD_SIZE (VariableHeader->DataSize)\r
+                           )\r
+          ) {\r
+        ASSERT (VariableHeader->State == VAR_ADDED);\r
+        ASSERT ((VariableHeader->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0);\r
+        Status = EsalSetVariable (\r
+                   (CHAR16 *) (VariableHeader + 1),\r
+                   &VariableHeader->VendorGuid,\r
+                   VariableHeader->Attributes,\r
+                   VariableHeader->DataSize,\r
+                   (UINT8 *) (VariableHeader + 1) + VariableHeader->NameSize + GET_PAD_SIZE (VariableHeader->NameSize),\r
+                   Physical,\r
+                   mVariableModuleGlobal\r
+                   );\r
+        ASSERT_EFI_ERROR (Status);\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
 /**\r
   Initializes variable store area for non-volatile and volatile variable.\r
 \r
 /**\r
   Initializes variable store area for non-volatile and volatile variable.\r
 \r
index ecff20fb80f18568368e820a5cd5738215c32084..5e6690ed70fa272efae7ca86d1b5f98c1ca86fac 100644 (file)
@@ -30,6 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Guid/EventGroup.h>\r
 \r
 #include <Library/PcdLib.h>\r
 #include <Guid/EventGroup.h>\r
 \r
 #include <Library/PcdLib.h>\r
+#include <Library/HobLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/DxeServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/DxeServicesTableLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
@@ -493,4 +494,12 @@ IsValidVariableHeader (
   OUT VARIABLE_HEADER        *VariableHeader  OPTIONAL\r
   );\r
 \r
   OUT VARIABLE_HEADER        *VariableHeader  OPTIONAL\r
   );\r
 \r
+/**\r
+  Flush the HOB variable to NV variable storage.\r
+**/\r
+VOID\r
+FlushHob2Nv (\r
+  VOID\r
+  );\r
+\r
 #endif\r
 #endif\r