/* @pool_type: type of the pool from which memory is to be allocated @size: number of bytes to be allocated @buffer: allocated memory Return: status code  */
efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
/* @pool_type: type of the pool from which memory is to be allocated @size: number of bytes to be allocated @buffer: allocated memory Return: status code  */
efi_status_t efi_allocate_pool(int pool_type, efi_uintn_t size, void **buffer)
{
	efi_status_t r;
	u64 addr;
	struct efi_pool_allocation *alloc;
	u64 num_pages = efi_size_in_pages(size +
					  sizeof(struct efi_pool_allocation));
	if (!buffer)
		return EFI_INVALID_PARAMETER;
	if (size == 0) {
		*buffer = NULL;
		return EFI_SUCCESS;
	}
	r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, pool_type, num_pages,
			       &addr);
	if (r == EFI_SUCCESS) {
		alloc = (struct efi_pool_allocation *)(uintptr_t)addr;
		alloc->num_pages = num_pages;
		alloc->checksum = checksum(alloc);
		*buffer = alloc->data;
	}
	return r;
}