|
EFI_STATUS EFIAPI | IoMmuMap (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) |
|
STATIC EFI_STATUS EFIAPI | IoMmuUnmapWorker (IN EDKII_IOMMU_PROTOCOL *This, IN VOID *Mapping, IN BOOLEAN MemoryMapLocked) |
|
EFI_STATUS EFIAPI | IoMmuUnmap (IN EDKII_IOMMU_PROTOCOL *This, IN VOID *Mapping) |
|
EFI_STATUS EFIAPI | IoMmuAllocateBuffer (IN EDKII_IOMMU_PROTOCOL *This, IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, IN OUT VOID **HostAddress, IN UINT64 Attributes) |
|
EFI_STATUS EFIAPI | IoMmuFreeBuffer (IN EDKII_IOMMU_PROTOCOL *This, IN UINTN Pages, IN VOID *HostAddress) |
|
EFI_STATUS EFIAPI | IoMmuSetAttribute (IN EDKII_IOMMU_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN VOID *Mapping, IN UINT64 IoMmuAccess) |
|
STATIC VOID EFIAPI | IoMmuExitBoot (IN EFI_EVENT Event, IN VOID *EventToSignal) |
|
STATIC VOID EFIAPI | IoMmuUnmapAllMappings (IN EFI_EVENT Event, IN VOID *Context) |
|
EFI_STATUS EFIAPI | InstallIoMmuProtocol (VOID) |
|
The protocol provides support to allocate, free, map and umap a DMA buffer for bus master (e.g PciHostBridge). When SEV or TDX is enabled, the DMA operations must be performed on unencrypted buffer hence we use a bounce buffer to map the guest buffer into an unencrypted DMA buffer.
Copyright (c) 2017 - 2024, AMD Inc. All rights reserved.
Copyright (c) 2017, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file CcIoMmu.c.
Notification function that is queued when gBS->ExitBootServices() signals the EFI_EVENT_GROUP_EXIT_BOOT_SERVICES event group. This function signals another event, received as Context, and returns.
Signaling an event in this context is safe. The UEFI spec allows gBS->SignalEvent() to return EFI_SUCCESS only; EFI_OUT_OF_RESOURCES is not listed, hence memory is not allocated. The edk2 implementation also does not release memory (and we only have to care about the edk2 implementation because EDKII_IOMMU_PROTOCOL is edk2-specific anyway).
- Parameters
-
[in] | Event | Event whose notification function is being invoked. Event is permitted to request the queueing of this function at TPL_CALLBACK or TPL_NOTIFY task priority level. |
[in] | EventToSignal | Identifies the EFI_EVENT to signal. EventToSignal is permitted to request the queueing of its notification function only at TPL_CALLBACK level. |
Definition at line 840 of file CcIoMmu.c.
Set IOMMU attribute for a system memory.
If the IOMMU protocol exists, the system memory cannot be used for DMA by default.
When a device requests a DMA access for a system memory, the device driver need use SetAttribute() to update the IOMMU attribute to request DMA access (read and/or write).
The DeviceHandle is used to identify which device submits the request. The IOMMU implementation need translate the device path to an IOMMU device ID, and set IOMMU hardware register accordingly. 1) DeviceHandle can be a standard PCI device. The memory for BusMasterRead need set EDKII_IOMMU_ACCESS_READ. The memory for BusMasterWrite need set EDKII_IOMMU_ACCESS_WRITE. The memory for BusMasterCommonBuffer need set EDKII_IOMMU_ACCESS_READ|EDKII_IOMMU_ACCESS_WRITE. After the memory is used, the memory need set 0 to keep it being protected. 2) DeviceHandle can be an ACPI device (ISA, I2C, SPI, etc). The memory for DMA access need set EDKII_IOMMU_ACCESS_READ and/or EDKII_IOMMU_ACCESS_WRITE.
- Parameters
-
[in] | This | The protocol instance pointer. |
[in] | DeviceHandle | The device who initiates the DMA access request. |
[in] | Mapping | The mapping value returned from Map(). |
[in] | IoMmuAccess | The IOMMU access. |
- Return values
-
EFI_SUCCESS | The IoMmuAccess is set for the memory range specified by DeviceAddress and Length. |
EFI_INVALID_PARAMETER | DeviceHandle is an invalid handle. |
EFI_INVALID_PARAMETER | Mapping is not a value that was returned by Map(). |
EFI_INVALID_PARAMETER | IoMmuAccess specified an illegal combination of access. |
EFI_UNSUPPORTED | DeviceHandle is unknown by the IOMMU. |
EFI_UNSUPPORTED | The bit mask of IoMmuAccess is not supported by the IOMMU. |
EFI_UNSUPPORTED | The IOMMU does not support the memory range specified by Mapping. |
EFI_OUT_OF_RESOURCES | There are not enough resources available to modify the IOMMU access. |
EFI_DEVICE_ERROR | The IOMMU device reported an error while attempting the operation. |
Definition at line 747 of file CcIoMmu.c.