/* @mmio_ptr: pointer to a pointer to the start of the memory-mapped IO region @len: size of the memory-mapped IO region Returns: status code  */
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
/* @mmio_ptr: pointer to a pointer to the start of the memory-mapped IO region @len: size of the memory-mapped IO region Returns: status code  */
efi_status_t efi_add_runtime_mmio(void *mmio_ptr, u64 len)
{
	struct efi_runtime_mmio_list *newmmio;
	u64 pages = (len + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT;
	uint64_t addr = *(uintptr_t *)mmio_ptr;
	efi_status_t ret;
	ret = efi_add_memory_map(addr, pages, EFI_MMAP_IO, false);
	if (ret != EFI_SUCCESS)
		return EFI_OUT_OF_RESOURCES;
	newmmio = calloc(1, sizeof(*newmmio));
	if (!newmmio)
		return EFI_OUT_OF_RESOURCES;
	newmmio->ptr = mmio_ptr;
	newmmio->paddr = *(uintptr_t *)mmio_ptr;
	newmmio->len = len;
	list_add_tail(&newmmio->link, &efi_runtime_mmio);
	return EFI_SUCCESS;
}