/* The function performs a Trusted Send of a Buffer containing a TCG_COM_PACKET. */
TCG_RESULT OpalTrustedSend(EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp, UINT32 MediaId, UINT8 SecurityProtocol, UINT16 SpSpecific, UINTN TransferLength, VOID *Buffer, UINTN BufferSize)
/* The function performs a Trusted Send of a Buffer containing a TCG_COM_PACKET. */
TCG_RESULT OpalTrustedSend(EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *Sscp, UINT32 MediaId, UINT8 SecurityProtocol, UINT16 SpSpecific, UINTN TransferLength, VOID *Buffer, UINTN BufferSize)
{
  UINTN       TransferLength512;
  EFI_STATUS  Status;
  TransferLength512 = (TransferLength + 511) & ~(UINTN)511;
  if (TransferLength512 > BufferSize) {
    return TcgResultFailureBufferTooSmall;
  }
  ZeroMem ((UINT8 *)Buffer + TransferLength, TransferLength512 - TransferLength);
  Status = Sscp->SendData (
                   Sscp,
                   MediaId,
                   TRUSTED_COMMAND_TIMEOUT_NS,
                   SecurityProtocol,
                   SwapBytes16 (SpSpecific),
                   TransferLength512,
                   Buffer
                   );
  return Status == EFI_SUCCESS ? TcgResultSuccess : TcgResultFailure;
}