+/**\r
+ Read work space data from work block or spare block.\r
+\r
+ @param FvBlock FVB Protocol interface to access the block.\r
+ @param BlockSize The size of the block.\r
+ @param Lba Lba of the block.\r
+ @param Offset The offset within the block.\r
+ @param Length The number of bytes to read from the block.\r
+ @param Buffer The data is read.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ABORTED The function could not complete successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+ReadWorkSpaceData (\r
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
+ IN UINTN BlockSize,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN Offset,\r
+ IN UINTN Length,\r
+ OUT UINT8 *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINT8 *Ptr;\r
+ UINTN MyLength;\r
+\r
+ //\r
+ // Calculate the real Offset and Lba to write.\r
+ //\r
+ while (Offset >= BlockSize) {\r
+ Offset -= BlockSize;\r
+ Lba++;\r
+ }\r
+\r
+ Ptr = Buffer;\r
+ while (Length > 0) {\r
+ if ((Offset + Length) > BlockSize) {\r
+ MyLength = BlockSize - Offset;\r
+ } else {\r
+ MyLength = Length;\r
+ }\r
+\r
+ Status = FvBlock->Read (\r
+ FvBlock,\r
+ Lba,\r
+ Offset,\r
+ &MyLength,\r
+ Ptr\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_ABORTED;\r
+ }\r
+ Offset = 0;\r
+ Length -= MyLength;\r
+ Ptr += MyLength;\r
+ Lba++;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+/**\r
+ Write work space data to work block.\r
+\r
+ @param FvBlock FVB Protocol interface to access the block.\r
+ @param BlockSize The size of the block.\r
+ @param Lba Lba of the block.\r
+ @param Offset The offset within the block to place the data.\r
+ @param Length The number of bytes to write to the block.\r
+ @param Buffer The data to write.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ABORTED The function could not complete successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+WriteWorkSpaceData (\r
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
+ IN UINTN BlockSize,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN Offset,\r
+ IN UINTN Length,\r
+ IN UINT8 *Buffer\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINT8 *Ptr;\r
+ UINTN MyLength;\r
+\r
+ //\r
+ // Calculate the real Offset and Lba to write.\r
+ //\r
+ while (Offset >= BlockSize) {\r
+ Offset -= BlockSize;\r
+ Lba++;\r
+ }\r
+\r
+ Ptr = Buffer;\r
+ while (Length > 0) {\r
+ if ((Offset + Length) > BlockSize) {\r
+ MyLength = BlockSize - Offset;\r
+ } else {\r
+ MyLength = Length;\r
+ }\r
+\r
+ Status = FvBlock->Write (\r
+ FvBlock,\r
+ Lba,\r
+ Offset,\r
+ &MyLength,\r
+ Ptr\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_ABORTED;\r
+ }\r
+ Offset = 0;\r
+ Length -= MyLength;\r
+ Ptr += MyLength;\r
+ Lba++;\r
+ }\r
+ return EFI_SUCCESS;\r
+}\r
+\r