MdeModulePkg/SdBlockIoPei: Support IoMmu

Update the SdBlockIoPei 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 13:49:31 +08:00
parent 85ad9a6e0a
commit 77af86688c
7 changed files with 483 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
/** @file
Copyright (c) 2015 - 2016, 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
@@ -29,9 +29,11 @@ SdPeimAllocMemBlock (
)
{
SD_PEIM_MEM_BLOCK *Block;
VOID *BufHost;
VOID *Mapping;
EFI_PHYSICAL_ADDRESS MappedAddr;
EFI_STATUS Status;
VOID *TempPtr;
EFI_PHYSICAL_ADDRESS Address;
TempPtr = NULL;
Block = NULL;
@@ -62,19 +64,22 @@ SdPeimAllocMemBlock (
Block->Bits = (UINT8*)(UINTN)TempPtr;
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
Status = IoMmuAllocateBuffer (
Pages,
&Address
&BufHost,
&MappedAddr,
&Mapping
);
if (EFI_ERROR (Status)) {
return NULL;
}
ZeroMem ((VOID*)(UINTN)Address, EFI_PAGES_TO_SIZE (Pages));
ZeroMem ((VOID*)(UINTN)BufHost, EFI_PAGES_TO_SIZE (Pages));
Block->Buf = (UINT8*)((UINTN)Address);
Block->Next = NULL;
Block->BufHost = (UINT8 *) (UINTN) BufHost;
Block->Buf = (UINT8 *) (UINTN) MappedAddr;
Block->Mapping = Mapping;
Block->Next = NULL;
return Block;
}
@@ -93,6 +98,8 @@ SdPeimFreeMemBlock (
)
{
ASSERT ((Pool != NULL) && (Block != NULL));
IoMmuFreeBuffer (EFI_SIZE_TO_PAGES (Block->BufLen), Block->BufHost, Block->Mapping);
}
/**