Revision 052e87b0 exec.c

b/exec.c
801 801
    MemoryRegionSection *existing = phys_page_find(d, base >> TARGET_PAGE_BITS);
802 802
    MemoryRegionSection subsection = {
803 803
        .offset_within_address_space = base,
804
        .size = TARGET_PAGE_SIZE,
804
        .size = int128_make64(TARGET_PAGE_SIZE),
805 805
    };
806 806
    hwaddr start, end;
807 807

  
......
816 816
        subpage = container_of(existing->mr, subpage_t, iomem);
817 817
    }
818 818
    start = section->offset_within_address_space & ~TARGET_PAGE_MASK;
819
    end = start + section->size - 1;
819
    end = start + int128_get64(section->size) - 1;
820 820
    subpage_register(subpage, start, end, phys_section_add(section));
821 821
}
822 822

  
823 823

  
824
static void register_multipage(AddressSpaceDispatch *d, MemoryRegionSection *section)
824
static void register_multipage(AddressSpaceDispatch *d,
825
                               MemoryRegionSection *section)
825 826
{
826 827
    hwaddr start_addr = section->offset_within_address_space;
827 828
    uint16_t section_index = phys_section_add(section);
828
    uint64_t num_pages = section->size >> TARGET_PAGE_BITS;
829
    uint64_t num_pages = int128_get64(int128_rshift(section->size,
830
                                                    TARGET_PAGE_BITS));
829 831

  
830 832
    assert(num_pages);
831 833
    phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index);
......
835 837
{
836 838
    AddressSpaceDispatch *d = container_of(listener, AddressSpaceDispatch, listener);
837 839
    MemoryRegionSection now = *section, remain = *section;
840
    Int128 page_size = int128_make64(TARGET_PAGE_SIZE);
838 841

  
839 842
    if (now.offset_within_address_space & ~TARGET_PAGE_MASK) {
840 843
        uint64_t left = TARGET_PAGE_ALIGN(now.offset_within_address_space)
841 844
                       - now.offset_within_address_space;
842 845

  
843
        now.size = MIN(left, now.size);
846
        now.size = int128_min(int128_make64(left), now.size);
844 847
        register_subpage(d, &now);
845 848
    } else {
846
        now.size = 0;
849
        now.size = int128_zero();
847 850
    }
848
    while (remain.size != now.size) {
849
        remain.size -= now.size;
850
        remain.offset_within_address_space += now.size;
851
        remain.offset_within_region += now.size;
851
    while (int128_ne(remain.size, now.size)) {
852
        remain.size = int128_sub(remain.size, now.size);
853
        remain.offset_within_address_space += int128_get64(now.size);
854
        remain.offset_within_region += int128_get64(now.size);
852 855
        now = remain;
853
        if (remain.size < TARGET_PAGE_SIZE) {
856
        if (int128_lt(remain.size, page_size)) {
854 857
            register_subpage(d, &now);
855 858
        } else if (remain.offset_within_region & ~TARGET_PAGE_MASK) {
856
            now.size = TARGET_PAGE_SIZE;
859
            now.size = page_size;
857 860
            register_subpage(d, &now);
858 861
        } else {
859
            now.size &= -TARGET_PAGE_SIZE;
862
            now.size = int128_and(now.size, int128_neg(page_size));
860 863
            register_multipage(d, &now);
861 864
        }
862 865
    }
......
1666 1669
        .mr = mr,
1667 1670
        .offset_within_address_space = 0,
1668 1671
        .offset_within_region = 0,
1669
        .size = UINT64_MAX,
1672
        .size = int128_2_64(),
1670 1673
    };
1671 1674

  
1672 1675
    return phys_section_add(&section);
......
1735 1738
    mrio->mr = section->mr;
1736 1739
    mrio->offset = section->offset_within_region;
1737 1740
    iorange_init(&mrio->iorange, &memory_region_iorange_ops,
1738
                 section->offset_within_address_space, section->size);
1741
                 section->offset_within_address_space,
1742
                 int128_get64(section->size));
1739 1743
    ioport_register(&mrio->iorange);
1740 1744
}
1741 1745

  
1742 1746
static void io_region_del(MemoryListener *listener,
1743 1747
                          MemoryRegionSection *section)
1744 1748
{
1745
    isa_unassign_ioport(section->offset_within_address_space, section->size);
1749
    isa_unassign_ioport(section->offset_within_address_space,
1750
                        int128_get64(section->size));
1746 1751
}
1747 1752

  
1748 1753
static MemoryListener core_memory_listener = {

Also available in: Unified diff