diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-10-10 02:21:51 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-10-10 02:21:51 +0000 |
commit | c65c1e1e1428a1a7c41a3b89a84383aa15624c7a (patch) | |
tree | 76568d095659b69cb8a79372dd3e547377b7a6ba | |
parent | 5f5f28c90dc44075e9f9202b030c66300218f7c0 (diff) | |
download | edk2-c65c1e1e1428a1a7c41a3b89a84383aa15624c7a.tar.gz edk2-c65c1e1e1428a1a7c41a3b89a84383aa15624c7a.tar.bz2 edk2-c65c1e1e1428a1a7c41a3b89a84383aa15624c7a.zip |
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
-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)
|