/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the functio shall return EFI_DEVICE_ERROR. */
EFI_STATUS EFIAPI AhciStorageSecuritySendData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
/* If the security protocol command completes without an error, the function shall return EFI_SUCCESS. If the security protocol command completes with an error, the functio shall return EFI_DEVICE_ERROR. */
EFI_STATUS EFIAPI AhciStorageSecuritySendData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
{
  PEI_AHCI_CONTROLLER_PRIVATE_DATA  *Private;
  PEI_AHCI_ATA_DEVICE_DATA          *DeviceData;
  if ((PayloadBuffer == NULL) && (PayloadBufferSize != 0)) {
    return EFI_INVALID_PARAMETER;
  }
  Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY (This);
  if ((DeviceIndex == 0) || (DeviceIndex > Private->TrustComputingDevices)) {
    return EFI_INVALID_PARAMETER;
  }
  DeviceData = SearchTrustComputingDeviceByIndex (Private, DeviceIndex);
  if (DeviceData == NULL) {
    return EFI_NOT_FOUND;
  }
  ASSERT ((DeviceData->IdentifyData->trusted_computing_support & BIT0) != 0);
  if ((DeviceData->IdentifyData->trusted_computing_support & BIT0) == 0) {
    return EFI_UNSUPPORTED;
  }
  return TrustTransferAtaDevice (
           DeviceData,
           PayloadBuffer,
           SecurityProtocolId,
           SecurityProtocolSpecificData,
           PayloadBufferSize,
           TRUE,
           Timeout,
           NULL
           );
}