summaryrefslogtreecommitdiff
path: root/EdkModulePkg/Universal
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-10 02:21:51 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2006-10-10 02:21:51 +0000
commitc65c1e1e1428a1a7c41a3b89a84383aa15624c7a (patch)
tree76568d095659b69cb8a79372dd3e547377b7a6ba /EdkModulePkg/Universal
parent5f5f28c90dc44075e9f9202b030c66300218f7c0 (diff)
downloadedk2-platforms-c65c1e1e1428a1a7c41a3b89a84383aa15624c7a.tar.xz
This patch is to make sure at least VARIABLE_RECLAIM_THRESHOLD (1024) bytes of spaces must be available in NV variable region. This conservative approach is make sure OS loader will have space to save important data.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1697 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkModulePkg/Universal')
-rw-r--r--EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.c17
-rw-r--r--EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h1
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)