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