2 DxeServicesLib memory allocation routines
4 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available
7 under the terms and conditions of the BSD License which accompanies this
8 distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/UefiBootServicesTableLib.h>
18 #include <Library/DxeServicesLib.h>
21 Allocates one or more 4KB pages of a given type from a memory region that is
24 Allocates the number of 4KB pages of type 'MemoryType' and returns a
25 pointer to the allocated buffer. The buffer returned is aligned on a 4KB
26 boundary. If Pages is 0, then NULL is returned. If there is not enough
27 memory remaining to satisfy the request, then NULL is returned.
29 @param[in] MemoryType The memory type to allocate
30 @param[in] Pages The number of 4 KB pages to allocate.
32 @return A pointer to the allocated buffer or NULL if allocation fails.
37 AllocatePeiAccessiblePages (
38 IN EFI_MEMORY_TYPE MemoryType
,
43 EFI_PHYSICAL_ADDRESS Memory
;
49 Status
= gBS
->AllocatePages (AllocateAnyPages
, MemoryType
, Pages
, &Memory
);
50 if (EFI_ERROR (Status
)) {
53 return (VOID
*)(UINTN
)Memory
;