/* [map->virt_addr, map->virt_addr + map->length) and [virt_addr, virt_addr + length) have intersection. And the physical address in the intersection are the same.  */
static void mapping_merge(MemoryMapping *map, hwaddr virt_addr, ram_addr_t length)
/* [map->virt_addr, map->virt_addr + map->length) and [virt_addr, virt_addr + length) have intersection. And the physical address in the intersection are the same.  */
static void mapping_merge(MemoryMapping *map, hwaddr virt_addr, ram_addr_t length)
{
    if (virt_addr < map->virt_addr) {
        map->length += map->virt_addr - virt_addr;
        map->virt_addr = virt_addr;
    }
    if ((virt_addr + length) >
        (map->virt_addr + map->length)) {
        map->length = virt_addr + length - map->virt_addr;
    }
}