From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/edk2/MdePkg/Library/DxeServicesLib/Allocate.c | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 roms/edk2/MdePkg/Library/DxeServicesLib/Allocate.c (limited to 'roms/edk2/MdePkg/Library/DxeServicesLib/Allocate.c') diff --git a/roms/edk2/MdePkg/Library/DxeServicesLib/Allocate.c b/roms/edk2/MdePkg/Library/DxeServicesLib/Allocate.c new file mode 100644 index 000000000..efb65768b --- /dev/null +++ b/roms/edk2/MdePkg/Library/DxeServicesLib/Allocate.c @@ -0,0 +1,48 @@ +/** @file + DxeServicesLib memory allocation routines + + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include + +/** + 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 + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS Memory; + + if (Pages == 0) { + return NULL; + } + + Status = gBS->AllocatePages (AllocateAnyPages, MemoryType, Pages, &Memory); + if (EFI_ERROR (Status)) { + return NULL; + } + return (VOID *)(UINTN)Memory; +} -- cgit 1.2.3-korg