Changeset dfd9186 in mainline


Ignore:
Timestamp:
2006-01-04T18:35:07Z (19 years ago)
Author:
Sergey Bondari <bondari@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96cacc1
Parents:
5fe5f1e
Message:

Memory zones console command implementation. todo: buddy allocator structures.

Location:
generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • generic/include/mm/frame.h

    r5fe5f1e rdfd9186  
    109109extern void frame_release(frame_t *frame);
    110110
     111
     112/*
     113 * Console functions
     114 */
     115extern void zone_print_list(void);
     116extern void zone_print_one(index_t index);
     117
    111118#endif
  • generic/src/console/cmd.c

    r5fe5f1e rdfd9186  
    255255/** Data and methods for 'zone' command */
    256256static int cmd_zone(cmd_arg_t *argv);
    257 static char zone_buf[MAX_CMDLINE+1];
     257//static char zone_buf[sizeof(__native)];
    258258static cmd_arg_t zone_argv = {
    259259        .type = ARG_TYPE_INT,
    260         .buffer = zone_buf,
    261         .len = sizeof(zone_buf)
     260        //.buffer = zone_buf,
     261        .len = sizeof(__native)
    262262};
    263263
     
    608608
    609609int cmd_zones(cmd_arg_t * argv) {
    610         printf("Zones listing not implemented\n");
     610        zone_print_list();
    611611        return 1;
    612612}
    613613
    614614int cmd_zone(cmd_arg_t * argv) {
    615         printf("Zone details not implemented\n");
     615        zone_print_one(argv[0].intval);
    616616        return 1;
    617617}
  • generic/src/mm/frame.c

    r5fe5f1e rdfd9186  
    483483        frame->refcount = 1;
    484484}
     485
     486
     487void zone_print_list(void) {
     488        zone_t *zone = NULL;
     489        link_t *cur;
     490        index_t i = 0;
     491        printf("No.\tBase address\tFree Frames\tBusy Frames\n");
     492        printf("---\t------------\t-----------\t-----------\n");
     493        for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
     494                zone = list_get_instance(cur, zone_t, link);
     495                printf("%d\t%L\t%d\t\t%d\n",i++,zone->base, zone->free_count, zone->busy_count);
     496        }
     497
     498}
     499
     500void zone_print_one(index_t zone_index) {
     501        zone_t *zone = NULL;
     502        link_t *cur;
     503        index_t i = 0;
     504       
     505        for (cur = zone_head.next; cur != &zone_head; cur = cur->next) {
     506                if (i == zone_index) {
     507                        zone = list_get_instance(cur, zone_t, link);
     508                        break;
     509                }
     510                i++;
     511        }
     512       
     513        if (!zone) {
     514                printf("No zone with index %d\n", zone_index);
     515                return;
     516        }
     517       
     518        printf("Memory zone %d information\n\n", zone_index);
     519        printf("Zone base address: %P\n", zone->base);
     520        printf("Zone size: %d frames (%d kbytes)\n", zone->free_count + zone->busy_count, ((zone->free_count + zone->busy_count) * FRAME_SIZE) >> 10);
     521        printf("Allocated space: %d frames (%d kbytes)\n", zone->busy_count, (zone->busy_count * FRAME_SIZE) >> 10);
     522        printf("Available space: %d (%d kbytes)\n", zone->free_count, (zone->free_count * FRAME_SIZE) >> 10);
     523        printf("Buddy allocator structures: not implemented\n");
     524}
     525
Note: See TracChangeset for help on using the changeset viewer.