\r
#include <PiDxe.h>\r
\r
-#include <Protocol/PciRootBridgeIo.h>\r
#include <Guid/SystemNvDataGuid.h>\r
#include <Protocol/FaultTolerantWriteLite.h>\r
#include <Protocol/FirmwareVolumeBlock.h>\r
#include <Library/UefiBootServicesTableLib.h>\r
#include <Library/DevicePathLib.h>\r
\r
-#include <WorkingBlockHeader.h>\r
-\r
-#define EFI_D_FTW_LITE EFI_D_ERROR\r
-#define EFI_D_FTW_INFO EFI_D_INFO\r
-\r
//\r
// Flash erase polarity is 1\r
//\r
//\r
} EFI_FTW_LITE_RECORD;\r
\r
-#define FTW_LITE_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('F', 'T', 'W', 'L')\r
+#define FTW_LITE_DEVICE_SIGNATURE SIGNATURE_32 ('F', 'T', 'W', 'L')\r
\r
-//\r
-// MACRO for Block size.\r
-// Flash Erasing will do in block granularity.\r
-//\r
-#ifdef FV_BLOCK_SIZE\r
-#define FTW_BLOCK_SIZE FV_BLOCK_SIZE\r
-#else\r
-#define FV_BLOCK_SIZE 0x10000\r
-#define FTW_BLOCK_SIZE FV_BLOCK_SIZE\r
-#endif\r
-//\r
-// MACRO for FTW WORK SPACE Base & Size\r
-//\r
-#ifdef EFI_FTW_WORKING_OFFSET\r
-#define FTW_WORK_SPACE_BASE EFI_FTW_WORKING_OFFSET\r
-#else\r
-#define FTW_WORK_SPACE_BASE 0x00E000\r
-#endif\r
-\r
-#ifdef EFI_FTW_WORKING_LENGTH\r
-#define FTW_WORK_SPACE_SIZE EFI_FTW_WORKING_LENGTH\r
-#else\r
-#define FTW_WORK_SPACE_SIZE 0x002000\r
-#endif\r
//\r
// MACRO for FTW header and record\r
//\r
-#define FTW_WORKING_QUEUE_SIZE (FTW_WORK_SPACE_SIZE - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER))\r
#define FTW_LITE_RECORD_SIZE (sizeof (EFI_FTW_LITE_RECORD))\r
-#define WRITE_TOTAL_SIZE FTW_LITE_RECORD_SIZE\r
\r
//\r
// EFI Fault tolerant protocol private data structure\r
UINTN Signature;\r
EFI_HANDLE Handle;\r
EFI_FTW_LITE_PROTOCOL FtwLiteInstance;\r
- EFI_PHYSICAL_ADDRESS WorkSpaceAddress;\r
- UINTN WorkSpaceLength;\r
- EFI_PHYSICAL_ADDRESS SpareAreaAddress;\r
- UINTN SpareAreaLength;\r
- UINTN NumberOfSpareBlock; // Number of the blocks in spare block\r
- UINTN SizeOfSpareBlock; // Block size in bytes of the blocks in spare block\r
- EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader;\r
- EFI_FTW_LITE_RECORD *FtwLastRecord;\r
+ EFI_PHYSICAL_ADDRESS WorkSpaceAddress; // Base address of working space range in flash.\r
+ UINTN WorkSpaceLength; // Size of working space range in flash.\r
+ EFI_PHYSICAL_ADDRESS SpareAreaAddress; // Base address of spare range in flash.\r
+ UINTN SpareAreaLength; // Size of spare range in flash.\r
+ UINTN NumberOfSpareBlock; // Number of the blocks in spare block.\r
+ UINTN BlockSize; // Block size in bytes of the blocks in flash\r
+ EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER *FtwWorkSpaceHeader;// Pointer to Working Space Header in memory buffer\r
+ EFI_FTW_LITE_RECORD *FtwLastRecord; // Pointer to last record in memory buffer\r
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwFvBlock; // FVB of working block\r
EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FtwBackupFvb; // FVB of spare block\r
- EFI_LBA FtwSpareLba;\r
- EFI_LBA FtwWorkBlockLba; // Start LBA of working block\r
+ EFI_LBA FtwSpareLba; // Start LBA of spare block\r
+ EFI_LBA FtwWorkBlockLba; // Start LBA of working block that contains working space in its last block.\r
EFI_LBA FtwWorkSpaceLba; // Start LBA of working space\r
- UINTN FtwWorkSpaceBase; // Offset from LBA start addr\r
- UINTN FtwWorkSpaceSize;\r
- UINT8 *FtwWorkSpace;\r
+ UINTN FtwWorkSpaceBase; // Offset into the FtwWorkSpaceLba block.\r
+ UINTN FtwWorkSpaceSize; // Size of working space range that stores write record.\r
+ UINT8 *FtwWorkSpace; // Point to Work Space in memory buffer \r
//\r
// Following a buffer of FtwWorkSpace[FTW_WORK_SPACE_SIZE],\r
// Allocated with EFI_FTW_LITE_DEVICE.\r
This function is the entry point of the Fault Tolerant Write driver.\r
\r
\r
- @param ImageHandle EFI_HANDLE: A handle for the image that is initializing\r
+ @param ImageHandle A handle for the image that is initializing\r
this driver\r
- @param SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table\r
+ @param SystemTable A pointer to the EFI system table\r
\r
@retval EFI_SUCCESS FTW has finished the initialization\r
@retval EFI_ABORTED FTW initialization error\r
);\r
\r
/**\r
- To Erase one block. The size is FTW_BLOCK_SIZE\r
+ To erase the block with the spare block size.\r
\r
\r
@param FtwLiteDevice Calling context\r
EFI_LBA Lba\r
);\r
\r
-/**\r
-\r
- Check whether the block is a boot block.\r
-\r
-\r
- @param FtwLiteDevice Calling context\r
- @param FvBlock Fvb protocol instance\r
- @param Lba Lba value\r
-\r
- @retval FALSE This is a boot block.\r
- @retval TRUE This is not a boot block.\r
-\r
-**/\r
-BOOLEAN\r
-IsBootBlock (\r
- EFI_FTW_LITE_DEVICE *FtwLiteDevice,\r
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *FvBlock,\r
- EFI_LBA Lba\r
- );\r
-\r
/**\r
Copy the content of spare block to a target block. Size is FTW_BLOCK_SIZE.\r
Spare block is accessed by FTW backup FVB protocol interface. LBA is\r
EFI_FTW_LITE_DEVICE *FtwLiteDevice\r
);\r
\r
-/**\r
- Copy the content of spare block to a boot block. Size is FTW_BLOCK_SIZE.\r
- Spare block is accessed by FTW backup FVB protocol interface. LBA is\r
- FtwLiteDevice->FtwSpareLba.\r
- Boot block is accessed by BootFvb protocol interface. LBA is 0.\r
-\r
-\r
- @param FtwLiteDevice The private data of FTW_LITE driver\r
-\r
- @retval EFI_SUCCESS Spare block content is copied to boot block\r
- @retval EFI_INVALID_PARAMETER Input parameter error\r
- @retval EFI_OUT_OF_RESOURCES Allocate memory error\r
- @retval EFI_ABORTED The function could not complete successfully\r
- Notes:\r
-\r
-**/\r
-EFI_STATUS\r
-FlushSpareBlockToBootBlock (\r
- EFI_FTW_LITE_DEVICE *FtwLiteDevice\r
- );\r
-\r
/**\r
Update a bit of state on a block device. The location of the bit is\r
calculated by the (Lba, Offset, bit). Here bit is determined by the\r