Ignore:
File:
1 edited

Legend:

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

    r4ce914d4 rcb3d641a  
    4646#include <print.h>
    4747#include <panic.h>
    48 #include <typedefs.h>
     48#include <arch/types.h>
    4949#include <adt/list.h>
    5050#include <arch.h>
    5151#include <config.h>
    5252#include <func.h>
    53 #include <str.h>
     53#include <string.h>
    5454#include <macros.h>
    5555#include <debug.h>
     
    6666#include <ipc/irq.h>
    6767#include <ipc/event.h>
    68 #include <sysinfo/sysinfo.h>
    6968#include <symtab.h>
    7069#include <errno.h>
     
    388387};
    389388
    390 static int cmd_sysinfo(cmd_arg_t *argv);
    391 static cmd_info_t sysinfo_info = {
    392         .name = "sysinfo",
    393         .description = "Dump sysinfo.",
    394         .func = cmd_sysinfo,
    395         .argc = 0
    396 };
    397 
    398389/* Data and methods for 'zones' command */
    399390static int cmd_zones(cmd_arg_t *argv);
     
    484475        &set4_info,
    485476        &slabs_info,
    486         &sysinfo_info,
    487477        &symaddr_info,
    488478        &sched_info,
     
    837827        bool pointer = false;
    838828        int rc;
    839        
    840         if (((char *) argv->buffer)[0] == '*') {
     829
     830        if (((char *)argv->buffer)[0] == '*') {
    841831                rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr);
    842832                pointer = true;
    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
     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 {
    850838                rc = symtab_addr_lookup((char *) argv->buffer, &addr);
    851        
     839        }
     840
    852841        if (rc == ENOENT)
    853842                printf("Symbol %s not found.\n", argv->buffer);
    854         else if (rc == EINVAL)
    855                 printf("Invalid address.\n");
    856843        else if (rc == EOVERFLOW) {
    857844                symtab_print_search((char *) argv->buffer);
    858                 printf("Duplicate symbol (be more specific) or address overflow.\n");
     845                printf("Duplicate symbol, be more specific.\n");
    859846        } else if (rc == EOK) {
    860847                if (pointer)
     
    862849                printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
    863850                *(uint32_t *) addr = arg1;
    864         } else
     851        } else {
    865852                printf("No symbol information available.\n");
     853        }
    866854       
    867855        return 1;
     
    880868}
    881869
    882 /** Command for dumping sysinfo
     870
     871/** Command for listings Thread information
    883872 *
    884873 * @param argv Ignores
     
    886875 * @return Always 1
    887876 */
    888 int cmd_sysinfo(cmd_arg_t * argv)
    889 {
    890         sysinfo_dump(NULL);
    891         return 1;
    892 }
    893 
     877int cmd_threads(cmd_arg_t * argv)
     878{
     879        thread_print_list();
     880        return 1;
     881}
     882
     883/** Command for listings Task information
     884 *
     885 * @param argv Ignores
     886 *
     887 * @return Always 1
     888 */
     889int cmd_tasks(cmd_arg_t * argv)
     890{
     891        task_print_list();
     892        return 1;
     893}
    894894
    895895/** Command for listings Thread information
     
    899899 * @return Always 1
    900900 */
    901 int cmd_threads(cmd_arg_t * argv)
    902 {
    903         thread_print_list();
    904         return 1;
    905 }
    906 
    907 /** Command for listings Task information
    908  *
    909  * @param argv Ignores
    910  *
    911  * @return Always 1
    912  */
    913 int cmd_tasks(cmd_arg_t * argv)
    914 {
    915         task_print_list();
    916         return 1;
    917 }
    918 
    919 /** Command for listings Thread information
    920  *
    921  * @param argv Ignores
    922  *
    923  * @return Always 1
    924  */
    925901int cmd_sched(cmd_arg_t * argv)
    926902{
     
    937913int cmd_zones(cmd_arg_t * argv)
    938914{
    939         zones_print_list();
     915        zone_print_list();
    940916        return 1;
    941917}
     
    10511027        ipl_t ipl = interrupts_disable();
    10521028        spinlock_lock(&TASK->lock);
    1053         uint64_t ucycles0, kcycles0;
    1054         task_get_accounting(TASK, &ucycles0, &kcycles0);
     1029        uint64_t t0 = task_get_accounting(TASK);
    10551030        spinlock_unlock(&TASK->lock);
    10561031        interrupts_restore(ipl);
     
    10581033        /* Execute the test */
    10591034        test_quiet = false;
    1060         const char *ret = test->entry();
     1035        char *ret = test->entry();
    10611036       
    10621037        /* Update and read thread accounting */
    1063         uint64_t ucycles1, kcycles1;
    10641038        ipl = interrupts_disable();
    10651039        spinlock_lock(&TASK->lock);
    1066         task_get_accounting(TASK, &ucycles1, &kcycles1);
     1040        uint64_t dt = task_get_accounting(TASK) - t0;
    10671041        spinlock_unlock(&TASK->lock);
    10681042        interrupts_restore(ipl);
    10691043       
    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);
     1044        uint64_t cycles;
     1045        char suffix;
     1046        order(dt, &cycles, &suffix);
     1047               
     1048        printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix);
    10771049       
    10781050        if (ret == NULL) {
     
    10891061        uint32_t i;
    10901062        bool ret = true;
    1091         uint64_t ucycles, kcycles;
    1092         char usuffix, ksuffix;
     1063        uint64_t cycles;
     1064        char suffix;
    10931065       
    10941066        if (cnt < 1)
     
    11081080                ipl_t ipl = interrupts_disable();
    11091081                spinlock_lock(&TASK->lock);
    1110                 uint64_t ucycles0, kcycles0;
    1111                 task_get_accounting(TASK, &ucycles0, &kcycles0);
     1082                uint64_t t0 = task_get_accounting(TASK);
    11121083                spinlock_unlock(&TASK->lock);
    11131084                interrupts_restore(ipl);
     
    11151086                /* Execute the test */
    11161087                test_quiet = true;
    1117                 const char *ret = test->entry();
     1088                char * ret = test->entry();
    11181089               
    11191090                /* Update and read thread accounting */
    11201091                ipl = interrupts_disable();
    11211092                spinlock_lock(&TASK->lock);
    1122                 uint64_t ucycles1, kcycles1;
    1123                 task_get_accounting(TASK, &ucycles1, &kcycles1);
     1093                uint64_t dt = task_get_accounting(TASK) - t0;
    11241094                spinlock_unlock(&TASK->lock);
    11251095                interrupts_restore(ipl);
    1126 
     1096               
    11271097                if (ret != NULL) {
    11281098                        printf("%s\n", ret);
     
    11311101                }
    11321102               
    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);
     1103                data[i] = dt;
     1104                order(dt, &cycles, &suffix);
     1105                printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix);
    11381106        }
    11391107       
     
    11471115                }
    11481116               
    1149                 order_suffix(sum / (uint64_t) cnt, &ucycles, &usuffix);
    1150                 printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix);
     1117                order(sum / (uint64_t) cnt, &cycles, &suffix);
     1118                printf("Average\t\t%" PRIu64 "%c\n", cycles, suffix);
    11511119        }
    11521120       
Note: See TracChangeset for help on using the changeset viewer.