MdeModulePkg/XhciPei: Fix Aligned Page Allocation

Add support for allocating aligned pages at an alignment higher
than 4K. The new function allocated memory taking into account
the padding required and then frees up unused pages before mapping
it.

Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Ashish Singhal
2019-10-16 01:20:47 +08:00
committed by Matt DeVillier
parent 6bd9d60b41
commit 4ba839c5c8
3 changed files with 160 additions and 21 deletions

View File

@@ -349,4 +349,32 @@ IoMmuFreeBuffer (
IN VOID *Mapping
);
/**
Allocates aligned pages that are suitable for an OperationBusMasterCommonBuffer or
OperationBusMasterCommonBuffer64 mapping.
@param Pages The number of pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
@param HostAddress A pointer to store the base system memory address of the
allocated range.
@param DeviceAddress The resulting map address for the bus master PCI controller to use to
access the hosts HostAddress.
@param Mapping A resulting value to pass to Unmap().
@retval EFI_SUCCESS The requested memory pages were allocated.
@retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
MEMORY_WRITE_COMBINE and MEMORY_CACHED.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
**/
EFI_STATUS
IoMmuAllocateAlignedBuffer (
IN UINTN Pages,
IN UINTN Alignment,
OUT VOID **HostAddress,
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
);
#endif