summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Variable
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2019-01-12 16:03:36 +0800
committerStar Zeng <star.zeng@intel.com>2019-01-24 10:52:32 +0800
commitb59fd889acc43a34030c20241cfcf102b442e5bf (patch)
treef64cef9a87911a126837122d964462454a790993 /MdeModulePkg/Universal/Variable
parent904e0ca9972eefca5e67e467c5f06b048fae3ff6 (diff)
downloadedk2-b59fd889acc43a34030c20241cfcf102b442e5bf.tar.gz
edk2-b59fd889acc43a34030c20241cfcf102b442e5bf.tar.bz2
edk2-b59fd889acc43a34030c20241cfcf102b442e5bf.zip
MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1323 Merge EmuVariable and Real variable driver. Abstract VariableWriteServiceInitializeDxe/Smm from FtwNotificationEvent/SmmFtwNotificationEvent, then VariableWriteServiceInitializeDxe/Smm could be not aware the NV storage is real or emulated. This patch prepares for adding emulated variable NV mode support in VariableRuntimeDxe. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Tested-by: Julien Grall <julien.grall@arm.com> Acked-by: Julien Grall <julien.grall@arm.com>
Diffstat (limited to 'MdeModulePkg/Universal/Variable')
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c55
-rw-r--r--MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c31
2 files changed, 60 insertions, 26 deletions
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index 30165ce4dc..521cb4ed24 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -342,6 +342,40 @@ OnEndOfDxe (
}
/**
+ Initializes variable write service for DXE.
+
+**/
+VOID
+VariableWriteServiceInitializeDxe (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = VariableWriteServiceInitialize ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));
+ }
+
+ //
+ // Some Secure Boot Policy Var (SecureBoot, etc) updates following other
+ // Secure Boot Policy Variable change. Record their initial value.
+ //
+ RecordSecureBootPolicyVarData();
+
+ //
+ // Install the Variable Write Architectural protocol.
+ //
+ Status = gBS->InstallProtocolInterface (
+ &mHandle,
+ &gEfiVariableWriteArchProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
Fault Tolerant Write protocol notification event handler.
Non-Volatile variable write may needs FTW protocol to reclaim when
@@ -423,27 +457,10 @@ FtwNotificationEvent (
}
}
- Status = VariableWriteServiceInitialize ();
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));
- }
-
//
- // Some Secure Boot Policy Var (SecureBoot, etc) updates following other
- // Secure Boot Policy Variable change. Record their initial value.
+ // Initializes variable write service after FTW was ready.
//
- RecordSecureBootPolicyVarData();
-
- //
- // Install the Variable Write Architectural protocol.
- //
- Status = gBS->InstallProtocolInterface (
- &mHandle,
- &gEfiVariableWriteArchProtocolGuid,
- EFI_NATIVE_INTERFACE,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
+ VariableWriteServiceInitializeDxe ();
//
// Close the notify event to avoid install gEfiVariableWriteArchProtocolGuid again.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 4b136464a2..e6734acdf2 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -840,6 +840,28 @@ SmmEndOfDxeCallback (
}
/**
+ Initializes variable write service for SMM.
+
+**/
+VOID
+VariableWriteServiceInitializeSmm (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+
+ Status = VariableWriteServiceInitialize ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));
+ }
+
+ //
+ // Notify the variable wrapper driver the variable write service is ready
+ //
+ VariableNotifySmmWriteReady ();
+}
+
+/**
SMM Fault Tolerant Write protocol notification event handler.
Non-Volatile variable write may needs FTW protocol to reclaim when
@@ -903,15 +925,10 @@ SmmFtwNotificationEvent (
mVariableModuleGlobal->FvbInstance = FvbProtocol;
- Status = VariableWriteServiceInitialize ();
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. Status = %r\n", Status));
- }
-
//
- // Notify the variable wrapper driver the variable write service is ready
+ // Initializes variable write service after FTW was ready.
//
- VariableNotifySmmWriteReady ();
+ VariableWriteServiceInitializeSmm ();
return EFI_SUCCESS;
}