2 DxeServicesLib memory allocation routines
4 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/UefiBootServicesTableLib.h>
12 #include <Library/DxeServicesLib.h>
15 Allocates one or more 4KB pages of a given type from a memory region that is
18 Allocates the number of 4KB pages of type 'MemoryType' and returns a
19 pointer to the allocated buffer. The buffer returned is aligned on a 4KB
20 boundary. If Pages is 0, then NULL is returned. If there is not enough
21 memory remaining to satisfy the request, then NULL is returned.
23 @param[in] MemoryType The memory type to allocate
24 @param[in] Pages The number of 4 KB pages to allocate.
26 @return A pointer to the allocated buffer or NULL if allocation fails.
31 AllocatePeiAccessiblePages (
32 IN EFI_MEMORY_TYPE MemoryType
,
37 EFI_PHYSICAL_ADDRESS Memory
;
43 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, Pages
, &Memory
);
44 if (EFI_ERROR (Status
)) {
47 return (VOID
*)(UINTN
)Memory
;