\r
\r
#include "Variable.h"\r
-#include <VariableFormat.h>\r
\r
+/**\r
+ Gets firmware volume block handle by given address.\r
+\r
+ This function gets firmware volume block handle whose\r
+ address range contains the parameter Address.\r
+\r
+ @param Address Address which should be contained\r
+ by returned FVB handle\r
+ @param FvbHandle Pointer to FVB handle for output\r
+\r
+ @retval EFI_SUCCESS FVB handle successfully returned\r
+ @retval EFI_NOT_FOUND Fail to find FVB handle by address\r
+\r
+**/\r
EFI_STATUS\r
GetFvbHandleByAddress (\r
IN EFI_PHYSICAL_ADDRESS Address,\r
return Status;\r
}\r
\r
+/**\r
+ Gets LBA of block and offset by given address.\r
+\r
+ This function gets the Logical Block Address (LBA) of firmware\r
+ volume block containing the given address, and the offset of\r
+ address on the block.\r
+\r
+ @param Address Address which should be contained\r
+ by returned FVB handle\r
+ @param Lba Pointer to LBA for output\r
+ @param Offset Pointer to offset for output\r
+\r
+ @retval EFI_SUCCESS LBA and offset successfully returned\r
+ @retval EFI_NOT_FOUND Fail to find FVB handle by address\r
+ @retval EFI_ABORTED Fail to find valid LBA and offset\r
+\r
+**/\r
EFI_STATUS\r
GetLbaAndOffsetByAddress (\r
IN EFI_PHYSICAL_ADDRESS Address,\r
return EFI_ABORTED;\r
}\r
\r
+/**\r
+ Writes a buffer to variable storage space, in the working block.\r
+\r
+ This function writes a buffer to variable storage space into firmware\r
+ volume block device. The destination is specified by parameter\r
+ VariableBase. Fault Tolerant Write protocol is used for writing.\r
+\r
+ @param VariableBase Base address of variable to write\r
+ @param Buffer Point to the data buffer\r
+ @param BufferSize The number of bytes of the data Buffer\r
+\r
+ @retval EFI_SUCCESS The function completed successfully\r
+ @retval EFI_NOT_FOUND Fail to locate Fault Tolerant Write protocol\r
+ @retval EFI_ABORTED The function could not complete successfully\r
+\r
+**/\r
EFI_STATUS\r
FtwVariableSpace (\r
IN EFI_PHYSICAL_ADDRESS VariableBase,\r
IN UINT8 *Buffer,\r
IN UINTN BufferSize\r
)\r
-/*++\r
-\r
-Routine Description:\r
- Write a buffer to Variable space, in the working block.\r
-\r
-Arguments:\r
- FvbHandle - Indicates a handle to FVB to access variable store\r
- Buffer - Point to the input buffer\r
- BufferSize - The number of bytes of the input Buffer\r
-\r
-Returns:\r
- EFI_SUCCESS - The function completed successfully\r
- EFI_ABORTED - The function could not complete successfully\r
- EFI_NOT_FOUND - Locate FVB protocol by handle fails\r
-\r
---*/\r
{\r
- EFI_STATUS Status;\r
- EFI_HANDLE FvbHandle;\r
- EFI_FTW_LITE_PROTOCOL *FtwLiteProtocol;\r
- EFI_LBA VarLba;\r
- UINTN VarOffset;\r
- UINT8 *FtwBuffer;\r
- UINTN FtwBufferSize;\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE FvbHandle;\r
+ EFI_LBA VarLba;\r
+ UINTN VarOffset;\r
+ UINT8 *FtwBuffer;\r
+ UINTN FtwBufferSize;\r
+ EFI_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;\r
\r
//\r
// Locate fault tolerant write protocol\r
//\r
Status = gBS->LocateProtocol (\r
- &gEfiFaultTolerantWriteLiteProtocolGuid,\r
+ &gEfiFaultTolerantWriteProtocolGuid,\r
NULL,\r
- (VOID **) &FtwLiteProtocol\r
+ (VOID **) &FtwProtocol\r
);\r
if (EFI_ERROR (Status)) {\r
return EFI_NOT_FOUND;\r
//\r
// FTW write record\r
//\r
- Status = FtwLiteProtocol->Write (\r
- FtwLiteProtocol,\r
- FvbHandle,\r
+ Status = FtwProtocol->Write (\r
+ FtwProtocol,\r
VarLba, // LBA\r
VarOffset, // Offset\r
- &FtwBufferSize, // NumBytes,\r
- FtwBuffer\r
+ FtwBufferSize, // NumBytes\r
+ NULL, // PrivateData NULL\r
+ FvbHandle, // Fvb Handle\r
+ FtwBuffer // write buffer\r
);\r
\r
FreePool (FtwBuffer);\r