Subversion Repositories HelenOS-historic

Rev

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

Rev 1048 Rev 1070
Line 49... Line 49...
49
#include <adt/list.h>
49
#include <adt/list.h>
50
#include <panic.h>
50
#include <panic.h>
51
#include <arch/asm.h>
51
#include <arch/asm.h>
52
#include <debug.h>
52
#include <debug.h>
53
#include <memstr.h>
53
#include <memstr.h>
-
 
54
#include <macros.h>
54
#include <arch.h>
55
#include <arch.h>
55
#include <print.h>
56
#include <print.h>
56
 
57
 
57
as_operations_t *as_operations = NULL;
58
as_operations_t *as_operations = NULL;
58
 
59
 
Line 535... Line 536...
535
bool check_area_conflicts(as_t *as, __address va, size_t size, as_area_t *avoid_area)
536
bool check_area_conflicts(as_t *as, __address va, size_t size, as_area_t *avoid_area)
536
{
537
{
537
    link_t *cur;
538
    link_t *cur;
538
    as_area_t *a;
539
    as_area_t *a;
539
   
540
   
-
 
541
    /*
-
 
542
     * We don't want any area to have conflicts with NULL page.
-
 
543
     */
-
 
544
    if (overlaps(va, size, NULL, PAGE_SIZE))
-
 
545
        return false;
-
 
546
   
540
    for (cur = as->as_area_head.next; cur != &as->as_area_head; cur = cur->next) {
547
    for (cur = as->as_area_head.next; cur != &as->as_area_head; cur = cur->next) {
541
        __address start;
548
        __address a_start;
542
        __address end;
549
        size_t a_size;
543
   
550
   
544
        a = list_get_instance(cur, as_area_t, link);
551
        a = list_get_instance(cur, as_area_t, link);
545
        if (a == avoid_area)
552
        if (a == avoid_area)
546
            continue;
553
            continue;
547
           
554
           
548
        spinlock_lock(&a->lock);
555
        spinlock_lock(&a->lock);
549
 
556
 
550
        start = a->base;
557
        a_start = a->base;
551
        end = a->base + a->pages * PAGE_SIZE - 1;
558
        a_size = a->pages * PAGE_SIZE;
552
 
559
 
553
        spinlock_unlock(&a->lock);
560
        spinlock_unlock(&a->lock);
554
 
561
 
555
        if ((va >= start) && (va <= end)) {
-
 
556
            /*
-
 
557
             * Tested area is inside another area.
-
 
558
             */
-
 
559
            return false;
-
 
560
        }
-
 
561
       
-
 
562
        if ((start >= va) && (start < va + size)) {
562
        if (overlaps(va, size, a_start, a_size))
563
            /*
-
 
564
             * Another area starts in tested area.
-
 
565
             */
-
 
566
            return false;
563
            return false;      
567
        }
-
 
568
       
564
 
569
        if ((end >= va) && (end < va + size)) {
-
 
570
            /*
-
 
571
             * Another area ends in tested area.
-
 
572
             */
-
 
573
            return false;
-
 
574
        }
565
    }
575
 
566
 
-
 
567
    /*
-
 
568
     * So far, the area does not conflict with other areas.
-
 
569
     * Check if it doesn't conflict with kernel address space.
-
 
570
     */  
-
 
571
    if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
-
 
572
        return !overlaps(va, size,
-
 
573
            KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START);
576
    }
574
    }
577
 
575
 
578
    return true;
576
    return true;
579
}
577
}