summaryrefslogtreecommitdiff
path: root/SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c
diff options
context:
space:
mode:
authorStar Zeng <star.zeng@intel.com>2013-11-12 13:31:43 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2013-11-12 13:31:43 +0000
commit128ef095b06aa16dfb2aa990af41de85eb6f6ea7 (patch)
tree262df7caffbdbbaef1f9a82fa67631c7fd6c050d /SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c
parent414ec461463dd9cf2c68e8b6799cef7e819cffa8 (diff)
downloadedk2-platforms-128ef095b06aa16dfb2aa990af41de85eb6f6ea7.tar.xz
MdeModulePkg and SecurityPkg Variable: Optimize the code to reduce some SMRAM consumption during variable reclaiming.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14832 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c')
-rw-r--r--SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c24
1 files changed, 6 insertions, 18 deletions
diff --git a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c
index 4f7a41cd09..b20facd9d8 100644
--- a/SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c
+++ b/SecurityPkg/VariableAuthenticated/RuntimeDxe/Reclaim.c
@@ -2,7 +2,7 @@
Handles non-volatile variable store garbage collection, using FTW
(Fault Tolerant Write) protocol.
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -98,8 +98,7 @@ GetLbaAndOffsetByAddress (
VariableBase. Fault Tolerant Write protocol is used for writing.
@param VariableBase Base address of variable to write
- @param Buffer Point to the data buffer.
- @param BufferSize The number of bytes of the data Buffer.
+ @param VariableBuffer Point to the variable data buffer.
@retval EFI_SUCCESS The function completed successfully.
@retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol.
@@ -109,15 +108,13 @@ GetLbaAndOffsetByAddress (
EFI_STATUS
FtwVariableSpace (
IN EFI_PHYSICAL_ADDRESS VariableBase,
- IN UINT8 *Buffer,
- IN UINTN BufferSize
+ IN VARIABLE_STORE_HEADER *VariableBuffer
)
{
EFI_STATUS Status;
EFI_HANDLE FvbHandle;
EFI_LBA VarLba;
UINTN VarOffset;
- UINT8 *FtwBuffer;
UINTN FtwBufferSize;
EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
@@ -142,17 +139,9 @@ FtwVariableSpace (
if (EFI_ERROR (Status)) {
return EFI_ABORTED;
}
- //
- // Prepare for the variable data.
- //
- FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;
- FtwBuffer = AllocatePool (FtwBufferSize);
- if (FtwBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- SetMem (FtwBuffer, FtwBufferSize, (UINT8) 0xff);
- CopyMem (FtwBuffer, Buffer, BufferSize);
+ FtwBufferSize = ((VARIABLE_STORE_HEADER *) ((UINTN) VariableBase))->Size;
+ ASSERT (FtwBufferSize == VariableBuffer->Size);
//
// FTW write record.
@@ -164,9 +153,8 @@ FtwVariableSpace (
FtwBufferSize, // NumBytes
NULL, // PrivateData NULL
FvbHandle, // Fvb Handle
- FtwBuffer // write buffer
+ (VOID *) VariableBuffer // write buffer
);
- FreePool (FtwBuffer);
return Status;
}