/* Provides the controller-specific addresses required to access system memory from a DMA bus master. On SEV guest, the DMA operations must be performed on shared buffer hence we allocate a bounce buffer to map the HostAddress to a DeviceAddress. The Encryption attribute is removed from the DeviceAddress buffer. */
STATIC EFI_STATUS EFIAPI NonCoherentIoMmuMap(IN EDKII_IOMMU_PROTOCOL *This, IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
/* Provides the controller-specific addresses required to access system memory from a DMA bus master. On SEV guest, the DMA operations must be performed on shared buffer hence we allocate a bounce buffer to map the HostAddress to a DeviceAddress. The Encryption attribute is removed from the DeviceAddress buffer. */
STATIC EFI_STATUS EFIAPI NonCoherentIoMmuMap(IN EDKII_IOMMU_PROTOCOL *This, IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
{
  DMA_MAP_OPERATION  DmaOperation;
  switch (Operation) {
    case EdkiiIoMmuOperationBusMasterRead:
    case EdkiiIoMmuOperationBusMasterRead64:
      DmaOperation = MapOperationBusMasterRead;
      break;
    case EdkiiIoMmuOperationBusMasterWrite:
    case EdkiiIoMmuOperationBusMasterWrite64:
      DmaOperation = MapOperationBusMasterWrite;
      break;
    case EdkiiIoMmuOperationBusMasterCommonBuffer:
    case EdkiiIoMmuOperationBusMasterCommonBuffer64:
      DmaOperation = MapOperationBusMasterCommonBuffer;
      break;
    default:
      ASSERT (FALSE);
      return EFI_INVALID_PARAMETER;
  }
  return DmaMap (
           DmaOperation,
           HostAddress,
           NumberOfBytes,
           DeviceAddress,
           Mapping
           );
}