Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    rcb3d641a r4ce914d4  
    4646#include <print.h>
    4747#include <panic.h>
    48 #include <arch/types.h>
     48#include <typedefs.h>
    4949#include <adt/list.h>
    5050#include <arch.h>
    5151#include <config.h>
    5252#include <func.h>
    53 #include <string.h>
     53#include <str.h>
    5454#include <macros.h>
    5555#include <debug.h>
     
    6666#include <ipc/irq.h>
    6767#include <ipc/event.h>
     68#include <sysinfo/sysinfo.h>
    6869#include <symtab.h>
    6970#include <errno.h>
     
    387388};
    388389
     390static int cmd_sysinfo(cmd_arg_t *argv);
     391static cmd_info_t sysinfo_info = {
     392        .name = "sysinfo",
     393        .description = "Dump sysinfo.",
     394        .func = cmd_sysinfo,
     395        .argc = 0
     396};
     397
    389398/* Data and methods for 'zones' command */
    390399static int cmd_zones(cmd_arg_t *argv);
     
    475484        &set4_info,
    476485        &slabs_info,
     486        &sysinfo_info,
    477487        &symaddr_info,
    478488        &sched_info,
     
    827837        bool pointer = false;
    828838        int rc;
    829 
    830         if (((char *)argv->buffer)[0] == '*') {
     839       
     840        if (((char *) argv->buffer)[0] == '*') {
    831841                rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr);
    832842                pointer = true;
    833         } else if (((char *) argv->buffer)[0] >= '0' &&
    834                    ((char *)argv->buffer)[0] <= '9') {
    835                 rc = EOK;
    836                 addr = atoi((char *)argv->buffer);
    837         } else {
     843        } else if (((char *) argv->buffer)[0] >= '0' &&
     844                   ((char *) argv->buffer)[0] <= '9') {
     845                uint64_t value;
     846                rc = str_uint64((char *) argv->buffer, NULL, 0, true, &value);
     847                if (rc == EOK)
     848                        addr = (uintptr_t) value;
     849        } else
    838850                rc = symtab_addr_lookup((char *) argv->buffer, &addr);
    839         }
    840 
     851       
    841852        if (rc == ENOENT)
    842853                printf("Symbol %s not found.\n", argv->buffer);
     854        else if (rc == EINVAL)
     855                printf("Invalid address.\n");
    843856        else if (rc == EOVERFLOW) {
    844857                symtab_print_search((char *) argv->buffer);
    845                 printf("Duplicate symbol, be more specific.\n");
     858                printf("Duplicate symbol (be more specific) or address overflow.\n");
    846859        } else if (rc == EOK) {
    847860                if (pointer)
     
    849862                printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
    850863                *(uint32_t *) addr = arg1;
    851         } else {
     864        } else
    852865                printf("No symbol information available.\n");
    853         }
    854866       
    855867        return 1;
     
    868880}
    869881
     882/** Command for dumping sysinfo
     883 *
     884 * @param argv Ignores
     885 *
     886 * @return Always 1
     887 */
     888int cmd_sysinfo(cmd_arg_t * argv)
     889{
     890        sysinfo_dump(NULL);
     891        return 1;
     892}
     893
    870894
    871895/** Command for listings Thread information
     
    913937int cmd_zones(cmd_arg_t * argv)
    914938{
    915         zone_print_list();
     939        zones_print_list();
    916940        return 1;
    917941}
     
    10271051        ipl_t ipl = interrupts_disable();
    10281052        spinlock_lock(&TASK->lock);
    1029         uint64_t t0 = task_get_accounting(TASK);
     1053        uint64_t ucycles0, kcycles0;
     1054        task_get_accounting(TASK, &ucycles0, &kcycles0);
    10301055        spinlock_unlock(&TASK->lock);
    10311056        interrupts_restore(ipl);
     
    10331058        /* Execute the test */
    10341059        test_quiet = false;
    1035         char *ret = test->entry();
     1060        const char *ret = test->entry();
    10361061       
    10371062        /* Update and read thread accounting */
     1063        uint64_t ucycles1, kcycles1;
    10381064        ipl = interrupts_disable();
    10391065        spinlock_lock(&TASK->lock);
    1040         uint64_t dt = task_get_accounting(TASK) - t0;
     1066        task_get_accounting(TASK, &ucycles1, &kcycles1);
    10411067        spinlock_unlock(&TASK->lock);
    10421068        interrupts_restore(ipl);
    10431069       
    1044         uint64_t cycles;
    1045         char suffix;
    1046         order(dt, &cycles, &suffix);
    1047                
    1048         printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix);
     1070        uint64_t ucycles, kcycles;
     1071        char usuffix, ksuffix;
     1072        order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
     1073        order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
     1074               
     1075        printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n",
     1076                        ucycles, usuffix, kcycles, ksuffix);
    10491077       
    10501078        if (ret == NULL) {
     
    10611089        uint32_t i;
    10621090        bool ret = true;
    1063         uint64_t cycles;
    1064         char suffix;
     1091        uint64_t ucycles, kcycles;
     1092        char usuffix, ksuffix;
    10651093       
    10661094        if (cnt < 1)
     
    10801108                ipl_t ipl = interrupts_disable();
    10811109                spinlock_lock(&TASK->lock);
    1082                 uint64_t t0 = task_get_accounting(TASK);
     1110                uint64_t ucycles0, kcycles0;
     1111                task_get_accounting(TASK, &ucycles0, &kcycles0);
    10831112                spinlock_unlock(&TASK->lock);
    10841113                interrupts_restore(ipl);
     
    10861115                /* Execute the test */
    10871116                test_quiet = true;
    1088                 char * ret = test->entry();
     1117                const char *ret = test->entry();
    10891118               
    10901119                /* Update and read thread accounting */
    10911120                ipl = interrupts_disable();
    10921121                spinlock_lock(&TASK->lock);
    1093                 uint64_t dt = task_get_accounting(TASK) - t0;
     1122                uint64_t ucycles1, kcycles1;
     1123                task_get_accounting(TASK, &ucycles1, &kcycles1);
    10941124                spinlock_unlock(&TASK->lock);
    10951125                interrupts_restore(ipl);
    1096                
     1126
    10971127                if (ret != NULL) {
    10981128                        printf("%s\n", ret);
     
    11011131                }
    11021132               
    1103                 data[i] = dt;
    1104                 order(dt, &cycles, &suffix);
    1105                 printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix);
     1133                data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0;
     1134                order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
     1135                order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
     1136                printf("OK (%" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles)\n",
     1137                                ucycles, usuffix, kcycles, ksuffix);
    11061138        }
    11071139       
     
    11151147                }
    11161148               
    1117                 order(sum / (uint64_t) cnt, &cycles, &suffix);
    1118                 printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);
     1149                order_suffix(sum / (uint64_t) cnt, &ucycles, &usuffix);
     1150                printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix);
    11191151        }
    11201152       
Note: See TracChangeset for help on using the changeset viewer.