Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 682 → Rev 683

/kernel/trunk/generic/include/mm/frame.h
113,6 → 113,6
* Console functions
*/
extern void zone_print_list(void);
extern void zone_print_one(index_t index);
extern void zone_print_one(__address base);
 
#endif
/kernel/trunk/generic/include/mm/buddy.h
55,5 → 55,7
extern link_t *buddy_system_alloc(buddy_system_t *b, __u8 i);
extern bool buddy_system_can_alloc(buddy_system_t *b, __u8 order);
extern void buddy_system_free(buddy_system_t *b, link_t *block);
extern void buddy_system_structure_print(buddy_system_t *b);
 
 
#endif
/kernel/trunk/generic/src/mm/buddy.c
230,3 → 230,35
list_append(block, &b->order[i]);
 
}
 
 
 
/** Prints out structure of buddy system
*
* @param b Pointer to buddy system
* @param es Element size
*/
void buddy_system_structure_print(buddy_system_t *b) {
index_t i;
count_t cnt, elem_count = 0, block_count = 0;
link_t * cur;
 
printf("Order\tStatistics\n");
printf("-----\t--------------------------------------\n");
for (i=0;i < b->max_order; i++) {
cnt = 0;
if (!list_empty(&b->order[i])) {
for (cur = b->order[i].next; cur != &b->order[i]; cur = cur->next) cnt++;
}
printf("#%d:\t%d blocks available (%d elements per block)\n", i, cnt, 1 << i);
block_count += cnt;
elem_count += (1 << i) * cnt;
}
printf("-----\t--------------------------------------\n");
printf("Buddy system contains %d elements (%d blocks)\n" , elem_count, block_count);
 
}
/kernel/trunk/generic/src/mm/frame.c
490,42 → 490,57
zone_t *zone = NULL;
link_t *cur;
index_t i = 0;
spinlock_lock(&zone_head_lock);
printf("No.\tBase address\tFree Frames\tBusy Frames\n");
printf("---\t------------\t-----------\t-----------\n");
for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
zone = list_get_instance(cur, zone_t, link);
spinlock_lock(&zone->lock);
printf("%d\t%L\t%d\t\t%d\n",i++,zone->base, zone->free_count, zone->busy_count);
}
spinlock_unlock(&zone_head_lock);
 
}
 
/** Prints zone details
*
* @param zone_index Zone order in zones list (0 is the first zone)
* @param base Zone base address
*/
void zone_print_one(index_t zone_index) {
zone_t *zone = NULL;
void zone_print_one(__address base) {
zone_t *zone = NULL, *z ;
link_t *cur;
index_t i = 0;
spinlock_lock(&zone_head_lock);
for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
if (i == zone_index) {
zone = list_get_instance(cur, zone_t, link);
z = list_get_instance(cur, zone_t, link);
if (base == z->base) {
zone = z;
break;
}
i++;
}
if (!zone) {
printf("No zone with index %d\n", zone_index);
printf("No zone with address %X\n", base);
return;
}
printf("Memory zone %d information\n\n", zone_index);
spinlock_lock(&zone->lock);
printf("Memory zone information\n\n");
printf("Zone base address: %P\n", zone->base);
printf("Zone size: %d frames (%d kbytes)\n", zone->free_count + zone->busy_count, ((zone->free_count + zone->busy_count) * FRAME_SIZE) >> 10);
printf("Allocated space: %d frames (%d kbytes)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
printf("Available space: %d (%d kbytes)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
printf("Buddy allocator structures: not implemented\n");
printf("\nBuddy allocator structures:\n\n");
buddy_system_structure_print(zone->buddy_system);
spinlock_unlock(&zone->lock);
spinlock_unlock(&zone_head_lock);
}