TianoCore EDK2 master
Loading...
Searching...
No Matches
FaultTolerantWriteSmmDxe.c File Reference

Go to the source code of this file.

Functions

VOID InitCommunicateBuffer (OUT VOID **CommunicateBuffer, OUT VOID **DataPtr, IN UINTN DataSize, IN UINTN Function)
 
EFI_STATUS SendCommunicateBuffer (IN OUT EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader, IN UINTN DataSize)
 
EFI_STATUS ConvertFvbHandle (IN EFI_HANDLE FvbHandle, OUT EFI_PHYSICAL_ADDRESS *FvbBaseAddress, OUT EFI_FVB_ATTRIBUTES_2 *FvbAttributes)
 
EFI_STATUS EFIAPI FtwGetMaxBlockSize (IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, OUT UINTN *BlockSize)
 
EFI_STATUS EFIAPI FtwAllocate (IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_GUID *CallerId, IN UINTN PrivateDataSize, IN UINTN NumberOfWrites)
 
EFI_STATUS EFIAPI FtwWrite (IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN UINTN Length, IN VOID *PrivateData, IN EFI_HANDLE FvBlockHandle, IN VOID *Buffer)
 
EFI_STATUS EFIAPI FtwRestart (IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_HANDLE FvBlockHandle)
 
EFI_STATUS EFIAPI FtwAbort (IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This)
 
EFI_STATUS EFIAPI FtwGetLastWrite (IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, OUT EFI_GUID *CallerId, OUT EFI_LBA *Lba, OUT UINTN *Offset, OUT UINTN *Length, IN OUT UINTN *PrivateDataSize, OUT VOID *PrivateData, OUT BOOLEAN *Complete)
 
VOID EFIAPI SmmFtwReady (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI FaultTolerantWriteSmmInitialize (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_HANDLE mHandle = NULL
 
EFI_MM_COMMUNICATION2_PROTOCOLmMmCommunication2 = NULL
 
UINTN mPrivateDataSize = 0
 
EFI_FAULT_TOLERANT_WRITE_PROTOCOL mFaultTolerantWriteDriver
 

Detailed Description

Implement the Fault Tolerant Write (FTW) protocol based on SMM FTW module.

Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file FaultTolerantWriteSmmDxe.c.

Function Documentation

◆ ConvertFvbHandle()

EFI_STATUS ConvertFvbHandle ( IN EFI_HANDLE  FvbHandle,
OUT EFI_PHYSICAL_ADDRESS FvbBaseAddress,
OUT EFI_FVB_ATTRIBUTES_2 FvbAttributes 
)

Get the FvbBaseAddress and FvbAttributes from the FVB handle FvbHandle.

Parameters
[in]FvbHandleThe handle of FVB protocol that provides services.
[out]FvbBaseAddressThe base address of the FVB attached with FvbHandle.
[out]FvbAttributesThe attributes of the FVB attached with FvbHandle.
Return values
EFI_SUCCESSThe function completed successfully.
OthersThe function could not complete successfully.

Definition at line 109 of file FaultTolerantWriteSmmDxe.c.

◆ FaultTolerantWriteSmmInitialize()

EFI_STATUS EFIAPI FaultTolerantWriteSmmInitialize ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The driver entry point for Fault Tolerant Write driver.

The function does the necessary initialization work.

Parameters
[in]ImageHandleThe firmware allocated handle for the UEFI image.
[in]SystemTableA pointer to the EFI system table.
Return values
EFI_SUCCESSThis funtion always return EFI_SUCCESS.

Definition at line 533 of file FaultTolerantWriteSmmDxe.c.

◆ FtwAbort()

EFI_STATUS EFIAPI FtwAbort ( IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL This)

Aborts all previously allocated writes.

Parameters
[in]ThisThe calling context.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDThe function could not complete successfully.
EFI_NOT_FOUNDNo allocated writes exist.

Definition at line 378 of file FaultTolerantWriteSmmDxe.c.

◆ FtwAllocate()

EFI_STATUS EFIAPI FtwAllocate ( IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL This,
IN EFI_GUID CallerId,
IN UINTN  PrivateDataSize,
IN UINTN  NumberOfWrites 
)

Allocates space for the protocol to maintain information about writes. Since writes must be completed in a fault-tolerant manner and multiple writes require more resources to be successful, this function enables the protocol to ensure that enough space exists to track information about upcoming writes.

Parameters
[in]ThisA pointer to the calling context.
[in]CallerIdThe GUID identifying the write.
[in]PrivateDataSizeThe size of the caller's private data that must be recorded for each write.
[in]NumberOfWritesThe number of fault tolerant block writes that will need to occur.
Return values
EFI_SUCCESSThe function completed successfully
EFI_ABORTEDThe function could not complete successfully.
EFI_ACCESS_DENIEDNot all allocated writes have been completed. All writes must be completed or aborted before another fault tolerant write can occur.

Definition at line 199 of file FaultTolerantWriteSmmDxe.c.

◆ FtwGetLastWrite()

EFI_STATUS EFIAPI FtwGetLastWrite ( IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL This,
OUT EFI_GUID CallerId,
OUT EFI_LBA Lba,
OUT UINTN Offset,
OUT UINTN Length,
IN OUT UINTN PrivateDataSize,
OUT VOID *  PrivateData,
OUT BOOLEAN *  Complete 
)

Starts a target block update. This function records information about the write in fault-tolerant storage and completes the write in a recoverable manner, ensuring at all times that either the original contents or the modified contents are available.

Parameters
[in]ThisIndicates a pointer to the calling context.
[out]CallerIdThe GUID identifying the last write.
[out]LbaThe logical block address of the last write.
[out]OffsetThe offset within the block of the last write.
[out]LengthThe length of the last write.
[in,out]PrivateDataSizeOn input, the size of the PrivateData buffer. On output, the size of the private data stored for this write.
[out]PrivateDataA pointer to a buffer. The function will copy PrivateDataSize bytes from the private data stored for this write.
[out]CompleteA Boolean value with TRUE indicating that the write was completed.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDThe function could not complete successfully.
EFI_NOT_FOUNDNo allocated writes exist.

Definition at line 426 of file FaultTolerantWriteSmmDxe.c.

◆ FtwGetMaxBlockSize()

EFI_STATUS EFIAPI FtwGetMaxBlockSize ( IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL This,
OUT UINTN BlockSize 
)

Get the size of the largest block that can be updated in a fault-tolerant manner.

Parameters
[in]ThisIndicates a pointer to the calling context.
[out]BlockSizeA pointer to a caller-allocated UINTN that is updated to indicate the size of the largest block that can be updated.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDThe function could not complete successfully.

Definition at line 146 of file FaultTolerantWriteSmmDxe.c.

◆ FtwRestart()

EFI_STATUS EFIAPI FtwRestart ( IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL This,
IN EFI_HANDLE  FvBlockHandle 
)

Restarts a previously interrupted write. The caller must provide the block protocol needed to complete the interrupted write.

Parameters
[in]ThisThe calling context.
[in]FvBlockHandleThe handle of FVB protocol that provides services.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDThe function could not complete successfully.
EFI_ACCESS_DENIEDNo pending writes exist.

Definition at line 332 of file FaultTolerantWriteSmmDxe.c.

◆ FtwWrite()

EFI_STATUS EFIAPI FtwWrite ( IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL This,
IN EFI_LBA  Lba,
IN UINTN  Offset,
IN UINTN  Length,
IN VOID *  PrivateData,
IN EFI_HANDLE  FvBlockHandle,
IN VOID *  Buffer 
)

Starts a target block update. This records information about the write in fault tolerant storage, and will complete the write in a recoverable manner, ensuring at all times that either the original contents or the modified contents are available.

Parameters
[in]ThisThe calling context.
[in]LbaThe logical block address of the target block.
[in]OffsetThe offset within the target block to place the data.
[in]LengthThe number of bytes to write to the target block.
[in]PrivateDataA pointer to private data that the caller requires to complete any pending writes in the event of a fault.
[in]FvBlockHandleThe handle of FVB protocol that provides services for reading, writing, and erasing the target block.
[in]BufferThe data to write.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_ABORTEDThe function could not complete successfully.
EFI_BAD_BUFFER_SIZEThe write would span a block boundary, which is not a valid action.
EFI_ACCESS_DENIEDNo writes have been allocated.
EFI_NOT_READYThe last write has not been completed. Restart() must be called to complete it.

Definition at line 261 of file FaultTolerantWriteSmmDxe.c.

◆ InitCommunicateBuffer()

VOID InitCommunicateBuffer ( OUT VOID **  CommunicateBuffer,
OUT VOID **  DataPtr,
IN UINTN  DataSize,
IN UINTN  Function 
)

Initialize the communicate buffer using DataSize and Function number.

Parameters
[out]CommunicateBufferThe communicate buffer. Caller should free it after use.
[out]DataPtrPoints to the data in the communicate buffer. Caller should not free it.
[in]DataSizeThe payload size.
[in]FunctionThe function number used to initialize the communicate header.

Definition at line 36 of file FaultTolerantWriteSmmDxe.c.

◆ SendCommunicateBuffer()

EFI_STATUS SendCommunicateBuffer ( IN OUT EFI_MM_COMMUNICATE_HEADER SmmCommunicateHeader,
IN UINTN  DataSize 
)

Send the data in communicate buffer to SMI handler and get response.

Parameters
[in,out]SmmCommunicateHeaderThe communicate buffer.
[in]DataSizeThe payload size.

Definition at line 75 of file FaultTolerantWriteSmmDxe.c.

◆ SmmFtwReady()

VOID EFIAPI SmmFtwReady ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

SMM Fault Tolerant Write Protocol notification event handler.

Install Fault Tolerant Write Protocol.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 485 of file FaultTolerantWriteSmmDxe.c.

Variable Documentation

◆ mFaultTolerantWriteDriver

EFI_FAULT_TOLERANT_WRITE_PROTOCOL mFaultTolerantWriteDriver
Initial value:
= {
}
EFI_STATUS EFIAPI FtwGetMaxBlockSize(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, OUT UINTN *BlockSize)
EFI_STATUS EFIAPI FtwRestart(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_HANDLE FvBlockHandle)
EFI_STATUS EFIAPI FtwAllocate(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_GUID *CallerId, IN UINTN PrivateDataSize, IN UINTN NumberOfWrites)
EFI_STATUS EFIAPI FtwWrite(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, IN EFI_LBA Lba, IN UINTN Offset, IN UINTN Length, IN VOID *PrivateData, IN EFI_HANDLE FvBlockHandle, IN VOID *Buffer)
EFI_STATUS EFIAPI FtwGetLastWrite(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This, OUT EFI_GUID *CallerId, OUT EFI_LBA *Lba, OUT UINTN *Offset, OUT UINTN *Length, IN OUT UINTN *PrivateDataSize, OUT VOID *PrivateData, OUT BOOLEAN *Complete)
EFI_STATUS EFIAPI FtwAbort(IN EFI_FAULT_TOLERANT_WRITE_PROTOCOL *This)

Definition at line 17 of file FaultTolerantWriteSmmDxe.c.

◆ mHandle

EFI_HANDLE mHandle = NULL

Handle for the Capsule Update Policy Protocol

Definition at line 13 of file FaultTolerantWriteSmmDxe.c.

◆ mMmCommunication2

EFI_MM_COMMUNICATION2_PROTOCOL* mMmCommunication2 = NULL

Definition at line 14 of file FaultTolerantWriteSmmDxe.c.

◆ mPrivateDataSize

UINTN mPrivateDataSize = 0

Definition at line 15 of file FaultTolerantWriteSmmDxe.c.