summaryrefslogtreecommitdiff
path: root/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-17 02:40:28 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-17 02:40:28 +0000
commit4f8ef5ce4ee883756bede7c134f14cda12ca248e (patch)
treee2ec1db4041cd8e470faf3bce1f29adef1944435 /SecurityPkg/VariableAuthenticated/EsalVariableDxeSal
parent53e6937c20448f7c5c761906e9f1765a57802f63 (diff)
downloadedk2-platforms-4f8ef5ce4ee883756bede7c134f14cda12ca248e.tar.xz
Change IPF version AuthVariable driver to support multiple-platform feature.
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
Diffstat (limited to 'SecurityPkg/VariableAuthenticated/EsalVariableDxeSal')
-rw-r--r--SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf1
-rw-r--r--SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c2
-rw-r--r--SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c52
-rw-r--r--SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h9
4 files changed, 64 insertions, 0 deletions
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
index dc161c9a9a..f6eece98d7 100644
--- a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
+++ b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/EsalVariableDxeSal.inf
@@ -57,6 +57,7 @@
PcdLib
ExtendedSalLib
BaseCryptLib
+ HobLib
[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c
index 0cf8141ce6..0f1d645622 100644
--- a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c
+++ b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/InitVariable.c
@@ -223,6 +223,8 @@ VariableServiceInitialize (
Status = AutenticatedVariableServiceInitialize ();
ASSERT_EFI_ERROR (Status);
+ FlushHob2Nv ();
+
//
// Register All the Functions with Extended SAL Variable Services Class
//
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
index 2be925d236..d0269c9da7 100644
--- a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
+++ b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.c
@@ -2939,6 +2939,58 @@ ReclaimForOS(
}
/**
+ Flush the HOB variable to NV variable storage.
+**/
+VOID
+FlushHob2Nv (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *GuidHob;
+ VARIABLE_STORE_HEADER *VariableStoreHeader;
+ VARIABLE_HEADER *VariableHeader;
+ //
+ // Get HOB variable store.
+ //
+ GuidHob = GetFirstGuidHob (&gEfiAuthenticatedVariableGuid);
+ if (GuidHob != NULL) {
+ VariableStoreHeader = (VARIABLE_STORE_HEADER *) GET_GUID_HOB_DATA (GuidHob);
+ if (CompareGuid (&VariableStoreHeader->Signature, &gEfiAuthenticatedVariableGuid) &&
+ (VariableStoreHeader->Format == VARIABLE_STORE_FORMATTED) &&
+ (VariableStoreHeader->State == VARIABLE_STORE_HEALTHY)
+ ) {
+ DEBUG ((EFI_D_INFO, "HOB Variable Store appears to be valid.\n"));
+ //
+ // Flush the HOB variable to NV Variable storage.
+ //
+ for ( VariableHeader = (VARIABLE_HEADER *) HEADER_ALIGN (VariableStoreHeader + 1)
+ ; (VariableHeader < (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) VariableStoreHeader + VariableStoreHeader->Size)
+ &&
+ (VariableHeader->StartId == VARIABLE_DATA))
+ ; VariableHeader = (VARIABLE_HEADER *) HEADER_ALIGN ((UINTN) (VariableHeader + 1)
+ + VariableHeader->NameSize + GET_PAD_SIZE (VariableHeader->NameSize)
+ + VariableHeader->DataSize + GET_PAD_SIZE (VariableHeader->DataSize)
+ )
+ ) {
+ ASSERT (VariableHeader->State == VAR_ADDED);
+ ASSERT ((VariableHeader->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0);
+ Status = EsalSetVariable (
+ (CHAR16 *) (VariableHeader + 1),
+ &VariableHeader->VendorGuid,
+ VariableHeader->Attributes,
+ VariableHeader->DataSize,
+ (UINT8 *) (VariableHeader + 1) + VariableHeader->NameSize + GET_PAD_SIZE (VariableHeader->NameSize),
+ Physical,
+ mVariableModuleGlobal
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+ }
+}
+
+/**
Initializes variable store area for non-volatile and volatile variable.
This function allocates and initializes memory space for global context of ESAL
diff --git a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h
index ecff20fb80..5e6690ed70 100644
--- a/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h
+++ b/SecurityPkg/VariableAuthenticated/EsalVariableDxeSal/Variable.h
@@ -30,6 +30,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Guid/EventGroup.h>
#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
@@ -493,4 +494,12 @@ IsValidVariableHeader (
OUT VARIABLE_HEADER *VariableHeader OPTIONAL
);
+/**
+ Flush the HOB variable to NV variable storage.
+**/
+VOID
+FlushHob2Nv (
+ VOID
+ );
+
#endif