Subversion Repositories HelenOS

Rev

Rev 2131 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2131 Rev 2292
Line 68... Line 68...
68
#include <config.h>
68
#include <config.h>
69
 
69
 
70
typedef struct {
70
typedef struct {
71
    count_t refcount;   /**< tracking of shared frames  */
71
    count_t refcount;   /**< tracking of shared frames  */
72
    uint8_t buddy_order;    /**< buddy system block order */
72
    uint8_t buddy_order;    /**< buddy system block order */
73
    link_t buddy_link;  /**< link to the next free block inside one order */
73
    link_t buddy_link;  /**< link to the next free block inside one
-
 
74
                     order */
74
    void *parent;           /**< If allocated by slab, this points there */
75
    void *parent;           /**< If allocated by slab, this points there */
75
} frame_t;
76
} frame_t;
76
 
77
 
77
typedef struct {
78
typedef struct {
78
    SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
79
    SPINLOCK_DECLARE(lock); /**< this lock protects everything below */
79
    pfn_t base;     /**< frame_no of the first frame in the frames array */
80
    pfn_t base;     /**< frame_no of the first frame in the frames
-
 
81
                     array */
80
    count_t count;          /**< Size of zone */
82
    count_t count;          /**< Size of zone */
81
 
83
 
82
    frame_t *frames;    /**< array of frame_t structures in this zone */
84
    frame_t *frames;    /**< array of frame_t structures in this
-
 
85
                     zone */
83
    count_t free_count; /**< number of free frame_t structures */
86
    count_t free_count; /**< number of free frame_t structures */
84
    count_t busy_count; /**< number of busy frame_t structures */
87
    count_t busy_count; /**< number of busy frame_t structures */
85
   
88
   
86
    buddy_system_t *buddy_system; /**< buddy system for the zone */
89
    buddy_system_t *buddy_system; /**< buddy system for the zone */
87
    int flags;
90
    int flags;
Line 155... Line 158...
155
    if (zones.count + 1 == ZONES_MAX)
158
    if (zones.count + 1 == ZONES_MAX)
156
        panic("Maximum zone(%d) count exceeded.", ZONES_MAX);
159
        panic("Maximum zone(%d) count exceeded.", ZONES_MAX);
157
    for (i = 0; i < zones.count; i++) {
160
    for (i = 0; i < zones.count; i++) {
158
        /* Check for overflow */
161
        /* Check for overflow */
159
        z = zones.info[i];
162
        z = zones.info[i];
160
        if (overlaps(newzone->base,newzone->count,
163
        if (overlaps(newzone->base,newzone->count, z->base,
161
                 z->base, z->count)) {
164
            z->count)) {
162
            printf("Zones overlap!\n");
165
            printf("Zones overlap!\n");
163
            return -1;
166
            return -1;
164
        }
167
        }
165
        if (newzone->base < z->base)
168
        if (newzone->base < z->base)
166
            break;
169
            break;
167
    }
170
    }
168
    /* Move other zones up */
171
    /* Move other zones up */
169
    for (j = i;j < zones.count; j++)
172
    for (j = i; j < zones.count; j++)
170
        zones.info[j + 1] = zones.info[j];
173
        zones.info[j + 1] = zones.info[j];
171
    zones.info[i] = newzone;
174
    zones.info[i] = newzone;
172
    zones.count++;
175
    zones.count++;
173
    spinlock_unlock(&zones.lock);
176
    spinlock_unlock(&zones.lock);
174
    interrupts_restore(ipl);
177
    interrupts_restore(ipl);
Line 200... Line 203...
200
    i = hint;
203
    i = hint;
201
    do {
204
    do {
202
        z = zones.info[i];
205
        z = zones.info[i];
203
        spinlock_lock(&z->lock);
206
        spinlock_lock(&z->lock);
204
        if (z->base <= frame && z->base + z->count > frame) {
207
        if (z->base <= frame && z->base + z->count > frame) {
-
 
208
            /* Unlock the global lock */
205
            spinlock_unlock(&zones.lock); /* Unlock the global lock */
209
            spinlock_unlock(&zones.lock);
206
            if (pzone)
210
            if (pzone)
207
                *pzone = i;
211
                *pzone = i;
208
            return z;
212
            return z;
209
        }
213
        }
210
        spinlock_unlock(&z->lock);
214
        spinlock_unlock(&z->lock);
Line 227... Line 231...
227
/** Find and lock zone that can allocate order frames.
231
/** Find and lock zone that can allocate order frames.
228
 *
232
 *
229
 * Assume interrupts are disabled.
233
 * Assume interrupts are disabled.
230
 *
234
 *
231
 * @param order Size (2^order) of free space we are trying to find
235
 * @param order Size (2^order) of free space we are trying to find
232
 * @param pzone Pointer to preferred zone or NULL, on return contains zone number
236
 * @param pzone Pointer to preferred zone or NULL, on return contains zone
-
 
237
 *      number
233
 */
238
 */
234
static zone_t * find_free_zone_and_lock(uint8_t order, unsigned int *pzone)
239
static zone_t * find_free_zone_and_lock(uint8_t order, unsigned int *pzone)
235
{
240
{
236
    unsigned int i;
241
    unsigned int i;
237
    zone_t *z;
242
    zone_t *z;
Line 271... Line 276...
271
 * That means go to lower addresses, until such block is found
276
 * That means go to lower addresses, until such block is found
272
 *
277
 *
273
 * @param order - Order of parent must be different then this parameter!!
278
 * @param order - Order of parent must be different then this parameter!!
274
 */
279
 */
275
static link_t *zone_buddy_find_block(buddy_system_t *b, link_t *child,
280
static link_t *zone_buddy_find_block(buddy_system_t *b, link_t *child,
276
                     uint8_t order)
281
    uint8_t order)
277
{
282
{
278
    frame_t * frame;
283
    frame_t *frame;
279
    zone_t * zone;
284
    zone_t *zone;
280
    index_t index;
285
    index_t index;
281
   
286
   
282
    frame = list_get_instance(child, frame_t, buddy_link);
287
    frame = list_get_instance(child, frame_t, buddy_link);
283
    zone = (zone_t *) b->data;
288
    zone = (zone_t *) b->data;
284
 
289
 
Line 291... Line 296...
291
    return NULL;
296
    return NULL;
292
}
297
}
293
 
298
 
294
static void zone_buddy_print_id(buddy_system_t *b, link_t *block)
299
static void zone_buddy_print_id(buddy_system_t *b, link_t *block)
295
{
300
{
296
    frame_t * frame;
301
    frame_t *frame;
297
    zone_t * zone;
302
    zone_t *zone;
298
    index_t index;
303
    index_t index;
299
 
304
 
300
    frame = list_get_instance(block, frame_t, buddy_link);
305
    frame = list_get_instance(block, frame_t, buddy_link);
301
    zone = (zone_t *) b->data;
306
    zone = (zone_t *) b->data;
302
    index = frame_index(zone, frame);
307
    index = frame_index(zone, frame);
Line 308... Line 313...
308
 * @param b Buddy system.
313
 * @param b Buddy system.
309
 * @param block Block for which buddy should be found
314
 * @param block Block for which buddy should be found
310
 *
315
 *
311
 * @return Buddy for given block if found
316
 * @return Buddy for given block if found
312
 */
317
 */
313
static link_t * zone_buddy_find_buddy(buddy_system_t *b, link_t * block)
318
static link_t *zone_buddy_find_buddy(buddy_system_t *b, link_t *block)
314
{
319
{
315
    frame_t * frame;
320
    frame_t *frame;
316
    zone_t * zone;
321
    zone_t *zone;
317
    index_t index;
322
    index_t index;
318
    bool is_left, is_right;
323
    bool is_left, is_right;
319
 
324
 
320
    frame = list_get_instance(block, frame_t, buddy_link);
325
    frame = list_get_instance(block, frame_t, buddy_link);
321
    zone = (zone_t *) b->data;
326
    zone = (zone_t *) b->data;
322
    ASSERT(IS_BUDDY_ORDER_OK(frame_index_abs(zone, frame), frame->buddy_order));
327
    ASSERT(IS_BUDDY_ORDER_OK(frame_index_abs(zone, frame),
-
 
328
        frame->buddy_order));
323
   
329
   
324
    is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame);
330
    is_left = IS_BUDDY_LEFT_BLOCK_ABS(zone, frame);
325
    is_right = IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame);
331
    is_right = IS_BUDDY_RIGHT_BLOCK_ABS(zone, frame);
326
 
332
 
327
    ASSERT(is_left ^ is_right);
333
    ASSERT(is_left ^ is_right);
Line 346... Line 352...
346
 * @param b Buddy system.
352
 * @param b Buddy system.
347
 * @param block Block to bisect
353
 * @param block Block to bisect
348
 *
354
 *
349
 * @return right block
355
 * @return right block
350
 */
356
 */
351
static link_t * zone_buddy_bisect(buddy_system_t *b, link_t * block) {
357
static link_t * zone_buddy_bisect(buddy_system_t *b, link_t *block) {
352
    frame_t * frame_l, * frame_r;
358
    frame_t *frame_l, *frame_r;
353
 
359
 
354
    frame_l = list_get_instance(block, frame_t, buddy_link);
360
    frame_l = list_get_instance(block, frame_t, buddy_link);
355
    frame_r = (frame_l + (1 << (frame_l->buddy_order - 1)));
361
    frame_r = (frame_l + (1 << (frame_l->buddy_order - 1)));
356
   
362
   
357
    return &frame_r->buddy_link;
363
    return &frame_r->buddy_link;
Line 363... Line 369...
363
 * @param block_1 First block
369
 * @param block_1 First block
364
 * @param block_2 First block's buddy
370
 * @param block_2 First block's buddy
365
 *
371
 *
366
 * @return Coalesced block (actually block that represents lower address)
372
 * @return Coalesced block (actually block that represents lower address)
367
 */
373
 */
368
static link_t * zone_buddy_coalesce(buddy_system_t *b, link_t * block_1,
374
static link_t *zone_buddy_coalesce(buddy_system_t *b, link_t *block_1,
369
                    link_t * block_2)
375
    link_t *block_2)
370
{
376
{
371
    frame_t *frame1, *frame2;
377
    frame_t *frame1, *frame2;
372
   
378
   
373
    frame1 = list_get_instance(block_1, frame_t, buddy_link);
379
    frame1 = list_get_instance(block_1, frame_t, buddy_link);
374
    frame2 = list_get_instance(block_2, frame_t, buddy_link);
380
    frame2 = list_get_instance(block_2, frame_t, buddy_link);
Line 380... Line 386...
380
 *
386
 *
381
 * @param b Buddy system.
387
 * @param b Buddy system.
382
 * @param block Buddy system block
388
 * @param block Buddy system block
383
 * @param order Order to set
389
 * @param order Order to set
384
 */
390
 */
385
static void zone_buddy_set_order(buddy_system_t *b, link_t * block, uint8_t order) {
391
static void zone_buddy_set_order(buddy_system_t *b, link_t *block,
-
 
392
    uint8_t order) {
386
    frame_t * frame;
393
    frame_t *frame;
387
    frame = list_get_instance(block, frame_t, buddy_link);
394
    frame = list_get_instance(block, frame_t, buddy_link);
388
    frame->buddy_order = order;
395
    frame->buddy_order = order;
389
}
396
}
390
 
397
 
391
/** Buddy system get_order implementation
398
/** Buddy system get_order implementation
Line 393... Line 400...
393
 * @param b Buddy system.
400
 * @param b Buddy system.
394
 * @param block Buddy system block
401
 * @param block Buddy system block
395
 *
402
 *
396
 * @return Order of block
403
 * @return Order of block
397
 */
404
 */
398
static uint8_t zone_buddy_get_order(buddy_system_t *b, link_t * block) {
405
static uint8_t zone_buddy_get_order(buddy_system_t *b, link_t *block) {
399
    frame_t * frame;
406
    frame_t *frame;
400
    frame = list_get_instance(block, frame_t, buddy_link);
407
    frame = list_get_instance(block, frame_t, buddy_link);
401
    return frame->buddy_order;
408
    return frame->buddy_order;
402
}
409
}
403
 
410
 
404
/** Buddy system mark_busy implementation
411
/** Buddy system mark_busy implementation
Line 418... Line 425...
418
 *
425
 *
419
 * @param b Buddy system
426
 * @param b Buddy system
420
 * @param block Buddy system block
427
 * @param block Buddy system block
421
 *
428
 *
422
 */
429
 */
423
static void zone_buddy_mark_available(buddy_system_t *b, link_t * block) {
430
static void zone_buddy_mark_available(buddy_system_t *b, link_t *block) {
424
    frame_t * frame;
431
    frame_t *frame;
425
    frame = list_get_instance(block, frame_t, buddy_link);
432
    frame = list_get_instance(block, frame_t, buddy_link);
426
    frame->refcount = 0;
433
    frame->refcount = 0;
427
}
434
}
428
 
435
 
429
static buddy_system_operations_t zone_buddy_system_operations = {
436
static buddy_system_operations_t zone_buddy_system_operations = {
Line 518... Line 525...
518
    link_t *link;
525
    link_t *link;
519
 
526
 
520
    frame = zone_get_frame(zone, frame_idx);
527
    frame = zone_get_frame(zone, frame_idx);
521
    if (frame->refcount)
528
    if (frame->refcount)
522
        return;
529
        return;
523
    link = buddy_system_alloc_block(zone->buddy_system,
530
    link = buddy_system_alloc_block(zone->buddy_system,
524
                    &frame->buddy_link);
531
        &frame->buddy_link);
525
    ASSERT(link);
532
    ASSERT(link);
526
    zone->free_count--;
533
    zone->free_count--;
527
}
534
}
528
 
535
 
529
/**
536
/**
Line 543... Line 550...
543
    unsigned int i;
550
    unsigned int i;
544
    int z2idx;
551
    int z2idx;
545
    pfn_t frame_idx;
552
    pfn_t frame_idx;
546
    frame_t *frame;
553
    frame_t *frame;
547
 
554
 
548
    ASSERT(!overlaps(z1->base,z1->count,z2->base,z2->count));
555
    ASSERT(!overlaps(z1->base, z1->count, z2->base, z2->count));
549
    ASSERT(z1->base < z2->base);
556
    ASSERT(z1->base < z2->base);
550
 
557
 
551
    spinlock_initialize(&z->lock, "zone_lock");
558
    spinlock_initialize(&z->lock, "zone_lock");
552
    z->base = z1->base;
559
    z->base = z1->base;
553
    z->count = z2->base+z2->count - z1->base;
560
    z->count = z2->base + z2->count - z1->base;
554
    z->flags = z1->flags & z2->flags;
561
    z->flags = z1->flags & z2->flags;
555
 
562
 
556
    z->free_count = z1->free_count + z2->free_count;
563
    z->free_count = z1->free_count + z2->free_count;
557
    z->busy_count = z1->busy_count + z2->busy_count;
564
    z->busy_count = z1->busy_count + z2->busy_count;
558
   
565
   
559
    max_order = fnzb(z->count);
566
    max_order = fnzb(z->count);
560
 
567
 
561
    z->buddy_system = (buddy_system_t *)&z[1];
568
    z->buddy_system = (buddy_system_t *) &z[1];
562
    buddy_system_create(z->buddy_system, max_order,
569
    buddy_system_create(z->buddy_system, max_order,
563
                &zone_buddy_system_operations,
570
        &zone_buddy_system_operations, (void *) z);
564
                (void *) z);
-
 
565
 
571
 
566
    z->frames = (frame_t *)((uint8_t *) z->buddy_system + buddy_conf_size(max_order));
572
    z->frames = (frame_t *)((uint8_t *) z->buddy_system +
-
 
573
        buddy_conf_size(max_order));
567
    for (i = 0; i < z->count; i++) {
574
    for (i = 0; i < z->count; i++) {
568
        /* This marks all frames busy */
575
        /* This marks all frames busy */
569
        frame_initialize(&z->frames[i]);
576
        frame_initialize(&z->frames[i]);
570
    }
577
    }
571
    /* Copy frames from both zones to preserve full frame orders,
578
    /* Copy frames from both zones to preserve full frame orders,
Line 601... Line 608...
601
        frame->refcount = 0;
608
        frame->refcount = 0;
602
        buddy_system_free(z->buddy_system, &frame->buddy_link);
609
        buddy_system_free(z->buddy_system, &frame->buddy_link);
603
    }
610
    }
604
    while (zone_can_alloc(z2, 0)) {
611
    while (zone_can_alloc(z2, 0)) {
605
        frame_idx = zone_frame_alloc(z2, 0);
612
        frame_idx = zone_frame_alloc(z2, 0);
606
        frame = &z->frames[frame_idx + (z2->base-z1->base)];
613
        frame = &z->frames[frame_idx + (z2->base - z1->base)];
607
        frame->refcount = 0;
614
        frame->refcount = 0;
608
        buddy_system_free(z->buddy_system, &frame->buddy_link);
615
        buddy_system_free(z->buddy_system, &frame->buddy_link);
609
    }
616
    }
610
}
617
}
611
 
618
 
Line 666... Line 673...
666
 
673
 
667
    /* Reduce all blocks to order 0 */
674
    /* Reduce all blocks to order 0 */
668
    for (i = 0; i < (count_t) (1 << order); i++) {
675
    for (i = 0; i < (count_t) (1 << order); i++) {
669
        frame = &zone->frames[i + frame_idx];
676
        frame = &zone->frames[i + frame_idx];
670
        frame->buddy_order = 0;
677
        frame->buddy_order = 0;
671
        if (! frame->refcount)
678
        if (!frame->refcount)
672
            frame->refcount = 1;
679
            frame->refcount = 1;
673
        ASSERT(frame->refcount == 1);
680
        ASSERT(frame->refcount == 1);
674
    }
681
    }
675
    /* Free unneeded frames */
682
    /* Free unneeded frames */
676
    for (i = count; i < (count_t) (1 << order); i++) {
683
    for (i = count; i < (count_t) (1 << order); i++) {
Line 708... Line 715...
708
    zone1 = zones.info[z1];
715
    zone1 = zones.info[z1];
709
    zone2 = zones.info[z2];
716
    zone2 = zones.info[z2];
710
    spinlock_lock(&zone1->lock);
717
    spinlock_lock(&zone1->lock);
711
    spinlock_lock(&zone2->lock);
718
    spinlock_lock(&zone2->lock);
712
 
719
 
713
    cframes = SIZE2FRAMES(zone_conf_size(zone2->base+zone2->count-zone1->base));
720
    cframes = SIZE2FRAMES(zone_conf_size(zone2->base + zone2->count -
-
 
721
        zone1->base));
714
    if (cframes == 1)
722
    if (cframes == 1)
715
        order = 0;
723
        order = 0;
716
    else
724
    else
717
        order = fnzb(cframes - 1) + 1;
725
        order = fnzb(cframes - 1) + 1;
718
 
726
 
Line 801... Line 809...
801
                &zone_buddy_system_operations,
809
                &zone_buddy_system_operations,
802
                (void *) z);
810
                (void *) z);
803
   
811
   
804
    /* Allocate frames _after_ the conframe */
812
    /* Allocate frames _after_ the conframe */
805
    /* Check sizes */
813
    /* Check sizes */
806
    z->frames = (frame_t *)((uint8_t *) z->buddy_system + buddy_conf_size(max_order));
814
    z->frames = (frame_t *)((uint8_t *) z->buddy_system +
-
 
815
        buddy_conf_size(max_order));
807
    for (i = 0; i < count; i++) {
816
    for (i = 0; i < count; i++) {
808
        frame_initialize(&z->frames[i]);
817
        frame_initialize(&z->frames[i]);
809
    }
818
    }
810
   
819
   
811
    /* Stuffing frames */
820
    /* Stuffing frames */
Line 863... Line 872...
863
     */
872
     */
864
    confcount = SIZE2FRAMES(zone_conf_size(count));
873
    confcount = SIZE2FRAMES(zone_conf_size(count));
865
    if (confframe >= start && confframe < start+count) {
874
    if (confframe >= start && confframe < start+count) {
866
        for (;confframe < start + count; confframe++) {
875
        for (;confframe < start + count; confframe++) {
867
            addr = PFN2ADDR(confframe);
876
            addr = PFN2ADDR(confframe);
-
 
877
            if (overlaps(addr, PFN2ADDR(confcount),
868
            if (overlaps(addr, PFN2ADDR(confcount), KA2PA(config.base), config.kernel_size))
878
                KA2PA(config.base), config.kernel_size))
869
                continue;
879
                continue;
870
           
880
           
-
 
881
            if (overlaps(addr, PFN2ADDR(confcount),
871
            if (overlaps(addr, PFN2ADDR(confcount), KA2PA(config.stack_base), config.stack_size))
882
                KA2PA(config.stack_base), config.stack_size))
872
                continue;
883
                continue;
873
           
884
           
874
            bool overlap = false;
885
            bool overlap = false;
875
            count_t i;
886
            count_t i;
876
            for (i = 0; i < init.cnt; i++)
887
            for (i = 0; i < init.cnt; i++)
877
                if (overlaps(addr, PFN2ADDR(confcount), KA2PA(init.tasks[i].addr), init.tasks[i].size)) {
888
                if (overlaps(addr, PFN2ADDR(confcount),
-
 
889
                    KA2PA(init.tasks[i].addr),
-
 
890
                    init.tasks[i].size)) {
878
                    overlap = true;
891
                    overlap = true;
879
                    break;
892
                    break;
880
                }
893
                }
881
            if (overlap)
894
            if (overlap)
882
                continue;
895
                continue;
Line 913... Line 926...
913
 
926
 
914
    zone_get_frame(zone, pfn-zone->base)->parent = data;
927
    zone_get_frame(zone, pfn-zone->base)->parent = data;
915
    spinlock_unlock(&zone->lock);
928
    spinlock_unlock(&zone->lock);
916
}
929
}
917
 
930
 
918
void * frame_get_parent(pfn_t pfn, unsigned int hint)
931
void *frame_get_parent(pfn_t pfn, unsigned int hint)
919
{
932
{
920
    zone_t *zone = find_zone_and_lock(pfn, &hint);
933
    zone_t *zone = find_zone_and_lock(pfn, &hint);
921
    void *res;
934
    void *res;
922
 
935
 
923
    ASSERT(zone);
936
    ASSERT(zone);
Line 1071... Line 1084...
1071
        spinlock_initialize(&zones.lock, "zones.lock");
1084
        spinlock_initialize(&zones.lock, "zones.lock");
1072
    }
1085
    }
1073
    /* Tell the architecture to create some memory */
1086
    /* Tell the architecture to create some memory */
1074
    frame_arch_init();
1087
    frame_arch_init();
1075
    if (config.cpu_active == 1) {
1088
    if (config.cpu_active == 1) {
1076
        frame_mark_unavailable(ADDR2PFN(KA2PA(config.base)), SIZE2FRAMES(config.kernel_size));
1089
        frame_mark_unavailable(ADDR2PFN(KA2PA(config.base)),
-
 
1090
            SIZE2FRAMES(config.kernel_size));
1077
        frame_mark_unavailable(ADDR2PFN(KA2PA(config.stack_base)), SIZE2FRAMES(config.stack_size));
1091
        frame_mark_unavailable(ADDR2PFN(KA2PA(config.stack_base)),
-
 
1092
            SIZE2FRAMES(config.stack_size));
1078
       
1093
       
1079
        count_t i;
1094
        count_t i;
1080
        for (i = 0; i < init.cnt; i++)
1095
        for (i = 0; i < init.cnt; i++) {
1081
            frame_mark_unavailable(ADDR2PFN(KA2PA(init.tasks[i].addr)), SIZE2FRAMES(init.tasks[i].size));
1096
            pfn_t pfn = ADDR2PFN(KA2PA(init.tasks[i].addr));
-
 
1097
            frame_mark_unavailable(pfn,
-
 
1098
                SIZE2FRAMES(init.tasks[i].size));
-
 
1099
        }
1082
 
1100
 
1083
        if (ballocs.size)
1101
        if (ballocs.size)
1084
            frame_mark_unavailable(ADDR2PFN(KA2PA(ballocs.base)), SIZE2FRAMES(ballocs.size));
1102
            frame_mark_unavailable(ADDR2PFN(KA2PA(ballocs.base)),
-
 
1103
                SIZE2FRAMES(ballocs.size));
1085
 
1104
 
1086
        /* Black list first frame, as allocating NULL would
1105
        /* Black list first frame, as allocating NULL would
1087
         * fail in some places */
1106
         * fail in some places */
1088
        frame_mark_unavailable(0, 1);
1107
        frame_mark_unavailable(0, 1);
1089
    }
1108
    }
Line 1104... Line 1123...
1104
    printf("#  base address free frames  busy frames\n");
1123
    printf("#  base address free frames  busy frames\n");
1105
    printf("-- ------------ ------------ ------------\n");
1124
    printf("-- ------------ ------------ ------------\n");
1106
    for (i = 0; i < zones.count; i++) {
1125
    for (i = 0; i < zones.count; i++) {
1107
        zone = zones.info[i];
1126
        zone = zones.info[i];
1108
        spinlock_lock(&zone->lock);
1127
        spinlock_lock(&zone->lock);
1109
        printf("%-2d %12p %12zd %12zd\n", i, PFN2ADDR(zone->base), zone->free_count, zone->busy_count);
1128
        printf("%-2d %12p %12zd %12zd\n", i, PFN2ADDR(zone->base),
-
 
1129
            zone->free_count, zone->busy_count);
1110
        spinlock_unlock(&zone->lock);
1130
        spinlock_unlock(&zone->lock);
1111
    }
1131
    }
1112
    spinlock_unlock(&zones.lock);
1132
    spinlock_unlock(&zones.lock);
1113
    interrupts_restore(ipl);
1133
    interrupts_restore(ipl);
1114
}
1134
}
Line 1136... Line 1156...
1136
        goto out;
1156
        goto out;
1137
    }
1157
    }
1138
   
1158
   
1139
    spinlock_lock(&zone->lock);
1159
    spinlock_lock(&zone->lock);
1140
    printf("Memory zone information\n");
1160
    printf("Memory zone information\n");
1141
    printf("Zone base address: %#.*p\n", sizeof(uintptr_t) * 2, PFN2ADDR(zone->base));
1161
    printf("Zone base address: %#.*p\n", sizeof(uintptr_t) * 2,
-
 
1162
        PFN2ADDR(zone->base));
1142
    printf("Zone size: %zd frames (%zdK)\n", zone->count, ((zone->count) * FRAME_SIZE) >> 10);
1163
    printf("Zone size: %zd frames (%zdK)\n", zone->count,
-
 
1164
        ((zone->count) * FRAME_SIZE) >> 10);
1143
    printf("Allocated space: %zd frames (%zdK)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
1165
    printf("Allocated space: %zd frames (%zdK)\n", zone->busy_count,
-
 
1166
        (zone->busy_count * FRAME_SIZE) >> 10);
1144
    printf("Available space: %zd frames (%zdK)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
1167
    printf("Available space: %zd frames (%zdK)\n", zone->free_count,
-
 
1168
        (zone->free_count * FRAME_SIZE) >> 10);
1145
    buddy_system_structure_print(zone->buddy_system, FRAME_SIZE);
1169
    buddy_system_structure_print(zone->buddy_system, FRAME_SIZE);
1146
   
1170
   
1147
    spinlock_unlock(&zone->lock);
1171
    spinlock_unlock(&zone->lock);
1148
out:
1172
out:
1149
    spinlock_unlock(&zones.lock);
1173
    spinlock_unlock(&zones.lock);
1150
    interrupts_restore(ipl);
1174
    interrupts_restore(ipl);
1151
}
1175
}
1152
 
1176
 
1153
/** @}
1177
/** @}
1154
 */
1178
 */
-
 
1179