Replace the call to emalloc() to uefi pool allocation

emalloc() is called only by construct_mbi() during creating e820 mmap
layout. The switching has two benefits: first, UEFI FW might keep some
memory in pool, unlike call to emalloc(), call to allocate_pool() might
have no impact on e820 mmap; on the other hand, we can remove emalloc()
routine after this switching.

Tracked-On:#1260
Signed-off-by: Chaohong Guo <chaohong.guo@intel.com>
Reviewed-by: Anthony Xu <Anthony.Xu@intel.com>
Acked-by: Gen Zheng <gen.zheng@intel.com>
This commit is contained in:
Chaohong guo 2018-09-17 14:22:07 +08:00 committed by lijinxia
parent 951a24cd3d
commit 1d15b98730

View File

@ -68,11 +68,10 @@ static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start,
EFI_STATUS construct_mbi(EFI_PHYSICAL_ADDRESS hv_hpa)
{
UINTN map_size, _map_size, map_key;
UINTN map_size, map_key;
UINT32 desc_version;
UINTN desc_size;
EFI_MEMORY_DESCRIPTOR *map_buf;
EFI_PHYSICAL_ADDRESS addr;
EFI_STATUS err = EFI_SUCCESS;
struct multiboot_info *mbi;
struct multiboot_mmap *mmap;
@ -92,11 +91,9 @@ EFI_STATUS construct_mbi(EFI_PHYSICAL_ADDRESS hv_hpa)
goto out;
again:
_map_size = map_size;
err = emalloc(map_size, 1, &addr);
err = allocate_pool(EfiLoaderData, map_size, (void **) &map_buf);
if (err != EFI_SUCCESS)
goto out;
map_buf = (EFI_MEMORY_DESCRIPTOR *)(UINTN)addr;
/*
* Remember! We've already allocated map_buf with emalloc (and
@ -115,7 +112,7 @@ again:
* larger. 'map_size' has been updated by the
* call to memory_map().
*/
efree((UINTN)map_buf, _map_size);
free_pool(map_buf);
goto again;
}
goto out;