RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429
Allocates one or more 4KB pages of given type MemoryType. Allocates the number of 4KB pages of MemoryType and returns a pointer to the allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> --- MdePkg/Include/Library/MemoryAllocationLib.h | 21 +++++++++++++++ .../MemoryAllocationLib.c | 27 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/MdePkg/Include/Library/MemoryAllocationLib.h b/MdePkg/Include/Library/MemoryAllocationLib.h index 65a30cf146dd..2bdc0592ef3e 100644 --- a/MdePkg/Include/Library/MemoryAllocationLib.h +++ b/MdePkg/Include/Library/MemoryAllocationLib.h @@ -484,4 +484,25 @@ FreePool ( IN VOID *Buffer ); +/** + Allocates one or more 4KB pages of given type MemoryType. + + Allocates the number of 4KB pages of MemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages + is 0, then NULL is returned. If there is not enough memory remaining to satisfy + the request, then NULL is returned. + + @param MemoryType Type of memory to use for this allocation. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocatePagesWithMemoryType ( + IN UINTN MemoryType, + IN UINTN Pages + ); + #endif diff --git a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c index b3f9df74f139..dcb313349729 100644 --- a/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c +++ b/MdePkg/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c @@ -839,4 +839,31 @@ FreePool ( // } +/** + Allocates one or more 4KB pages of given type MemoryType. + Allocates the number of 4KB pages of MemoryType and returns a pointer to the + allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages + is 0, then NULL is returned. If there is not enough memory remaining to satisfy + the request, then NULL is returned. + + @param MemoryType Type of memory to use for this allocation. + @param Pages The number of 4 KB pages to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +AllocatePagesWithMemoryType ( + IN UINTN MemoryType, + IN UINTN Pages + ) +{ + if (MemoryType >= EfiMaxMemoryType) { + ASSERT (FALSE); + return NULL; + } + + return InternalAllocatePages (MemoryType, Pages); +} -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#79176): https://edk2.groups.io/g/devel/message/79176 Mute This Topic: https://groups.io/mt/84837917/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-