TianoCore EDK2 master
Loading...
Searching...
No Matches
NonCoherentIoMmuDxe.c
Go to the documentation of this file.
1
8#include <PiDxe.h>
9#include <Library/BaseLib.h>
10#include <Library/DebugLib.h>
11#include <Library/DmaLib.h>
13#include <Protocol/IoMmu.h>
14
65EFIAPI
68 IN EFI_HANDLE DeviceHandle,
69 IN VOID *Mapping,
70 IN UINT64 IoMmuAccess
71 )
72{
73 return EFI_SUCCESS;
74}
75
106STATIC
108EFIAPI
111 IN EDKII_IOMMU_OPERATION Operation,
112 IN VOID *HostAddress,
113 IN OUT UINTN *NumberOfBytes,
114 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
115 OUT VOID **Mapping
116 )
117{
118 DMA_MAP_OPERATION DmaOperation;
119
120 switch (Operation) {
123 DmaOperation = MapOperationBusMasterRead;
124 break;
125
128 DmaOperation = MapOperationBusMasterWrite;
129 break;
130
134 break;
135
136 default:
137 ASSERT (FALSE);
138 return EFI_INVALID_PARAMETER;
139 }
140
141 return DmaMap (
142 DmaOperation,
143 HostAddress,
144 NumberOfBytes,
145 DeviceAddress,
146 Mapping
147 );
148}
149
162STATIC
164EFIAPI
167 IN VOID *Mapping
168 )
169{
170 return DmaUnmap (Mapping);
171}
172
195STATIC
197EFIAPI
201 IN EFI_MEMORY_TYPE MemoryType,
202 IN UINTN Pages,
203 IN OUT VOID **HostAddress,
204 IN UINT64 Attributes
205 )
206{
207 return DmaAllocateBuffer (MemoryType, Pages, HostAddress);
208}
209
223STATIC
225EFIAPI
228 IN UINTN Pages,
229 IN VOID *HostAddress
230 )
231{
232 return DmaFreeBuffer (Pages, HostAddress);
233}
234
235STATIC EDKII_IOMMU_PROTOCOL mNonCoherentIoMmuOps = {
236 EDKII_IOMMU_PROTOCOL_REVISION,
242};
243
245EFIAPI
246NonCoherentIoMmuDxeEntryPoint (
247 IN EFI_HANDLE ImageHandle,
248 IN EFI_SYSTEM_TABLE *SystemTable
249 )
250{
251 return gBS->InstallMultipleProtocolInterfaces (
252 &ImageHandle,
254 &mNonCoherentIoMmuOps,
255 NULL
256 );
257}
UINT64 UINTN
DMA_MAP_OPERATION
Definition: DmaLib.h:37
@ MapOperationBusMasterWrite
Definition: DmaLib.h:45
@ MapOperationBusMasterRead
Definition: DmaLib.h:41
@ MapOperationBusMasterCommonBuffer
Definition: DmaLib.h:50
EFI_STATUS EFIAPI DmaUnmap(IN VOID *Mapping)
EFI_STATUS EFIAPI DmaMap(IN DMA_MAP_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
EFI_STATUS EFIAPI DmaAllocateBuffer(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT VOID **HostAddress)
EFI_STATUS EFIAPI DmaFreeBuffer(IN UINTN Pages, IN VOID *HostAddress)
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
STATIC EFI_STATUS EFIAPI NonCoherentIoMmuFreeBuffer(IN EDKII_IOMMU_PROTOCOL *This, IN UINTN Pages, IN VOID *HostAddress)
STATIC EFI_STATUS EFIAPI NonCoherentIoMmuSetAttribute(IN EDKII_IOMMU_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN VOID *Mapping, IN UINT64 IoMmuAccess)
STATIC EFI_STATUS EFIAPI NonCoherentIoMmuUnmap(IN EDKII_IOMMU_PROTOCOL *This, IN VOID *Mapping)
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)
STATIC EFI_STATUS EFIAPI NonCoherentIoMmuAllocateBuffer(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_GUID gEdkiiIoMmuProtocolGuid
EDKII_IOMMU_OPERATION
Definition: IoMmu.h:44
@ EdkiiIoMmuOperationBusMasterWrite
Definition: IoMmu.h:54
@ EdkiiIoMmuOperationBusMasterWrite64
Definition: IoMmu.h:69
@ EdkiiIoMmuOperationBusMasterCommonBuffer
Definition: IoMmu.h:59
@ EdkiiIoMmuOperationBusMasterRead64
Definition: IoMmu.h:64
@ EdkiiIoMmuOperationBusMasterRead
Definition: IoMmu.h:49
@ EdkiiIoMmuOperationBusMasterCommonBuffer64
Definition: IoMmu.h:74
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_MEMORY_TYPE
EFI_ALLOCATE_TYPE
Definition: UefiSpec.h:29