/* @memory: start of the memory area to be freed @pages: number of pages to be freed Return: status code  */
efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
/* @memory: start of the memory area to be freed @pages: number of pages to be freed Return: status code  */
efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
{
	efi_status_t ret;
	ret = efi_check_allocated(memory, true);
	if (ret != EFI_SUCCESS)
		return ret;
	if (!memory || (memory & EFI_PAGE_MASK) || !pages) {
		printf("%s: illegal free 0x%llx, 0x%zx\n", __func__,
		       memory, pages);
		return EFI_INVALID_PARAMETER;
	}
	ret = efi_add_memory_map(memory, pages, EFI_CONVENTIONAL_MEMORY, false);
	if (ret != EFI_SUCCESS)
		return EFI_NOT_FOUND;
	return ret;
}