Subversion Repositories HelenOS-historic

Rev

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

Rev 824 Rev 852
Line 134... Line 134...
134
    ipl = interrupts_disable();
134
    ipl = interrupts_disable();
135
    spinlock_lock(&zones.lock);
135
    spinlock_lock(&zones.lock);
136
    /* Try to merge */
136
    /* Try to merge */
137
    if (zones.count+1 == ZONES_MAX)
137
    if (zones.count+1 == ZONES_MAX)
138
        panic("Maximum zone(%d) count exceeded.", ZONES_MAX);
138
        panic("Maximum zone(%d) count exceeded.", ZONES_MAX);
139
 
-
 
140
    for (i=0; i < zones.count; i++) {
139
    for (i=0; i < zones.count; i++) {
141
        /* Check for overflow */
140
        /* Check for overflow */
142
        z = zones.info[zones.count];
141
        z = zones.info[i];
143
        if (overlaps(newzone->base,newzone->count,
142
        if (overlaps(newzone->base,newzone->count,
144
                 z->base, z->count)) {
143
                 z->base, z->count)) {
145
            printf("Zones overlap!\n");
144
            printf("Zones overlap!\n");
146
            return -1;
145
            return -1;
147
        }
146
        }
148
        if (z->base < newzone->base)
147
        if (newzone->base < z->base)
149
            break;
148
            break;
150
    }
149
    }
151
    /* Move other zones up */
150
    /* Move other zones up */
152
    for (j=i;j < zones.count;j++)
151
    for (j=i;j < zones.count;j++)
153
        zones.info[j+1] = zones.info[j];
152
        zones.info[j+1] = zones.info[j];
154
 
-
 
155
    zones.info[i] = newzone;
153
    zones.info[i] = newzone;
156
    zones.count++;
154
    zones.count++;
157
 
-
 
158
    spinlock_unlock(&zones.lock);
155
    spinlock_unlock(&zones.lock);
159
    interrupts_restore(ipl);
156
    interrupts_restore(ipl);
160
 
157
 
161
    return i;
158
    return i;
162
}
159
}
Line 765... Line 762...
765
    /* Check sizes */
762
    /* Check sizes */
766
    z->frames = (frame_t *)((void *)z->buddy_system+buddy_conf_size(max_order));
763
    z->frames = (frame_t *)((void *)z->buddy_system+buddy_conf_size(max_order));
767
    for (i = 0; i<count; i++) {
764
    for (i = 0; i<count; i++) {
768
        frame_initialize(&z->frames[i]);
765
        frame_initialize(&z->frames[i]);
769
    }
766
    }
770
 
767
   
771
    /* Stuffing frames */
768
    /* Stuffing frames */
772
    for (i = 0; i < count; i++) {
769
    for (i = 0; i < count; i++) {
773
        z->frames[i].refcount = 0;
770
        z->frames[i].refcount = 0;
774
        buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);
771
        buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);
775
    }
772
    }
Line 841... Line 838...
841
    /* If confdata in zone, mark as unavailable */
838
    /* If confdata in zone, mark as unavailable */
842
    if (confframe >= start && confframe < start+count)
839
    if (confframe >= start && confframe < start+count)
843
        for (i=confframe; i<confframe+confcount; i++) {
840
        for (i=confframe; i<confframe+confcount; i++) {
844
            zone_mark_unavailable(z, i - z->base);
841
            zone_mark_unavailable(z, i - z->base);
845
        }
842
        }
846
 
-
 
847
    return znum;
843
    return znum;
848
}
844
}
849
 
845
 
850
/***************************************/
846
/***************************************/
851
/* Frame functions */
847
/* Frame functions */
Line 969... Line 965...
969
void frame_mark_unavailable(pfn_t start, count_t count)
965
void frame_mark_unavailable(pfn_t start, count_t count)
970
{
966
{
971
    int i;
967
    int i;
972
    zone_t *zone;
968
    zone_t *zone;
973
    int prefzone = 0;
969
    int prefzone = 0;
974
 
970
   
975
    for (i=0; i < count; i++) {
971
    for (i=0; i < count; i++) {
976
        zone = find_zone_and_lock(start+i,&prefzone);
972
        zone = find_zone_and_lock(start+i,&prefzone);
977
        if (!zone) /* PFN not found */
973
        if (!zone) /* PFN not found */
978
            continue;
974
            continue;
979
        zone_mark_unavailable(zone, start+i-zone->base);
975
        zone_mark_unavailable(zone, start+i-zone->base);
Line 993... Line 989...
993
        spinlock_initialize(&zones.lock,"zones_glob_lock");
989
        spinlock_initialize(&zones.lock,"zones_glob_lock");
994
    }
990
    }
995
    /* Tell the architecture to create some memory */
991
    /* Tell the architecture to create some memory */
996
    frame_arch_init();
992
    frame_arch_init();
997
    if (config.cpu_active == 1) {
993
    if (config.cpu_active == 1) {
998
        frame_mark_unavailable(ADDR2PFN(KA2PA(config.base)),
994
        pfn_t firstframe = ADDR2PFN(KA2PA(config.base));
999
                       SIZE2FRAMES(config.kernel_size));
995
        pfn_t lastframe = ADDR2PFN(KA2PA(config.base+config.kernel_size));
-
 
996
        frame_mark_unavailable(firstframe,lastframe-firstframe+1);
1000
        if (config.init_size > 0)
997
        if (config.init_size > 0)
1001
            frame_mark_unavailable(ADDR2PFN(KA2PA(config.init_addr)),
998
            frame_mark_unavailable(ADDR2PFN(KA2PA(config.init_addr)),
1002
                           SIZE2FRAMES(config.init_size));
999
                           SIZE2FRAMES(config.init_size));
1003
    }
1000
    }
1004
}
1001
}