diff --git a/xtldr/efiutil.c b/xtldr/efiutil.c index 3f06c72..cf11938 100644 --- a/xtldr/efiutil.c +++ b/xtldr/efiutil.c @@ -162,6 +162,27 @@ BlDbgPrint(IN PUINT16 Format, } } +/** + * This routine allocates one or more 4KB pages. + * + * @param Size + * The number of contiguous 4KB pages to allocate. + * + * @param Memory + * The pointer to a physical address. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +EFI_STATUS +BlEfiMemoryAllocatePages(IN UINT64 Size, + OUT PEFI_PHYSICAL_ADDRESS Memory) +{ + return EfiSystemTable->BootServices->AllocatePages(AllocateAnyPages, EfiRuntimeServicesData, + EFI_SIZE_TO_PAGES(Size), Memory); +} + /** * This routine allocates a pool memory. * @@ -183,6 +204,26 @@ BlEfiMemoryAllocatePool(IN UINT_PTR Size, return EfiSystemTable->BootServices->AllocatePool(EfiLoaderData, Size, Memory); } +/** + * This routine frees memory pages. + * + * @param Size + * The number of contiguous 4 KB pages to free. + * + * @param Memory + * The base physical address of the pages to be freed. + * + * @return This routine returns a status code. + * + * @since XT 1.0 + */ +EFI_STATUS +BlEfiMemoryFreePages(IN UINT64 Size, + IN EFI_PHYSICAL_ADDRESS Memory) +{ + return EfiSystemTable->BootServices->FreePages(Memory, Size); +} + /** * Returns pool memory to the system. * diff --git a/xtldr/includes/xtbl.h b/xtldr/includes/xtbl.h index c615594..4c7e38e 100644 --- a/xtldr/includes/xtbl.h +++ b/xtldr/includes/xtbl.h @@ -58,10 +58,18 @@ EFI_STATUS BlEfiGetSystemConfigurationTable(IN PEFI_GUID TableGuid, OUT PVOID *Table); +EFI_STATUS +BlEfiMemoryAllocatePages(IN UINT64 Size, + OUT PEFI_PHYSICAL_ADDRESS Memory); + EFI_STATUS BlEfiMemoryAllocatePool(IN UINT_PTR Size, OUT PVOID *Memory); +EFI_STATUS +BlEfiMemoryFreePages(IN UINT64 Size, + IN EFI_PHYSICAL_ADDRESS Memory); + EFI_STATUS BlEfiMemoryFreePool(IN PVOID Memory);