X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FVariable%2FRuntimeDxe%2FReclaim.c;h=9c351a3547e748b1178bb71f4c5aae60bbd5065b;hp=ed68f12017f737270d28ee2949e14b4a075134b7;hb=88a5561c66bccd27c0fe4c3d7d0b3c235b2ae531;hpb=8ef155106f6f10f5be50153b239df3e5422cc770 diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Reclaim.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Reclaim.c index ed68f12017..9c351a3547 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Reclaim.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Reclaim.c @@ -16,8 +16,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Variable.h" -#include +/** + Gets firmware volume block handle by given address. + + This function gets firmware volume block handle whose + address range contains the parameter Address. + + @param Address Address which should be contained + by returned FVB handle + @param FvbHandle Pointer to FVB handle for output + + @retval EFI_SUCCESS FVB handle successfully returned + @retval EFI_NOT_FOUND Fail to find FVB handle by address + +**/ EFI_STATUS GetFvbHandleByAddress ( IN EFI_PHYSICAL_ADDRESS Address, @@ -79,6 +92,23 @@ GetFvbHandleByAddress ( return Status; } +/** + Gets LBA of block and offset by given address. + + This function gets the Logical Block Address (LBA) of firmware + volume block containing the given address, and the offset of + address on the block. + + @param Address Address which should be contained + by returned FVB handle + @param Lba Pointer to LBA for output + @param Offset Pointer to offset for output + + @retval EFI_SUCCESS LBA and offset successfully returned + @retval EFI_NOT_FOUND Fail to find FVB handle by address + @retval EFI_ABORTED Fail to find valid LBA and offset + +**/ EFI_STATUS GetLbaAndOffsetByAddress ( IN EFI_PHYSICAL_ADDRESS Address, @@ -148,44 +178,44 @@ GetLbaAndOffsetByAddress ( return EFI_ABORTED; } +/** + Writes a buffer to variable storage space, in the working block. + + This function writes a buffer to variable storage space into firmware + volume block device. The destination is specified by parameter + 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 + + @retval EFI_SUCCESS The function completed successfully + @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol + @retval EFI_ABORTED The function could not complete successfully + +**/ EFI_STATUS FtwVariableSpace ( IN EFI_PHYSICAL_ADDRESS VariableBase, IN UINT8 *Buffer, IN UINTN BufferSize ) -/*++ - -Routine Description: - Write a buffer to Variable space, in the working block. - -Arguments: - FvbHandle - Indicates a handle to FVB to access variable store - Buffer - Point to the input buffer - BufferSize - The number of bytes of the input Buffer - -Returns: - EFI_SUCCESS - The function completed successfully - EFI_ABORTED - The function could not complete successfully - EFI_NOT_FOUND - Locate FVB protocol by handle fails - ---*/ { - EFI_STATUS Status; - EFI_HANDLE FvbHandle; - EFI_FTW_LITE_PROTOCOL *FtwLiteProtocol; - EFI_LBA VarLba; - UINTN VarOffset; - UINT8 *FtwBuffer; - UINTN FtwBufferSize; + EFI_STATUS Status; + EFI_HANDLE FvbHandle; + EFI_LBA VarLba; + UINTN VarOffset; + UINT8 *FtwBuffer; + UINTN FtwBufferSize; + EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol; // // Locate fault tolerant write protocol // Status = gBS->LocateProtocol ( - &gEfiFaultTolerantWriteLiteProtocolGuid, + &gEfiFaultTolerantWriteProtocolGuid, NULL, - (VOID **) &FtwLiteProtocol + (VOID **) &FtwProtocol ); if (EFI_ERROR (Status)) { return EFI_NOT_FOUND; @@ -219,13 +249,14 @@ Returns: // // FTW write record // - Status = FtwLiteProtocol->Write ( - FtwLiteProtocol, - FvbHandle, + Status = FtwProtocol->Write ( + FtwProtocol, VarLba, // LBA VarOffset, // Offset - &FtwBufferSize, // NumBytes, - FtwBuffer + FtwBufferSize, // NumBytes + NULL, // PrivateData NULL + FvbHandle, // Fvb Handle + FtwBuffer // write buffer ); FreePool (FtwBuffer);