/* Initialize the communicate buffer using DataSize and Function number. */
VOID InitCommunicateBuffer(OUT VOID **CommunicateBuffer, OUT VOID **DataPtr, IN UINTN DataSize, IN UINTN Function)
/* Initialize the communicate buffer using DataSize and Function number. */
VOID InitCommunicateBuffer(OUT VOID **CommunicateBuffer, OUT VOID **DataPtr, IN UINTN DataSize, IN UINTN Function)
{
  EFI_MM_COMMUNICATE_HEADER            *SmmCommunicateHeader;
  SMM_FTW_COMMUNICATE_FUNCTION_HEADER  *SmmFtwFunctionHeader;
  SmmCommunicateHeader = AllocateZeroPool (DataSize + SMM_COMMUNICATE_HEADER_SIZE + SMM_FTW_COMMUNICATE_HEADER_SIZE);
  ASSERT (SmmCommunicateHeader != NULL);
  CopyGuid (&SmmCommunicateHeader->HeaderGuid, &gEfiSmmFaultTolerantWriteProtocolGuid);
  SmmCommunicateHeader->MessageLength = DataSize + SMM_FTW_COMMUNICATE_HEADER_SIZE;
  SmmFtwFunctionHeader           = (SMM_FTW_COMMUNICATE_FUNCTION_HEADER *)SmmCommunicateHeader->Data;
  SmmFtwFunctionHeader->Function = Function;
  *CommunicateBuffer = SmmCommunicateHeader;
  if (DataPtr != NULL) {
    *DataPtr = SmmFtwFunctionHeader->Data;
  }
}