From 0fb5e515f2f338c25679e2129ef81c4d230649b9 Mon Sep 17 00:00:00 2001 From: Star Zeng Date: Mon, 2 Feb 2015 09:30:34 +0000 Subject: MdeModulePkg Variable: Introduce PcdReclaimVariableSpaceAtEndOfDxe for trying to reclaim variable space at EndOfDxe. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng Reviewed-by: Liming Gao git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16687 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 9 +++++++++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c | 3 +++ .../Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf | 3 ++- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | 3 +++ MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf | 3 ++- 5 files changed, 19 insertions(+), 2 deletions(-) (limited to 'MdeModulePkg/Universal/Variable/RuntimeDxe') diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index 349128937b..b3c36992e3 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -3124,6 +3124,15 @@ ReclaimForOS( EFI_STATUS Status; UINTN RemainingCommonRuntimeVariableSpace; UINTN RemainingHwErrVariableSpace; + STATIC BOOLEAN Reclaimed; + + // + // This function will be called only once at EndOfDxe or ReadyToBoot event. + // + if (Reclaimed) { + return; + } + Reclaimed = TRUE; Status = EFI_SUCCESS; diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c index c61064efde..c5cef31944 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c @@ -313,6 +313,9 @@ OnEndOfDxe ( // The initialization for variable quota. // InitializeVariableQuota (); + if (PcdGetBool (PcdReclaimVariableSpaceAtEndOfDxe)) { + ReclaimForOS (); + } } /** diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf index ed6d1b5cbb..05d276590c 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf @@ -103,7 +103,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize ## CONSUMES - + gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe ## CONSUMES + [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics ## CONSUMES # statistic the information of variable. gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c index 815ee2e819..3bf545a4e0 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c @@ -832,6 +832,9 @@ SmmEndOfDxeCallback ( // The initialization for variable quota. // InitializeVariableQuota (); + if (PcdGetBool (PcdReclaimVariableSpaceAtEndOfDxe)) { + ReclaimForOS (); + } return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf index e57a731d15..b84ff87e43 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf @@ -105,7 +105,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize ## CONSUMES - + gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe ## CONSUMES + [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics ## CONSUMES # statistic the information of variable. gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate ## CONSUMES -- cgit v1.2.3