void *address_space_map(AddressSpace *as,

                        hwaddr addr,

                        hwaddr *plen,

                        bool is_write)

{

    AddressSpaceDispatch *d = as->dispatch;

    hwaddr len = *plen;

    hwaddr todo = 0;

    int l;

    hwaddr page;

    MemoryRegionSection *section;

    ram_addr_t raddr = RAM_ADDR_MAX;

    ram_addr_t rlen;

    void *ret;



    while (len > 0) {

        page = addr & TARGET_PAGE_MASK;

        l = (page + TARGET_PAGE_SIZE) - addr;

        if (l > len)

            l = len;

        section = phys_page_find(d, page >> TARGET_PAGE_BITS);



        if (!(memory_region_is_ram(section->mr) && !section->readonly)) {

            if (todo || bounce.buffer) {

                break;

            }

            bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE);

            bounce.addr = addr;

            bounce.len = l;

            if (!is_write) {

                address_space_read(as, addr, bounce.buffer, l);

            }



            *plen = l;

            return bounce.buffer;

        }

        if (!todo) {

            raddr = memory_region_get_ram_addr(section->mr)

                + memory_region_section_addr(section, addr);

        }



        len -= l;

        addr += l;

        todo += l;

    }

    rlen = todo;

    ret = qemu_ram_ptr_length(raddr, &rlen);

    *plen = rlen;

    return ret;

}

void *address_space_map(AddressSpace *as,

                        hwaddr addr,

                        hwaddr *plen,

                        bool is_write)

{

    AddressSpaceDispatch *d = as->dispatch;

    hwaddr len = *plen;

    hwaddr todo = 0;

    int l;

    hwaddr page;

    MemoryRegionSection *section;

    ram_addr_t raddr = RAM_ADDR_MAX;

    ram_addr_t rlen;

    void *ret;



    while (len > 0) {

        page = addr & TARGET_PAGE_MASK;

        l = (page + TARGET_PAGE_SIZE) - addr;

        if (l > len)

            l = len;

        section = phys_page_find(d, page >> TARGET_PAGE_BITS);



        if (!(memory_region_is_ram(section->mr) && !section->readonly)) {

            if (todo || bounce.buffer) {

                break;

            }

            bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE);

            bounce.addr = addr;

            bounce.len = l;

            if (!is_write) {

                address_space_read(as, addr, bounce.buffer, l);

            }



            *plen = l;

            return bounce.buffer;

        }

        if (!todo) {

            raddr = memory_region_get_ram_addr(section->mr)

                + memory_region_section_addr(section, addr);

        }



        len -= l;

        addr += l;

        todo += l;

    }

    rlen = todo;

    ret = qemu_ram_ptr_length(raddr, &rlen);

    *plen = rlen;

    return ret;

}

void *FUNC_0(AddressSpace *VAR_0,

                        hwaddr VAR_1,

                        hwaddr *VAR_2,

                        bool VAR_3)

{

    AddressSpaceDispatch *d = VAR_0->dispatch;

    hwaddr len = *VAR_2;

    hwaddr todo = 0;

    int VAR_4;

    hwaddr page;

    MemoryRegionSection *section;

    ram_addr_t raddr = RAM_ADDR_MAX;

    ram_addr_t rlen;

    void *VAR_5;



    while (len > 0) {

        page = VAR_1 & TARGET_PAGE_MASK;

        VAR_4 = (page + TARGET_PAGE_SIZE) - VAR_1;

        if (VAR_4 > len)

            VAR_4 = len;

        section = phys_page_find(d, page >> TARGET_PAGE_BITS);



        if (!(memory_region_is_ram(section->mr) && !section->readonly)) {

            if (todo || bounce.buffer) {

                break;

            }

            bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE);

            bounce.VAR_1 = VAR_1;

            bounce.len = VAR_4;

            if (!VAR_3) {

                address_space_read(VAR_0, VAR_1, bounce.buffer, VAR_4);

            }



            *VAR_2 = VAR_4;

            return bounce.buffer;

        }

        if (!todo) {

            raddr = memory_region_get_ram_addr(section->mr)

                + memory_region_section_addr(section, VAR_1);

        }



        len -= VAR_4;

        VAR_1 += VAR_4;

        todo += VAR_4;

    }

    rlen = todo;

    VAR_5 = qemu_ram_ptr_length(raddr, &rlen);

    *VAR_2 = rlen;

    return VAR_5;

}

void *FUNC_0(AddressSpace *VAR_0,
hwaddr VAR_1,
hwaddr *VAR_2,
bool VAR_3)
{ AddressSpaceDispatch *d = VAR_0->dispatch; hwaddr len = *VAR_2; hwaddr todo = 0; int VAR_4; hwaddr page; MemoryRegionSection *section; ram_addr_t raddr = RAM_ADDR_MAX; ram_addr_t rlen; void *VAR_5; while (len > 0) { page = VAR_1 & TARGET_PAGE_MASK; VAR_4 = (page + TARGET_PAGE_SIZE) - VAR_1; if (VAR_4 > len)
VAR_4 = len; section = phys_page_find(d, page >> TARGET_PAGE_BITS); if (!(memory_region_is_ram(section->mr) && !section->readonly)) { if (todo || bounce.buffer) { break; } bounce.buffer = qemu_memalign(TARGET_PAGE_SIZE, TARGET_PAGE_SIZE); bounce.VAR_1 = VAR_1; bounce.len = VAR_4; if (!VAR_3) { address_space_read(VAR_0, VAR_1, bounce.buffer, VAR_4); } *VAR_2 = VAR_4; return bounce.buffer; } if (!todo) { raddr = memory_region_get_ram_addr(section->mr)
+ memory_region_section_addr(section, VAR_1); } len -= VAR_4; VAR_1 += VAR_4; todo += VAR_4; } rlen = todo; VAR_5 = qemu_ram_ptr_length(raddr, &rlen); *VAR_2 = rlen; return VAR_5; }