Subversion Repositories HelenOS-historic

Rev

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

Rev 720 Rev 721
Line 131... Line 131...
131
       
131
       
132
        panic("Sleep not implemented.\n");
132
        panic("Sleep not implemented.\n");
133
        goto loop;
133
        goto loop;
134
    }
134
    }
135
       
135
       
136
 
-
 
137
    /* Allocate frames from zone buddy system */
136
    /* Allocate frames from zone buddy system */
138
    tmp = buddy_system_alloc(zone->buddy_system, order);
137
    tmp = buddy_system_alloc(zone->buddy_system, order);
139
   
138
   
140
    ASSERT(tmp);
139
    ASSERT(tmp);
141
   
140
   
Line 158... Line 157...
158
   
157
   
159
    if (flags & FRAME_NON_BLOCKING) {
158
    if (flags & FRAME_NON_BLOCKING) {
160
        ASSERT(status != NULL);
159
        ASSERT(status != NULL);
161
        *status = FRAME_OK;
160
        *status = FRAME_OK;
162
    }
161
    }
163
   
-
 
-
 
162
    printf("frame_alloc() returns %P\n", v);
164
    return v;
163
    return v;
165
}
164
}
166
 
165
 
167
/** Free a frame.
166
/** Free a frame.
168
 *
167
 *
Line 177... Line 176...
177
    ipl_t ipl;
176
    ipl_t ipl;
178
    link_t *cur;
177
    link_t *cur;
179
    zone_t *z;
178
    zone_t *z;
180
    zone_t *zone = NULL;
179
    zone_t *zone = NULL;
181
    frame_t *frame;
180
    frame_t *frame;
-
 
181
    int order;
-
 
182
   
182
    ASSERT(addr % FRAME_SIZE == 0);
183
    ASSERT(addr % FRAME_SIZE == 0);
183
   
184
   
184
    ipl = interrupts_disable();
185
    ipl = interrupts_disable();
185
    spinlock_lock(&zone_head_lock);
186
    spinlock_lock(&zone_head_lock);
186
   
187
   
Line 207... Line 208...
207
    }
208
    }
208
   
209
   
209
    ASSERT(zone != NULL);
210
    ASSERT(zone != NULL);
210
   
211
   
211
    frame = ADDR2FRAME(zone, addr);
212
    frame = ADDR2FRAME(zone, addr);
-
 
213
   
-
 
214
    /* remember frame order */
-
 
215
    order = frame->buddy_order;
212
 
216
 
213
    ASSERT(frame->refcount);
217
    ASSERT(frame->refcount);
214
 
218
 
215
    if (!--frame->refcount) {
219
    if (!--frame->refcount) {
216
        buddy_system_free(zone->buddy_system, &frame->buddy_link);
220
        buddy_system_free(zone->buddy_system, &frame->buddy_link);
217
    }
221
    }
218
 
222
 
219
    /* Update zone information. */
223
    /* Update zone information. */
220
    zone->free_count += (1 << frame->buddy_order);
224
    zone->free_count += (1 << order);
221
    zone->busy_count -= (1 << frame->buddy_order);
225
    zone->busy_count -= (1 << order);
222
   
226
   
223
    spinlock_unlock(&zone->lock);
227
    spinlock_unlock(&zone->lock);
224
    spinlock_unlock(&zone_head_lock);
228
    spinlock_unlock(&zone_head_lock);
225
    interrupts_restore(ipl);
229
    interrupts_restore(ipl);
226
}
230
}
Line 319... Line 323...
319
    if (z) {
323
    if (z) {
320
        link_initialize(&z->link);
324
        link_initialize(&z->link);
321
        spinlock_initialize(&z->lock, "zone_lock");
325
        spinlock_initialize(&z->lock, "zone_lock");
322
   
326
   
323
        z->base = start;
327
        z->base = start;
-
 
328
        z->base_index = start / FRAME_SIZE;
-
 
329
       
324
        z->flags = flags;
330
        z->flags = flags;
325
 
331
 
326
        z->free_count = cnt;
332
        z->free_count = cnt;
327
        z->busy_count = 0;
333
        z->busy_count = 0;
328
       
334
       
Line 346... Line 352...
346
        /* Stuffing frames */
352
        /* Stuffing frames */
347
        for (i = 0; i<cnt; i++) {
353
        for (i = 0; i<cnt; i++) {
348
            z->frames[i].refcount = 0;
354
            z->frames[i].refcount = 0;
349
            buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);  
355
            buddy_system_free(z->buddy_system, &z->frames[i].buddy_link);  
350
        }
356
        }
-
 
357
       
351
    }
358
    }
352
    return z;
359
    return z;
353
}
360
}
354
 
361
 
355
/** Attach frame zone
362
/** Attach frame zone
Line 398... Line 405...
398
    index_t index;
405
    index_t index;
399
    bool is_left, is_right;
406
    bool is_left, is_right;
400
 
407
 
401
    frame = list_get_instance(block, frame_t, buddy_link);
408
    frame = list_get_instance(block, frame_t, buddy_link);
402
    zone = (zone_t *) b->data;
409
    zone = (zone_t *) b->data;
-
 
410
    ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX_ABS(zone, frame), frame->buddy_order));
403
   
411
   
404
    ASSERT(IS_BUDDY_ORDER_OK(FRAME_INDEX(zone, frame), frame->buddy_order));
-
 
405
   
412
   
406
    is_left = IS_BUDDY_LEFT_BLOCK(zone, frame);
413
    is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame);
407
    is_right = IS_BUDDY_RIGHT_BLOCK(zone, frame);
414
    is_right = IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame);
408
   
415
   
409
    ASSERT(is_left ^ is_right);
416
    ASSERT(is_left ^ is_right);
410
   
417
   
411
    if (is_left) {
418
    if (is_left) {
412
        index = (FRAME_INDEX(zone, frame)) + (1 << frame->buddy_order);
419
        index = (FRAME_INDEX(zone, frame)) + (1 << frame->buddy_order);