diff options
-rw-r--r-- | EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 17 | ||||
-rw-r--r-- | EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c index a9505d903c..d575417fe9 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -1389,6 +1389,23 @@ Returns: mVariableModuleGlobal->NonVolatileLastVariableOffset = (UINTN) NextVariable - (UINTN) CurrPtr;
//
+ // Check if the free area is blow a threshold
+ //
+ if ((((VARIABLE_STORE_HEADER *)((UINTN) CurrPtr))->Size - mVariableModuleGlobal->NonVolatileLastVariableOffset) < VARIABLE_RECLAIM_THRESHOLD) {
+ Status = Reclaim (
+ mVariableModuleGlobal->VariableBase[Physical].NonVolatileVariableBase,
+ &mVariableModuleGlobal->NonVolatileLastVariableOffset,
+ FALSE
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (mVariableModuleGlobal);
+ gBS->FreePool (VolatileVariableStore);
+ return Status;
+ }
+
+ //
// Check if the free area is really free.
//
for (Index = mVariableModuleGlobal->NonVolatileLastVariableOffset; Index < VariableStoreHeader->Size; Index++) {
diff --git a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h index 55423a25b9..014df50c3d 100644 --- a/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h +++ b/EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h @@ -35,6 +35,7 @@ Abstract: #define ALIGNMENT 1
#endif
+#define VARIABLE_RECLAIM_THRESHOLD (1024)
#define VARIABLE_STORE_SIZE (64 * 1024)
#define SCRATCH_SIZE (4 * 1024)
|