Subversion Repositories HelenOS

Rev

Rev 2647 | Rev 3057 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2647 Rev 2745
Line 429... Line 429...
429
                btree_node_t, leaf_link);
429
                btree_node_t, leaf_link);
430
            if ((cond = (bool) node->keys)) {
430
            if ((cond = (bool) node->keys)) {
431
                uintptr_t b = node->key[node->keys - 1];
431
                uintptr_t b = node->key[node->keys - 1];
432
                count_t c =
432
                count_t c =
433
                    (count_t) node->value[node->keys - 1];
433
                    (count_t) node->value[node->keys - 1];
434
                int i = 0;
434
                unsigned int i = 0;
435
           
435
           
436
                if (overlaps(b, c * PAGE_SIZE, area->base,
436
                if (overlaps(b, c * PAGE_SIZE, area->base,
437
                    pages * PAGE_SIZE)) {
437
                    pages * PAGE_SIZE)) {
438
                   
438
                   
439
                    if (b + c * PAGE_SIZE <= start_free) {
439
                    if (b + c * PAGE_SIZE <= start_free) {
Line 559... Line 559...
559
     * Visit only the pages mapped by used_space B+tree.
559
     * Visit only the pages mapped by used_space B+tree.
560
     */
560
     */
561
    for (cur = area->used_space.leaf_head.next;
561
    for (cur = area->used_space.leaf_head.next;
562
        cur != &area->used_space.leaf_head; cur = cur->next) {
562
        cur != &area->used_space.leaf_head; cur = cur->next) {
563
        btree_node_t *node;
563
        btree_node_t *node;
564
        int i;
564
        unsigned int i;
565
       
565
       
566
        node = list_get_instance(cur, btree_node_t, leaf_link);
566
        node = list_get_instance(cur, btree_node_t, leaf_link);
567
        for (i = 0; i < node->keys; i++) {
567
        for (i = 0; i < node->keys; i++) {
568
            uintptr_t b = node->key[i];
568
            uintptr_t b = node->key[i];
569
            count_t j;
569
            count_t j;
Line 1095... Line 1095...
1095
 */
1095
 */
1096
as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
1096
as_area_t *find_area_and_lock(as_t *as, uintptr_t va)
1097
{
1097
{
1098
    as_area_t *a;
1098
    as_area_t *a;
1099
    btree_node_t *leaf, *lnode;
1099
    btree_node_t *leaf, *lnode;
1100
    int i;
1100
    unsigned int i;
1101
   
1101
   
1102
    a = (as_area_t *) btree_search(&as->as_area_btree, va, &leaf);
1102
    a = (as_area_t *) btree_search(&as->as_area_btree, va, &leaf);
1103
    if (a) {
1103
    if (a) {
1104
        /* va is the base address of an address space area */
1104
        /* va is the base address of an address space area */
1105
        mutex_lock(&a->lock);
1105
        mutex_lock(&a->lock);
Line 1153... Line 1153...
1153
bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
1153
bool check_area_conflicts(as_t *as, uintptr_t va, size_t size,
1154
              as_area_t *avoid_area)
1154
              as_area_t *avoid_area)
1155
{
1155
{
1156
    as_area_t *a;
1156
    as_area_t *a;
1157
    btree_node_t *leaf, *node;
1157
    btree_node_t *leaf, *node;
1158
    int i;
1158
    unsigned int i;
1159
   
1159
   
1160
    /*
1160
    /*
1161
     * We don't want any area to have conflicts with NULL page.
1161
     * We don't want any area to have conflicts with NULL page.
1162
     */
1162
     */
1163
    if (overlaps(va, size, NULL, PAGE_SIZE))
1163
    if (overlaps(va, size, NULL, PAGE_SIZE))
Line 1262... Line 1262...
1262
 */
1262
 */
1263
int used_space_insert(as_area_t *a, uintptr_t page, count_t count)
1263
int used_space_insert(as_area_t *a, uintptr_t page, count_t count)
1264
{
1264
{
1265
    btree_node_t *leaf, *node;
1265
    btree_node_t *leaf, *node;
1266
    count_t pages;
1266
    count_t pages;
1267
    int i;
1267
    unsigned int i;
1268
 
1268
 
1269
    ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
1269
    ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
1270
    ASSERT(count);
1270
    ASSERT(count);
1271
 
1271
 
1272
    pages = (count_t) btree_search(&a->used_space, page, &leaf);
1272
    pages = (count_t) btree_search(&a->used_space, page, &leaf);
Line 1544... Line 1544...
1544
 */
1544
 */
1545
int used_space_remove(as_area_t *a, uintptr_t page, count_t count)
1545
int used_space_remove(as_area_t *a, uintptr_t page, count_t count)
1546
{
1546
{
1547
    btree_node_t *leaf, *node;
1547
    btree_node_t *leaf, *node;
1548
    count_t pages;
1548
    count_t pages;
1549
    int i;
1549
    unsigned int i;
1550
 
1550
 
1551
    ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
1551
    ASSERT(page == ALIGN_DOWN(page, PAGE_SIZE));
1552
    ASSERT(count);
1552
    ASSERT(count);
1553
 
1553
 
1554
    pages = (count_t) btree_search(&a->used_space, page, &leaf);
1554
    pages = (count_t) btree_search(&a->used_space, page, &leaf);
Line 1732... Line 1732...
1732
         * reference from all frames found there.
1732
         * reference from all frames found there.
1733
         */
1733
         */
1734
        for (cur = sh_info->pagemap.leaf_head.next;
1734
        for (cur = sh_info->pagemap.leaf_head.next;
1735
            cur != &sh_info->pagemap.leaf_head; cur = cur->next) {
1735
            cur != &sh_info->pagemap.leaf_head; cur = cur->next) {
1736
            btree_node_t *node;
1736
            btree_node_t *node;
1737
            int i;
1737
            unsigned int i;
1738
           
1738
           
1739
            node = list_get_instance(cur, btree_node_t, leaf_link);
1739
            node = list_get_instance(cur, btree_node_t, leaf_link);
1740
            for (i = 0; i < node->keys; i++)
1740
            for (i = 0; i < node->keys; i++)
1741
                frame_free((uintptr_t) node->value[i]);
1741
                frame_free((uintptr_t) node->value[i]);
1742
        }
1742
        }
Line 1793... Line 1793...
1793
        cur != &as->as_area_btree.leaf_head; cur = cur->next) {
1793
        cur != &as->as_area_btree.leaf_head; cur = cur->next) {
1794
        btree_node_t *node;
1794
        btree_node_t *node;
1795
       
1795
       
1796
        node = list_get_instance(cur, btree_node_t, leaf_link);
1796
        node = list_get_instance(cur, btree_node_t, leaf_link);
1797
       
1797
       
1798
        int i;
1798
        unsigned int i;
1799
        for (i = 0; i < node->keys; i++) {
1799
        for (i = 0; i < node->keys; i++) {
1800
            as_area_t *area = node->value[i];
1800
            as_area_t *area = node->value[i];
1801
       
1801
       
1802
            mutex_lock(&area->lock);
1802
            mutex_lock(&area->lock);
1803
            printf("as_area: %p, base=%p, pages=%d (%p - %p)\n",
1803
            printf("as_area: %p, base=%p, pages=%d (%p - %p)\n",