/* ARMv7-specific implementation of memory unmapping at run-time Unmaps memory according to the parameters provided by the caller at run-time.  */
static int __arch_mem_unmap(void *addr, size_t size)
/* ARMv7-specific implementation of memory unmapping at run-time Unmaps memory according to the parameters provided by the caller at run-time.  */
static int __arch_mem_unmap(void *addr, size_t size)
{
	uint32_t va = (uint32_t)addr;
	uint32_t rem_size = (uint32_t)size;
	int key;
	if (addr == NULL) {
		LOG_ERR("Cannot unmap virtual memory: invalid NULL pointer");
		return -EINVAL;
	}
	if (size == 0) {
		LOG_ERR("Cannot unmap virtual memory at 0x%08X: invalid "
			"zero size", (uint32_t)addr);
		return -EINVAL;
	}
	key = arch_irq_lock();
	while (rem_size > 0) {
		arm_mmu_l2_unmap_page(va);
		rem_size -= (rem_size >= KB(4)) ? KB(4) : rem_size;
		va += KB(4);
	}
	arch_irq_unlock(key);
	return 0;
}