From d369a5e1632caff3bafa38b10275d7b4151c1bf9 Mon Sep 17 00:00:00 2001 From: belliash Date: Sun, 21 Aug 2022 17:05:05 +0200 Subject: [PATCH] Implement BlEfiMemoryAllocatePool() and BlEfiMemoryFreePool() --- xtldr/efiutil.c | 38 ++++++++++++++++++++++++++++++++++++++ xtldr/includes/xtbl.h | 7 +++++++ 2 files changed, 45 insertions(+) diff --git a/xtldr/efiutil.c b/xtldr/efiutil.c index d9a3d4d..34adcf9 100644 --- a/xtldr/efiutil.c +++ b/xtldr/efiutil.c @@ -155,6 +155,44 @@ BlDbgPrint(IN PUINT16 Format, } } +/** + * This routine allocates a pool memory. + * + * @param Size + * The number of bytes to allocate from the pool. + * + * @param Memory + * The pointer to a physical address. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +EFI_STATUS +BlEfiMemoryAllocatePool(IN UINT_PTR Size, + OUT PVOID *Memory) +{ + /* Allocate pool */ + return EfiSystemTable->BootServices->AllocatePool(EfiLoaderData, Size, Memory); +} + +/** + * Returns pool memory to the system. + * + * @param Memory + * The pointer to the buffer to free. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +EFI_STATUS +BlEfiMemoryFreePool(IN PVOID Memory) +{ + /* Free pool */ + return EfiSystemTable->BootServices->FreePool(Memory); +} + /** * This routine formats the input string and prints it out to the stdout and serial console. * diff --git a/xtldr/includes/xtbl.h b/xtldr/includes/xtbl.h index 4b2bb06..444b8c6 100644 --- a/xtldr/includes/xtbl.h +++ b/xtldr/includes/xtbl.h @@ -41,6 +41,13 @@ VOID BlDbgPrint(IN PUINT16 Format, IN ...); +EFI_STATUS +BlEfiMemoryAllocatePool(IN UINT_PTR Size, + OUT PVOID *Memory); + +EFI_STATUS +BlEfiMemoryFreePool(IN PVOID Memory); + VOID BlEfiPrint(IN PUINT16 Format, IN ...);