提交 997ef4ae 编写于 作者: M Marvin Häuser

User/UserBaseMemoryLib: Define aligned page alloc definitions

上级 8d349232
......@@ -206,13 +206,14 @@ PhaseAllocatePool (
return Buffer;
}
STATIC
EFI_STATUS
EFIAPI
PhaseAllocatePages (
InternalAllocatePagesAlign (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
IN OUT EFI_PHYSICAL_ADDRESS *Memory,
IN UINT32 Alignment
)
{
VOID *Buffer;
......@@ -231,12 +232,12 @@ PhaseAllocatePages (
//
if (RequestedAllocationSize <= mPoolAllocationSizeLimit) {
#ifdef _WIN32
Buffer = _aligned_malloc (RequestedAllocationSize, EFI_PAGE_SIZE);
Buffer = _aligned_malloc (RequestedAllocationSize, Alignment);
#else // !_WIN32
Buffer = NULL;
INTN RetVal;
RetVal = posix_memalign (&Buffer, EFI_PAGE_SIZE, RequestedAllocationSize);
RetVal = posix_memalign (&Buffer, Alignment, RequestedAllocationSize);
if (RetVal != 0) {
DEBUG ((DEBUG_ERROR, "posix_memalign returns error %d\n", RetVal));
Buffer = NULL;
......@@ -267,6 +268,24 @@ PhaseAllocatePages (
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
PhaseAllocatePages (
IN EFI_ALLOCATE_TYPE Type,
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN OUT EFI_PHYSICAL_ADDRESS *Memory
)
{
return InternalAllocatePagesAlign (
Type,
MemoryType,
Pages,
Memory,
EFI_PAGE_SIZE
);
}
VOID
EFIAPI
PhaseFreePool (
......@@ -353,6 +372,39 @@ PhaseFreePages (
return EFI_SUCCESS;
}
VOID *
InternalAllocateAlignedPages (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
IN UINTN Alignment
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS Memory;
Status = InternalAllocatePagesAlign (
AllocateAnyPages,
MemoryType,
Pages,
&Memory,
EFI_PAGE_SIZE
);
if (EFI_ERROR (Status)) {
return NULL;
}
return (VOID *)(UINTN)Memory;
}
VOID
InternalFreeAlignedPages (
IN VOID *Buffer,
IN UINTN Pages
)
{
PhaseFreePages ((UINTN)Buffer, Pages);
}
GUID *
EFIAPI
CopyGuid (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册