MdeModulePkg/PciHostBridge: Add IOMMU support.
If IOMMU protocol is installed, PciHostBridge just calls IOMMU AllocateBuffer/FreeBuffer/Map/Unmap. PciHostBridge does not set IOMMU access attribute, because it does not know which device request the DMA. This work is done by PciBus driver. Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Leo Duran <leo.duran@amd.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Previous patch Tested-by: Brijesh Singh <brijesh.singh@amd.com> Previous patch Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Leo Duran <leo.duran@amd.com>
This commit is contained in:
@@ -28,6 +28,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mPciResourceTypeStr[] = {
|
||||
L"I/O", L"Mem", L"PMem", L"Mem64", L"PMem64", L"Bus"
|
||||
};
|
||||
|
||||
EDKII_IOMMU_PROTOCOL *mIoMmuProtocol;
|
||||
EFI_EVENT mIoMmuEvent;
|
||||
VOID *mIoMmuRegistration;
|
||||
|
||||
/**
|
||||
Ensure the compatibility of an IO space descriptor with the IO aperture.
|
||||
|
||||
@@ -312,6 +316,28 @@ FreeMemorySpaceMap:
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
Event notification that is fired when IOMMU protocol is installed.
|
||||
|
||||
@param Event The Event that is being processed.
|
||||
@param Context Event Context.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
IoMmuProtocolCallback (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = gBS->LocateProtocol (&gEdkiiIoMmuProtocolGuid, NULL, (VOID **)&mIoMmuProtocol);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
gBS->CloseEvent (mIoMmuEvent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Entry point of this driver.
|
||||
@@ -489,6 +515,17 @@ InitializePciHostBridge (
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
PciHostBridgeFreeRootBridges (RootBridges, RootBridgeCount);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
mIoMmuEvent = EfiCreateProtocolNotifyEvent (
|
||||
&gEdkiiIoMmuProtocolGuid,
|
||||
TPL_CALLBACK,
|
||||
IoMmuProtocolCallback,
|
||||
NULL,
|
||||
&mIoMmuRegistration
|
||||
);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user