Changes in kernel/generic/src/mm/as.c [7250d2c:e394b736] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/as.c
r7250d2c re394b736 94 94 * 95 95 * This lock protects: 96 * - inactive_as_with_asid_ list96 * - inactive_as_with_asid_head list 97 97 * - as->asid for each as of the as_t type 98 98 * - asids_allocated counter … … 105 105 * that have valid ASID. 106 106 */ 107 LIST_INITIALIZE(inactive_as_with_asid_ list);107 LIST_INITIALIZE(inactive_as_with_asid_head); 108 108 109 109 /** Kernel address space. */ … … 235 235 bool cond = true; 236 236 while (cond) { 237 ASSERT(!list_empty(&as->as_area_btree.leaf_ list));237 ASSERT(!list_empty(&as->as_area_btree.leaf_head)); 238 238 239 239 btree_node_t *node = 240 list_get_instance( list_first(&as->as_area_btree.leaf_list),240 list_get_instance(as->as_area_btree.leaf_head.next, 241 241 btree_node_t, leaf_link); 242 242 … … 302 302 * We don't want any area to have conflicts with NULL page. 303 303 */ 304 if (overlaps(addr, P2SZ(count), (uintptr_t) NULL, PAGE_SIZE))304 if (overlaps(addr, count << PAGE_WIDTH, (uintptr_t) NULL, PAGE_SIZE)) 305 305 return false; 306 306 … … 329 329 mutex_lock(&area->lock); 330 330 331 if (overlaps(addr, P2SZ(count), area->base,332 P2SZ(area->pages))) {331 if (overlaps(addr, count << PAGE_WIDTH, 332 area->base, area->pages << PAGE_WIDTH)) { 333 333 mutex_unlock(&area->lock); 334 334 return false; … … 346 346 mutex_lock(&area->lock); 347 347 348 if (overlaps(addr, P2SZ(count), area->base,349 P2SZ(area->pages))) {348 if (overlaps(addr, count << PAGE_WIDTH, 349 area->base, area->pages << PAGE_WIDTH)) { 350 350 mutex_unlock(&area->lock); 351 351 return false; … … 366 366 mutex_lock(&area->lock); 367 367 368 if (overlaps(addr, P2SZ(count), area->base,369 P2SZ(area->pages))) {368 if (overlaps(addr, count << PAGE_WIDTH, 369 area->base, area->pages << PAGE_WIDTH)) { 370 370 mutex_unlock(&area->lock); 371 371 return false; … … 380 380 */ 381 381 if (!KERNEL_ADDRESS_SPACE_SHADOWED) { 382 return !overlaps(addr, P2SZ(count), KERNEL_ADDRESS_SPACE_START, 382 return !overlaps(addr, count << PAGE_WIDTH, 383 KERNEL_ADDRESS_SPACE_START, 383 384 KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START); 384 385 } … … 473 474 474 475 btree_node_t *leaf; 475 as_area_t *area = (as_area_t *) btree_search(&as->as_area_btree, va, 476 &leaf); 476 as_area_t *area = (as_area_t *) btree_search(&as->as_area_btree, va, &leaf); 477 477 if (area) { 478 478 /* va is the base address of an address space area */ … … 482 482 483 483 /* 484 * Search the leaf node and the righ tmost record of its left neighbour484 * Search the leaf node and the righmost record of its left neighbour 485 485 * to find out whether this is a miss or va belongs to an address 486 486 * space area found there. … … 494 494 495 495 mutex_lock(&area->lock); 496 496 497 497 if ((area->base <= va) && 498 (va < = area->base + (P2SZ(area->pages) - 1)))498 (va < area->base + (area->pages << PAGE_WIDTH))) 499 499 return area; 500 500 … … 506 506 * Because of its position in the B+tree, it must have base < va. 507 507 */ 508 btree_node_t *lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, 509 leaf); 508 btree_node_t *lnode = btree_leaf_node_left_neighbour(&as->as_area_btree, leaf); 510 509 if (lnode) { 511 510 area = (as_area_t *) lnode->value[lnode->keys - 1]; … … 513 512 mutex_lock(&area->lock); 514 513 515 if (va < = area->base + (P2SZ(area->pages) - 1))514 if (va < area->base + (area->pages << PAGE_WIDTH)) 516 515 return area; 517 516 … … 578 577 579 578 if (pages < area->pages) { 580 uintptr_t start_free = area->base + P2SZ(pages);579 uintptr_t start_free = area->base + (pages << PAGE_WIDTH); 581 580 582 581 /* … … 591 590 */ 592 591 ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid, 593 area->base + P2SZ(pages), area->pages - pages);592 area->base + (pages << PAGE_WIDTH), area->pages - pages); 594 593 595 594 /* … … 602 601 bool cond = true; 603 602 while (cond) { 604 ASSERT(!list_empty(&area->used_space.leaf_ list));603 ASSERT(!list_empty(&area->used_space.leaf_head)); 605 604 606 605 btree_node_t *node = 607 list_get_instance( list_last(&area->used_space.leaf_list),606 list_get_instance(area->used_space.leaf_head.prev, 608 607 btree_node_t, leaf_link); 609 608 … … 614 613 size_t i = 0; 615 614 616 if (overlaps(ptr, P2SZ(size), area->base,617 P2SZ(pages))) {615 if (overlaps(ptr, size << PAGE_WIDTH, area->base, 616 pages << PAGE_WIDTH)) { 618 617 619 if (ptr + P2SZ(size) <= start_free) {618 if (ptr + (size << PAGE_WIDTH) <= start_free) { 620 619 /* 621 620 * The whole interval fits … … 648 647 649 648 for (; i < size; i++) { 650 pte_t *pte = page_mapping_find(as, 651 ptr + P2SZ(i), false);649 pte_t *pte = page_mapping_find(as, ptr + 650 (i << PAGE_WIDTH)); 652 651 653 652 ASSERT(pte); … … 658 657 (area->backend->frame_free)) { 659 658 area->backend->frame_free(area, 660 ptr + P2SZ(i),659 ptr + (i << PAGE_WIDTH), 661 660 PTE_GET_FRAME(pte)); 662 661 } 663 662 664 page_mapping_remove(as, ptr + P2SZ(i)); 663 page_mapping_remove(as, ptr + 664 (i << PAGE_WIDTH)); 665 665 } 666 666 } … … 671 671 */ 672 672 673 tlb_invalidate_pages(as->asid, area->base + P2SZ(pages),673 tlb_invalidate_pages(as->asid, area->base + (pages << PAGE_WIDTH), 674 674 area->pages - pages); 675 675 676 676 /* 677 * Invalidate software translation caches 678 * (e.g. TSB on sparc64, PHT on ppc32). 679 */ 680 as_invalidate_translation_cache(as, area->base + P2SZ(pages), 681 area->pages - pages); 677 * Invalidate software translation caches (e.g. TSB on sparc64). 678 */ 679 as_invalidate_translation_cache(as, area->base + 680 (pages << PAGE_WIDTH), area->pages - pages); 682 681 tlb_shootdown_finalize(ipl); 683 682 … … 727 726 if (--sh_info->refcount == 0) { 728 727 dealloc = true; 728 link_t *cur; 729 729 730 730 /* … … 732 732 * reference from all frames found there. 733 733 */ 734 list_foreach(sh_info->pagemap.leaf_list, cur) { 734 for (cur = sh_info->pagemap.leaf_head.next; 735 cur != &sh_info->pagemap.leaf_head; cur = cur->next) { 735 736 btree_node_t *node 736 737 = list_get_instance(cur, btree_node_t, leaf_link); … … 784 785 * Visit only the pages mapped by used_space B+tree. 785 786 */ 786 list_foreach(area->used_space.leaf_list, cur) { 787 link_t *cur; 788 for (cur = area->used_space.leaf_head.next; 789 cur != &area->used_space.leaf_head; cur = cur->next) { 787 790 btree_node_t *node; 788 791 btree_key_t i; … … 794 797 795 798 for (size = 0; size < (size_t) node->value[i]; size++) { 796 pte_t *pte = page_mapping_find(as,797 ptr + P2SZ(size), false);799 pte_t *pte = 800 page_mapping_find(as, ptr + (size << PAGE_WIDTH)); 798 801 799 802 ASSERT(pte); … … 804 807 (area->backend->frame_free)) { 805 808 area->backend->frame_free(area, 806 ptr + P2SZ(size), 807 PTE_GET_FRAME(pte)); 809 ptr + (size << PAGE_WIDTH), PTE_GET_FRAME(pte)); 808 810 } 809 811 810 page_mapping_remove(as, ptr + P2SZ(size));812 page_mapping_remove(as, ptr + (size << PAGE_WIDTH)); 811 813 } 812 814 } … … 820 822 821 823 /* 822 * Invalidate potential software translation caches 823 * (e.g. TSB on sparc64, PHT on ppc32).824 * Invalidate potential software translation caches (e.g. TSB on 825 * sparc64). 824 826 */ 825 827 as_invalidate_translation_cache(as, area->base, area->pages); … … 895 897 } 896 898 897 size_t src_size = P2SZ(src_area->pages);899 size_t src_size = src_area->pages << PAGE_WIDTH; 898 900 unsigned int src_flags = src_area->flags; 899 901 mem_backend_t *src_backend = src_area->backend; … … 1061 1063 */ 1062 1064 size_t used_pages = 0; 1063 1064 list_foreach(area->used_space.leaf_list, cur) { 1065 link_t *cur; 1066 1067 for (cur = area->used_space.leaf_head.next; 1068 cur != &area->used_space.leaf_head; cur = cur->next) { 1065 1069 btree_node_t *node 1066 1070 = list_get_instance(cur, btree_node_t, leaf_link); … … 1088 1092 size_t frame_idx = 0; 1089 1093 1090 list_foreach(area->used_space.leaf_list, cur) { 1091 btree_node_t *node = list_get_instance(cur, btree_node_t, 1092 leaf_link); 1094 for (cur = area->used_space.leaf_head.next; 1095 cur != &area->used_space.leaf_head; cur = cur->next) { 1096 btree_node_t *node 1097 = list_get_instance(cur, btree_node_t, leaf_link); 1093 1098 btree_key_t i; 1094 1099 … … 1098 1103 1099 1104 for (size = 0; size < (size_t) node->value[i]; size++) { 1100 pte_t *pte = page_mapping_find(as,1101 p tr + P2SZ(size), false);1105 pte_t *pte = 1106 page_mapping_find(as, ptr + (size << PAGE_WIDTH)); 1102 1107 1103 1108 ASSERT(pte); … … 1108 1113 1109 1114 /* Remove old mapping */ 1110 page_mapping_remove(as, ptr + P2SZ(size));1115 page_mapping_remove(as, ptr + (size << PAGE_WIDTH)); 1111 1116 } 1112 1117 } … … 1120 1125 1121 1126 /* 1122 * Invalidate potential software translation caches 1123 * (e.g. TSB on sparc64, PHT on ppc32).1127 * Invalidate potential software translation caches (e.g. TSB on 1128 * sparc64). 1124 1129 */ 1125 1130 as_invalidate_translation_cache(as, area->base, area->pages); … … 1140 1145 frame_idx = 0; 1141 1146 1142 list_foreach(area->used_space.leaf_list, cur) { 1147 for (cur = area->used_space.leaf_head.next; 1148 cur != &area->used_space.leaf_head; cur = cur->next) { 1143 1149 btree_node_t *node 1144 1150 = list_get_instance(cur, btree_node_t, leaf_link); … … 1153 1159 1154 1160 /* Insert the new mapping */ 1155 page_mapping_insert(as, ptr + P2SZ(size),1161 page_mapping_insert(as, ptr + (size << PAGE_WIDTH), 1156 1162 old_frame[frame_idx++], page_flags); 1157 1163 … … 1234 1240 */ 1235 1241 pte_t *pte; 1236 if ((pte = page_mapping_find(AS, page , false))) {1242 if ((pte = page_mapping_find(AS, page))) { 1237 1243 if (PTE_PRESENT(pte)) { 1238 1244 if (((access == PF_ACCESS_READ) && PTE_READABLE(pte)) || … … 1284 1290 * thing which is forbidden in this context is locking the address space. 1285 1291 * 1286 * When this function is en tered, no spinlocks may be held.1292 * When this function is enetered, no spinlocks may be held. 1287 1293 * 1288 1294 * @param old Old address space or NULL. … … 1326 1332 1327 1333 list_append(&old_as->inactive_as_with_asid_link, 1328 &inactive_as_with_asid_ list);1334 &inactive_as_with_asid_head); 1329 1335 } 1330 1336 … … 1475 1481 1476 1482 if (src_area) { 1477 size = P2SZ(src_area->pages);1483 size = src_area->pages << PAGE_WIDTH; 1478 1484 mutex_unlock(&src_area->lock); 1479 1485 } else … … 1530 1536 if (page >= right_pg) { 1531 1537 /* Do nothing. */ 1532 } else if (overlaps(page, P2SZ(count), left_pg,1533 P2SZ(left_cnt))) {1538 } else if (overlaps(page, count << PAGE_WIDTH, left_pg, 1539 left_cnt << PAGE_WIDTH)) { 1534 1540 /* The interval intersects with the left interval. */ 1535 1541 return false; 1536 } else if (overlaps(page, P2SZ(count), right_pg,1537 P2SZ(right_cnt))) {1542 } else if (overlaps(page, count << PAGE_WIDTH, right_pg, 1543 right_cnt << PAGE_WIDTH)) { 1538 1544 /* The interval intersects with the right interval. */ 1539 1545 return false; 1540 } else if ((page == left_pg + P2SZ(left_cnt)) &&1541 (page + P2SZ(count) == right_pg)) {1546 } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) && 1547 (page + (count << PAGE_WIDTH) == right_pg)) { 1542 1548 /* 1543 1549 * The interval can be added by merging the two already … … 1547 1553 btree_remove(&area->used_space, right_pg, leaf); 1548 1554 goto success; 1549 } else if (page == left_pg + P2SZ(left_cnt)) {1555 } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) { 1550 1556 /* 1551 1557 * The interval can be added by simply growing the left … … 1554 1560 node->value[node->keys - 1] += count; 1555 1561 goto success; 1556 } else if (page + P2SZ(count) == right_pg) {1562 } else if (page + (count << PAGE_WIDTH) == right_pg) { 1557 1563 /* 1558 1564 * The interval can be addded by simply moving base of … … 1581 1587 */ 1582 1588 1583 if (overlaps(page, P2SZ(count), right_pg, P2SZ(right_cnt))) { 1589 if (overlaps(page, count << PAGE_WIDTH, right_pg, 1590 right_cnt << PAGE_WIDTH)) { 1584 1591 /* The interval intersects with the right interval. */ 1585 1592 return false; 1586 } else if (page + P2SZ(count) == right_pg) {1593 } else if (page + (count << PAGE_WIDTH) == right_pg) { 1587 1594 /* 1588 1595 * The interval can be added by moving the base of the … … 1619 1626 if (page < left_pg) { 1620 1627 /* Do nothing. */ 1621 } else if (overlaps(page, P2SZ(count), left_pg,1622 P2SZ(left_cnt))) {1628 } else if (overlaps(page, count << PAGE_WIDTH, left_pg, 1629 left_cnt << PAGE_WIDTH)) { 1623 1630 /* The interval intersects with the left interval. */ 1624 1631 return false; 1625 } else if (overlaps(page, P2SZ(count), right_pg,1626 P2SZ(right_cnt))) {1632 } else if (overlaps(page, count << PAGE_WIDTH, right_pg, 1633 right_cnt << PAGE_WIDTH)) { 1627 1634 /* The interval intersects with the right interval. */ 1628 1635 return false; 1629 } else if ((page == left_pg + P2SZ(left_cnt)) &&1630 (page + P2SZ(count) == right_pg)) {1636 } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) && 1637 (page + (count << PAGE_WIDTH) == right_pg)) { 1631 1638 /* 1632 1639 * The interval can be added by merging the two already … … 1636 1643 btree_remove(&area->used_space, right_pg, node); 1637 1644 goto success; 1638 } else if (page == left_pg + P2SZ(left_cnt)) {1645 } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) { 1639 1646 /* 1640 1647 * The interval can be added by simply growing the left … … 1643 1650 leaf->value[leaf->keys - 1] += count; 1644 1651 goto success; 1645 } else if (page + P2SZ(count) == right_pg) {1652 } else if (page + (count << PAGE_WIDTH) == right_pg) { 1646 1653 /* 1647 1654 * The interval can be addded by simply moving base of … … 1670 1677 */ 1671 1678 1672 if (overlaps(page, P2SZ(count), left_pg, P2SZ(left_cnt))) { 1679 if (overlaps(page, count << PAGE_WIDTH, left_pg, 1680 left_cnt << PAGE_WIDTH)) { 1673 1681 /* The interval intersects with the left interval. */ 1674 1682 return false; 1675 } else if (left_pg + P2SZ(left_cnt) == page) {1683 } else if (left_pg + (left_cnt << PAGE_WIDTH) == page) { 1676 1684 /* 1677 1685 * The interval can be added by growing the left … … 1708 1716 */ 1709 1717 1710 if (overlaps(page, P2SZ(count), left_pg,1711 P2SZ(left_cnt))) {1718 if (overlaps(page, count << PAGE_WIDTH, left_pg, 1719 left_cnt << PAGE_WIDTH)) { 1712 1720 /* 1713 1721 * The interval intersects with the left … … 1715 1723 */ 1716 1724 return false; 1717 } else if (overlaps(page, P2SZ(count), right_pg,1718 P2SZ(right_cnt))) {1725 } else if (overlaps(page, count << PAGE_WIDTH, right_pg, 1726 right_cnt << PAGE_WIDTH)) { 1719 1727 /* 1720 1728 * The interval intersects with the right … … 1722 1730 */ 1723 1731 return false; 1724 } else if ((page == left_pg + P2SZ(left_cnt)) &&1725 (page + P2SZ(count) == right_pg)) {1732 } else if ((page == left_pg + (left_cnt << PAGE_WIDTH)) && 1733 (page + (count << PAGE_WIDTH) == right_pg)) { 1726 1734 /* 1727 1735 * The interval can be added by merging the two … … 1731 1739 btree_remove(&area->used_space, right_pg, leaf); 1732 1740 goto success; 1733 } else if (page == left_pg + P2SZ(left_cnt)) {1741 } else if (page == left_pg + (left_cnt << PAGE_WIDTH)) { 1734 1742 /* 1735 1743 * The interval can be added by simply growing … … 1738 1746 leaf->value[i - 1] += count; 1739 1747 goto success; 1740 } else if (page + P2SZ(count) == right_pg) {1748 } else if (page + (count << PAGE_WIDTH) == right_pg) { 1741 1749 /* 1742 1750 * The interval can be addded by simply moving … … 1804 1812 for (i = 0; i < leaf->keys; i++) { 1805 1813 if (leaf->key[i] == page) { 1806 leaf->key[i] += P2SZ(count);1814 leaf->key[i] += count << PAGE_WIDTH; 1807 1815 leaf->value[i] -= count; 1808 1816 goto success; … … 1814 1822 } 1815 1823 1816 btree_node_t *node = btree_leaf_node_left_neighbour(&area->used_space, 1817 leaf); 1824 btree_node_t *node = btree_leaf_node_left_neighbour(&area->used_space, leaf); 1818 1825 if ((node) && (page < leaf->key[0])) { 1819 1826 uintptr_t left_pg = node->key[node->keys - 1]; 1820 1827 size_t left_cnt = (size_t) node->value[node->keys - 1]; 1821 1828 1822 if (overlaps(left_pg, P2SZ(left_cnt), page, P2SZ(count))) { 1823 if (page + P2SZ(count) == left_pg + P2SZ(left_cnt)) { 1829 if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page, 1830 count << PAGE_WIDTH)) { 1831 if (page + (count << PAGE_WIDTH) == 1832 left_pg + (left_cnt << PAGE_WIDTH)) { 1824 1833 /* 1825 1834 * The interval is contained in the rightmost … … 1830 1839 node->value[node->keys - 1] -= count; 1831 1840 goto success; 1832 } else if (page + P2SZ(count) < 1833 left_pg + P2SZ(left_cnt)) { 1834 size_t new_cnt; 1835 1841 } else if (page + (count << PAGE_WIDTH) < 1842 left_pg + (left_cnt << PAGE_WIDTH)) { 1836 1843 /* 1837 1844 * The interval is contained in the rightmost … … 1841 1848 * new interval. 1842 1849 */ 1843 new_cnt = ((left_pg + P2SZ(left_cnt)) -1844 (page + P2SZ(count))) >> PAGE_WIDTH;1850 size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) - 1851 (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH; 1845 1852 node->value[node->keys - 1] -= count + new_cnt; 1846 1853 btree_insert(&area->used_space, page + 1847 P2SZ(count), (void *) new_cnt, leaf);1854 (count << PAGE_WIDTH), (void *) new_cnt, leaf); 1848 1855 goto success; 1849 1856 } … … 1858 1865 size_t left_cnt = (size_t) leaf->value[leaf->keys - 1]; 1859 1866 1860 if (overlaps(left_pg, P2SZ(left_cnt), page, P2SZ(count))) { 1861 if (page + P2SZ(count) == left_pg + P2SZ(left_cnt)) { 1867 if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page, 1868 count << PAGE_WIDTH)) { 1869 if (page + (count << PAGE_WIDTH) == 1870 left_pg + (left_cnt << PAGE_WIDTH)) { 1862 1871 /* 1863 1872 * The interval is contained in the rightmost … … 1867 1876 leaf->value[leaf->keys - 1] -= count; 1868 1877 goto success; 1869 } else if (page + P2SZ(count) < left_pg + 1870 P2SZ(left_cnt)) { 1871 size_t new_cnt; 1872 1878 } else if (page + (count << PAGE_WIDTH) < left_pg + 1879 (left_cnt << PAGE_WIDTH)) { 1873 1880 /* 1874 1881 * The interval is contained in the rightmost … … 1878 1885 * interval. 1879 1886 */ 1880 new_cnt = ((left_pg + P2SZ(left_cnt)) -1881 (page + P2SZ(count))) >> PAGE_WIDTH;1887 size_t new_cnt = ((left_pg + (left_cnt << PAGE_WIDTH)) - 1888 (page + (count << PAGE_WIDTH))) >> PAGE_WIDTH; 1882 1889 leaf->value[leaf->keys - 1] -= count + new_cnt; 1883 1890 btree_insert(&area->used_space, page + 1884 P2SZ(count), (void *) new_cnt, leaf);1891 (count << PAGE_WIDTH), (void *) new_cnt, leaf); 1885 1892 goto success; 1886 1893 } … … 1904 1911 * to (i - 1) and i. 1905 1912 */ 1906 if (overlaps(left_pg, P2SZ(left_cnt), page,1907 P2SZ(count))) {1908 if (page + P2SZ(count) ==1909 left_pg + P2SZ(left_cnt)) {1913 if (overlaps(left_pg, left_cnt << PAGE_WIDTH, page, 1914 count << PAGE_WIDTH)) { 1915 if (page + (count << PAGE_WIDTH) == 1916 left_pg + (left_cnt << PAGE_WIDTH)) { 1910 1917 /* 1911 1918 * The interval is contained in the … … 1916 1923 leaf->value[i - 1] -= count; 1917 1924 goto success; 1918 } else if (page + P2SZ(count) < 1919 left_pg + P2SZ(left_cnt)) { 1920 size_t new_cnt; 1921 1925 } else if (page + (count << PAGE_WIDTH) < 1926 left_pg + (left_cnt << PAGE_WIDTH)) { 1922 1927 /* 1923 1928 * The interval is contained in the … … 1927 1932 * also inserting a new interval. 1928 1933 */ 1929 new_cnt = ((left_pg + P2SZ(left_cnt)) - 1930 (page + P2SZ(count))) >> 1934 size_t new_cnt = ((left_pg + 1935 (left_cnt << PAGE_WIDTH)) - 1936 (page + (count << PAGE_WIDTH))) >> 1931 1937 PAGE_WIDTH; 1932 1938 leaf->value[i - 1] -= count + new_cnt; 1933 1939 btree_insert(&area->used_space, page + 1934 P2SZ(count), (void *) new_cnt,1940 (count << PAGE_WIDTH), (void *) new_cnt, 1935 1941 leaf); 1936 1942 goto success; … … 2019 2025 2020 2026 /* Eventually check the addresses behind each area */ 2021 li st_foreach(AS->as_area_btree.leaf_list, cur) {2022 if (ret != 0)2023 break;2024 2027 link_t *cur; 2028 for (cur = AS->as_area_btree.leaf_head.next; 2029 (ret == 0) && (cur != &AS->as_area_btree.leaf_head); 2030 cur = cur->next) { 2025 2031 btree_node_t *node = 2026 2032 list_get_instance(cur, btree_node_t, leaf_link); … … 2028 2034 btree_key_t i; 2029 2035 for (i = 0; (ret == 0) && (i < node->keys); i++) { 2030 uintptr_t addr;2031 2032 2036 as_area_t *area = (as_area_t *) node->value[i]; 2033 2037 2034 2038 mutex_lock(&area->lock); 2035 2039 2036 addr = ALIGN_UP(area->base + P2SZ(area->pages), 2040 uintptr_t addr = 2041 ALIGN_UP(area->base + (area->pages << PAGE_WIDTH), 2037 2042 PAGE_SIZE); 2038 2043 … … 2064 2069 2065 2070 size_t area_cnt = 0; 2066 2067 list_foreach(as->as_area_btree.leaf_list, cur) { 2071 link_t *cur; 2072 2073 for (cur = as->as_area_btree.leaf_head.next; 2074 cur != &as->as_area_btree.leaf_head; cur = cur->next) { 2068 2075 btree_node_t *node = 2069 2076 list_get_instance(cur, btree_node_t, leaf_link); … … 2078 2085 size_t area_idx = 0; 2079 2086 2080 list_foreach(as->as_area_btree.leaf_list, cur) { 2087 for (cur = as->as_area_btree.leaf_head.next; 2088 cur != &as->as_area_btree.leaf_head; cur = cur->next) { 2081 2089 btree_node_t *node = 2082 2090 list_get_instance(cur, btree_node_t, leaf_link); … … 2090 2098 2091 2099 info[area_idx].start_addr = area->base; 2092 info[area_idx].size = P2SZ(area->pages);2100 info[area_idx].size = FRAMES2SIZE(area->pages); 2093 2101 info[area_idx].flags = area->flags; 2094 2102 ++area_idx; … … 2114 2122 2115 2123 /* Print out info about address space areas */ 2116 list_foreach(as->as_area_btree.leaf_list, cur) { 2124 link_t *cur; 2125 for (cur = as->as_area_btree.leaf_head.next; 2126 cur != &as->as_area_btree.leaf_head; cur = cur->next) { 2117 2127 btree_node_t *node 2118 2128 = list_get_instance(cur, btree_node_t, leaf_link); … … 2126 2136 " (%p - %p)\n", area, (void *) area->base, 2127 2137 area->pages, (void *) area->base, 2128 (void *) (area->base + P2SZ(area->pages)));2138 (void *) (area->base + FRAMES2SIZE(area->pages))); 2129 2139 mutex_unlock(&area->lock); 2130 2140 }
Note:
See TracChangeset
for help on using the changeset viewer.