Subversion Repositories HelenOS-historic

Rev

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

Rev 689 Rev 701
Line 115... Line 115...
115
   
115
   
116
    if (!zone) {
116
    if (!zone) {
117
        if (flags & FRAME_PANIC)
117
        if (flags & FRAME_PANIC)
118
            panic("Can't allocate frame.\n");
118
            panic("Can't allocate frame.\n");
119
       
119
       
120
       
-
 
121
       
-
 
122
        /*
120
        /*
123
         * TODO: Sleep until frames are available again.
121
         * TODO: Sleep until frames are available again.
124
         */
122
         */
125
        spinlock_unlock(&zone_head_lock);
123
        spinlock_unlock(&zone_head_lock);
126
        interrupts_restore(ipl);
124
        interrupts_restore(ipl);
Line 153... Line 151...
153
 
151
 
154
    spinlock_unlock(&zone->lock);
152
    spinlock_unlock(&zone->lock);
155
    spinlock_unlock(&zone_head_lock);
153
    spinlock_unlock(&zone_head_lock);
156
    interrupts_restore(ipl);
154
    interrupts_restore(ipl);
157
 
155
 
158
 
-
 
159
    if (flags & FRAME_KA)
156
    if (flags & FRAME_KA)
160
        v = PA2KA(v);
157
        v = PA2KA(v);
161
   
158
   
162
    if (flags & FRAME_NON_BLOCKING) {
159
    if (flags & FRAME_NON_BLOCKING) {
163
        ASSERT(status != NULL);
160
        ASSERT(status != NULL);
Line 203... Line 200...
203
         */
200
         */
204
        if ((addr >= z->base) && (addr <= z->base + (z->free_count + z->busy_count) * FRAME_SIZE)) {
201
        if ((addr >= z->base) && (addr <= z->base + (z->free_count + z->busy_count) * FRAME_SIZE)) {
205
            zone = z;
202
            zone = z;
206
            break;
203
            break;
207
        }
204
        }
-
 
205
 
208
        spinlock_unlock(&z->lock);
206
        spinlock_unlock(&z->lock);
209
    }
207
    }
210
   
208
   
211
    ASSERT(zone != NULL);
209
    ASSERT(zone != NULL);
212
   
210
   
Line 500... Line 498...
500
 *
498
 *
501
 */
499
 */
502
void zone_print_list(void) {
500
void zone_print_list(void) {
503
    zone_t *zone = NULL;
501
    zone_t *zone = NULL;
504
    link_t *cur;
502
    link_t *cur;
-
 
503
    ipl_t ipl;
-
 
504
 
-
 
505
    ipl = interrupts_disable();
505
    spinlock_lock(&zone_head_lock);
506
    spinlock_lock(&zone_head_lock);
506
    printf("Base address\tFree Frames\tBusy Frames\n");
507
    printf("Base address\tFree Frames\tBusy Frames\n");
507
    printf("------------\t-----------\t-----------\n");
508
    printf("------------\t-----------\t-----------\n");
508
    for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
509
    for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
509
        zone = list_get_instance(cur, zone_t, link);
510
        zone = list_get_instance(cur, zone_t, link);
510
        spinlock_lock(&zone->lock);
511
        spinlock_lock(&zone->lock);
511
        printf("%L\t%d\t\t%d\n",zone->base, zone->free_count, zone->busy_count);
512
        printf("%L\t%d\t\t%d\n",zone->base, zone->free_count, zone->busy_count);
-
 
513
        spinlock_unlock(&zone->lock);
512
    }
514
    }
513
    spinlock_unlock(&zone_head_lock);
515
    spinlock_unlock(&zone_head_lock);
514
 
-
 
-
 
516
    interrupts_restore(ipl);
515
}
517
}
516
 
518
 
517
/** Prints zone details
519
/** Prints zone details
518
 *
520
 *
519
 * @param base Zone base address
521
 * @param base Zone base address
520
 */
522
 */
521
void zone_print_one(__address base) {
523
void zone_print_one(__address base) {
522
    zone_t *zone = NULL, *z ;
524
    zone_t *zone = NULL, *z ;
523
    link_t *cur;
525
    link_t *cur;
524
   
526
    ipl_t ipl;
525
   
527
 
-
 
528
    ipl = interrupts_disable();
526
    spinlock_lock(&zone_head_lock);
529
    spinlock_lock(&zone_head_lock);
527
   
530
   
528
   
-
 
529
    for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
531
    for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
530
        z = list_get_instance(cur, zone_t, link);
532
        z = list_get_instance(cur, zone_t, link);
531
        if (base == z->base) {
533
        if (base == z->base) {
532
            zone = z;
534
            zone = z;
533
            break;
535
            break;
534
        }
536
        }
535
    }
537
    }
536
   
538
   
537
   
-
 
538
    if (!zone) {
539
    if (!zone) {
-
 
540
        spinlock_unlock(&zone_head_lock);
-
 
541
        interrupts_restore(ipl);
539
        printf("No zone with address %X\n", base);
542
        printf("No zone with address %X\n", base);
540
        return;
543
        return;
541
    }
544
    }
542
   
545
   
543
    spinlock_lock(&zone->lock);
546
    spinlock_lock(&zone->lock);
544
    printf("Memory zone information\n\n");
547
    printf("Memory zone information\n\n");
545
    printf("Zone base address: %P\n", zone->base);
548
    printf("Zone base address: %P\n", zone->base);
546
    printf("Zone size: %d frames (%d kbytes)\n", zone->free_count + zone->busy_count, ((zone->free_count + zone->busy_count) * FRAME_SIZE) >> 10);
549
    printf("Zone size: %d frames (%dK)\n", zone->free_count + zone->busy_count, ((zone->free_count + zone->busy_count) * FRAME_SIZE) >> 10);
547
    printf("Allocated space: %d frames (%d kbytes)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
550
    printf("Allocated space: %d frames (%dK)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
548
    printf("Available space: %d (%d kbytes)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
551
    printf("Available space: %d (%dK)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
549
   
552
   
550
    printf("\nBuddy allocator structures:\n\n");
553
    printf("\nBuddy allocator structures:\n\n");
551
    buddy_system_structure_print(zone->buddy_system, FRAME_SIZE);
554
    buddy_system_structure_print(zone->buddy_system, FRAME_SIZE);
552
   
555
   
553
    spinlock_unlock(&zone->lock);
556
    spinlock_unlock(&zone->lock);
554
    spinlock_unlock(&zone_head_lock);
557
    spinlock_unlock(&zone_head_lock);
555
   
-
 
-
 
558
    interrupts_restore(ipl);
556
}
559
}
557
 
560