Move memory related routines to a separate file and implement BlGetMemoryMap() routine

This commit is contained in:
2022-12-05 20:08:18 +01:00
parent 6b2f34f287
commit 2f03f84a20
4 changed files with 169 additions and 78 deletions

View File

@@ -162,84 +162,6 @@ BlDbgPrint(IN PUINT16 Format,
}
}
/**
* This routine allocates one or more 4KB pages.
*
* @param Pages
* 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 Pages,
OUT PEFI_PHYSICAL_ADDRESS Memory)
{
return EfiSystemTable->BootServices->AllocatePages(AllocateAnyPages, EfiLoaderData, Pages, Memory);
}
/**
* 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);
}
/**
* This routine frees memory pages.
*
* @param Pages
* 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 Pages,
IN EFI_PHYSICAL_ADDRESS Memory)
{
return EfiSystemTable->BootServices->FreePages(Memory, Pages);
}
/**
* 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.
*