MdePkg/DxeServicesLib: introduce AllocatePeiAccessiblePages routine

Add a routine to DxeServicesLib that abstracts the allocation of memory
that should be accessible by PEI after resuming from S3. We will use it
to replace open coded implementations that limit the address to < 4 GB,
which may not be possible on non-Intel systems that have no 32-bit
addressable memory at all.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Ard Biesheuvel
2018-05-24 10:44:01 +02:00
parent 97399f2d6f
commit a40e0b7aa9
4 changed files with 155 additions and 2 deletions

View File

@@ -305,5 +305,26 @@ GetFileDevicePathFromAnyFv (
OUT EFI_DEVICE_PATH_PROTOCOL **FvFileDevicePath
);
#endif
/**
Allocates one or more 4KB pages of a given type from a memory region that is
accessible to PEI.
Allocates the number of 4KB pages of type '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[in] MemoryType The memory type to allocate
@param[in] Pages The number of 4 KB pages to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
AllocatePeiAccessiblePages (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages
);
#endif