MdeModulePkg/EmmcBlockIoPei: Support IoMmu

Update the EmmcBlockIoPei driver to consume IOMMU_PPI to allocate DMA
buffer.

If no IOMMU_PPI exists, this driver still calls PEI service
to allocate DMA buffer, with assumption that DRAM==DMA.

This is a compatible change.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Hao Wu
2017-10-30 11:15:08 +08:00
parent 44a0857ec6
commit 85ad9a6e0a
7 changed files with 483 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
/** @file
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -136,6 +136,11 @@ EMMC_PEIM_HC_PRIVATE_DATA gEmmcHcPrivateTemplate = {
&gEfiPeiVirtualBlockIo2PpiGuid,
NULL
},
{ // EndOfPeiNotifyList
(EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiEndOfPeiSignalPpiGuid,
EmmcBlockIoPeimEndOfPei
},
{ // Slot
{
0,
@@ -618,6 +623,36 @@ EmmcBlockIoPeimReadBlocks2 (
return Status;
}
/**
One notified function to cleanup the allocated DMA buffers at the end of PEI.
@param[in] PeiServices Pointer to PEI Services Table.
@param[in] NotifyDescriptor Pointer to the descriptor for the Notification
event that caused this function to execute.
@param[in] Ppi Pointer to the PPI data associated with this function.
@retval EFI_SUCCESS The function completes successfully
**/
EFI_STATUS
EFIAPI
EmmcBlockIoPeimEndOfPei (
IN EFI_PEI_SERVICES **PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
IN VOID *Ppi
)
{
EMMC_PEIM_HC_PRIVATE_DATA *Private;
Private = GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor);
if ((Private->Pool != NULL) && (Private->Pool->Head != NULL)) {
EmmcPeimFreeMemPool (Private->Pool);
}
return EFI_SUCCESS;
}
/**
The user code starts with this function.
@@ -672,6 +707,8 @@ InitializeEmmcBlockIoPeim (
return EFI_DEVICE_ERROR;
}
IoMmuInit ();
Controller = 0;
MmioBase = NULL;
while (TRUE) {
@@ -800,6 +837,11 @@ InitializeEmmcBlockIoPeim (
if (!EFI_ERROR (Status)) {
PeiServicesInstallPpi (&Private->BlkIoPpiList);
PeiServicesNotifyPpi (&Private->EndOfPeiNotifyList);
} else {
if (Private->Pool->Head != NULL) {
EmmcPeimFreeMemPool (Private->Pool);
}
}
}