--- /dev/null
+/** @file\r
+\r
+ The internal header file includes the common header files, defines\r
+ internal structure and functions used by FTW module.\r
+\r
+Copyright (c) 2011, Intel Corporation. All rights reserved. <BR>\r
+This program and the accompanying materials \r
+are licensed and made available under the terms and conditions of the BSD License \r
+which accompanies this distribution. The full text of the license may be found at \r
+http://opensource.org/licenses/bsd-license.php \r
+ \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+**/\r
+\r
+#ifndef __SMM_FTW_DXE_H__\r
+#define __SMM_FTW_DXE_H__\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/SmmCommunication.h>\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+\r
+#include <Guid/EventGroup.h>\r
+\r
+#include "FaultTolerantWriteSmmCommon.h"\r
+\r
+/**\r
+ Get the size of the largest block that can be updated in a fault-tolerant manner.\r
+\r
+ @param[in] This Indicates a pointer to the calling context.\r
+ @param[out] BlockSize A pointer to a caller-allocated UINTN that is\r
+ updated to indicate the size of the largest block\r
+ that can be updated.\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
+EFIAPI\r
+FtwGetMaxBlockSize (\r
+ IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
+ OUT UINTN *BlockSize\r
+ );\r
+\r
+\r
+/**\r
+ Allocates space for the protocol to maintain information about writes.\r
+ Since writes must be completed in a fault-tolerant manner and multiple\r
+ writes require more resources to be successful, this function\r
+ enables the protocol to ensure that enough space exists to track\r
+ information about upcoming writes.\r
+\r
+ @param[in] This A pointer to the calling context.\r
+ @param[in] CallerId The GUID identifying the write.\r
+ @param[in] PrivateDataSize The size of the caller's private data that must be\r
+ recorded for each write.\r
+ @param[in] NumberOfWrites The number of fault tolerant block writes that will\r
+ need to occur.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully\r
+ @retval EFI_ABORTED The function could not complete successfully.\r
+ @retval EFI_ACCESS_DENIED Not all allocated writes have been completed. All\r
+ writes must be completed or aborted before another\r
+ fault tolerant write can occur.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FtwAllocate (\r
+ IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
+ IN EFI_GUID *CallerId,\r
+ IN UINTN PrivateDataSize,\r
+ IN UINTN NumberOfWrites\r
+ );\r
+\r
+\r
+/**\r
+ Starts a target block update. This records information about the write\r
+ in fault tolerant storage, and will complete the write in a recoverable\r
+ manner, ensuring at all times that either the original contents or\r
+ the modified contents are available.\r
+\r
+ @param[in] This The calling context.\r
+ @param[in] Lba The logical block address of the target block.\r
+ @param[in] Offset The offset within the target block to place the\r
+ data.\r
+ @param[in] Length The number of bytes to write to the target block.\r
+ @param[in] PrivateData A pointer to private data that the caller requires\r
+ to complete any pending writes in the event of a\r
+ fault.\r
+ @param[in] FvBlockHandle The handle of FVB protocol that provides services\r
+ for reading, writing, and erasing the target block.\r
+ @param[in] 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
+ @retval EFI_BAD_BUFFER_SIZE The write would span a block boundary, which is not\r
+ a valid action.\r
+ @retval EFI_ACCESS_DENIED No writes have been allocated.\r
+ @retval EFI_NOT_READY The last write has not been completed. Restart()\r
+ must be called to complete it.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FtwWrite (\r
+ IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
+ IN EFI_LBA Lba,\r
+ IN UINTN Offset,\r
+ IN UINTN Length,\r
+ IN VOID *PrivateData,\r
+ IN EFI_HANDLE FvBlockHandle,\r
+ IN VOID *Buffer\r
+ );\r
+\r
+\r
+/**\r
+ Restarts a previously interrupted write. The caller must provide the\r
+ block protocol needed to complete the interrupted write.\r
+\r
+ @param[in] This The calling context.\r
+ @param[in] FvBlockHandle The handle of FVB protocol that provides services.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ABORTED The function could not complete successfully.\r
+ @retval EFI_ACCESS_DENIED No pending writes exist.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FtwRestart (\r
+ IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
+ IN EFI_HANDLE FvBlockHandle\r
+ );\r
+\r
+\r
+/**\r
+ Aborts all previously allocated writes.\r
+\r
+ @param This The calling context.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ABORTED The function could not complete successfully.\r
+ @retval EFI_NOT_FOUND No allocated writes exist.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FtwAbort (\r
+ IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This\r
+ );\r
+\r
+\r
+/**\r
+ Starts a target block update. This function records information about the write\r
+ in fault-tolerant storage and completes the write in a recoverable\r
+ manner, ensuring at all times that either the original contents or\r
+ the modified contents are available.\r
+\r
+ @param[in] This Indicates a pointer to the calling context.\r
+ @param[out] CallerId The GUID identifying the last write.\r
+ @param[out] Lba The logical block address of the last write.\r
+ @param[out] Offset The offset within the block of the last write.\r
+ @param[out] Length The length of the last write.\r
+ @param[in, out] PrivateDataSize On input, the size of the PrivateData buffer. On\r
+ output, the size of the private data stored for\r
+ this write.\r
+ @param[out] PrivateData A pointer to a buffer. The function will copy\r
+ PrivateDataSize bytes from the private data stored\r
+ for this write.\r
+ @param[out] Complete A Boolean value with TRUE indicating that the write\r
+ was completed.\r
+\r
+ @retval EFI_SUCCESS The function completed successfully.\r
+ @retval EFI_ABORTED The function could not complete successfully.\r
+ @retval EFI_NOT_FOUND No allocated writes exist.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FtwGetLastWrite (\r
+ IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This,\r
+ OUT EFI_GUID *CallerId,\r
+ OUT EFI_LBA *Lba,\r
+ OUT UINTN *Offset,\r
+ OUT UINTN *Length,\r
+ IN OUT UINTN *PrivateDataSize,\r
+ OUT VOID *PrivateData,\r
+ OUT BOOLEAN *Complete\r
+ );\r
+\r
+#endif\r