46 Status = mIoMmu->Map (
54 if (EFI_ERROR (Status)) {
55 return EFI_OUT_OF_RESOURCES;
61 Attribute = EDKII_IOMMU_ACCESS_READ;
65 Attribute = EDKII_IOMMU_ACCESS_WRITE;
69 Attribute = EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE;
73 return EFI_INVALID_PARAMETER;
76 Status = mIoMmu->SetAttribute (
81 if (EFI_ERROR (Status)) {
109 if (mIoMmu !=
NULL) {
110 Status = mIoMmu->SetAttribute (mIoMmu, Mapping, 0);
111 Status = mIoMmu->Unmap (mIoMmu, Mapping);
140 OUT VOID **HostAddress,
152 if (mIoMmu !=
NULL) {
153 Status = mIoMmu->AllocateBuffer (
160 if (EFI_ERROR (Status)) {
161 return EFI_OUT_OF_RESOURCES;
165 Status = mIoMmu->Map (
173 if (EFI_ERROR (Status)) {
174 return EFI_OUT_OF_RESOURCES;
177 Status = mIoMmu->SetAttribute (
180 EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE
182 if (EFI_ERROR (Status)) {
191 if (EFI_ERROR (Status)) {
192 return EFI_OUT_OF_RESOURCES;
195 *HostAddress = (VOID *)(
UINTN)HostPhyAddress;
196 *DeviceAddress = HostPhyAddress;
218 IN VOID *HostAddress,
224 if (mIoMmu !=
NULL) {
225 Status = mIoMmu->SetAttribute (mIoMmu, Mapping, 0);
226 Status = mIoMmu->Unmap (mIoMmu, Mapping);
227 Status = mIoMmu->FreeBuffer (mIoMmu, Pages, HostAddress);
258 OUT VOID **HostAddress,
267 UINTN UnalignedPages;
274 AlignmentMask = Alignment - 1;
284 ASSERT (RealPages > Pages);
286 if (mIoMmu !=
NULL) {
287 Status = mIoMmu->AllocateBuffer (
294 if (EFI_ERROR (Status)) {
295 return EFI_OUT_OF_RESOURCES;
298 Memory = *HostAddress;
299 AlignedMemory = ((
UINTN)Memory + AlignmentMask) & ~AlignmentMask;
301 if (UnalignedPages > 0) {
305 Status = mIoMmu->FreeBuffer (
310 if (EFI_ERROR (Status)) {
316 UnalignedPages = RealPages - Pages - UnalignedPages;
317 if (UnalignedPages > 0) {
321 Status = mIoMmu->FreeBuffer (
326 if (EFI_ERROR (Status)) {
331 *HostAddress = (VOID *)AlignedMemory;
333 Status = mIoMmu->Map (
341 if (EFI_ERROR (Status)) {
342 return EFI_OUT_OF_RESOURCES;
345 Status = mIoMmu->SetAttribute (
348 EDKII_IOMMU_ACCESS_READ | EDKII_IOMMU_ACCESS_WRITE
350 if (EFI_ERROR (Status)) {
359 if (EFI_ERROR (Status)) {
360 return EFI_OUT_OF_RESOURCES;
363 *HostAddress = (VOID *)(((
UINTN)HostPhyAddress + AlignmentMask) & ~AlignmentMask);
364 *DeviceAddress = ((
UINTN)HostPhyAddress + AlignmentMask) & ~AlignmentMask;
EFI_STATUS IoMmuUnmap(IN VOID *Mapping)
EFI_STATUS IoMmuAllocateBuffer(IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
EFI_STATUS IoMmuMap(IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
EFI_STATUS IoMmuFreeBuffer(IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory)
VOID IoMmuInit(OUT EDKII_IOMMU_PPI **IoMmu)
EFI_STATUS IoMmuAllocateAlignedBuffer(IN UINTN Pages, IN UINTN Alignment, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
EFI_GUID gEdkiiIoMmuPpiGuid
@ EdkiiIoMmuOperationBusMasterWrite
@ EdkiiIoMmuOperationBusMasterWrite64
@ EdkiiIoMmuOperationBusMasterCommonBuffer
@ EdkiiIoMmuOperationBusMasterRead64
@ EdkiiIoMmuOperationBusMasterRead
@ EdkiiIoMmuOperationBusMasterCommonBuffer64
UINT64 EFI_PHYSICAL_ADDRESS
#define EFI_PAGES_TO_SIZE(Pages)
#define EFI_SIZE_TO_PAGES(Size)