Ignore:
File:
1 edited

Legend:

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

    r40fb017 r851f33a  
    7878static cmd_info_t help_info = {
    7979        .name = "help",
    80         .description = "List supported commands.",
     80        .description = "List of supported commands.",
    8181        .func = cmd_help,
    8282        .argc = 0
    8383};
    8484
    85 /* Data and methods for 'reboot' command. */
    8685static int cmd_reboot(cmd_arg_t *argv);
    8786static cmd_info_t reboot_info = {
    8887        .name = "reboot",
    89         .description = "Reboot system.",
     88        .description = "Reboot.",
    9089        .func = cmd_reboot,
    9190        .argc = 0
    9291};
    9392
    94 /* Data and methods for 'uptime' command. */
    9593static int cmd_uptime(cmd_arg_t *argv);
    9694static cmd_info_t uptime_info = {
    9795        .name = "uptime",
    98         .description = "Show system uptime.",
     96        .description = "Print uptime information.",
    9997        .func = cmd_uptime,
    10098        .argc = 0
    10199};
    102100
    103 /* Data and methods for 'continue' command. */
    104101static int cmd_continue(cmd_arg_t *argv);
    105102static cmd_info_t continue_info = {
     
    111108
    112109#ifdef CONFIG_TEST
    113 
    114 /* Data and methods for 'test' command. */
    115110static char test_buf[MAX_CMDLINE + 1];
    116111static int cmd_test(cmd_arg_t *argv);
     
    124119static cmd_info_t test_info = {
    125120        .name = "test",
    126         .description = "<test> List kernel tests or run a test.",
     121        .description = "Print list of kernel tests or run a test.",
    127122        .func = cmd_test,
    128123        .argc = 1,
     
    130125};
    131126
    132 /* Data and methods for 'bench' command. */
    133127static int cmd_bench(cmd_arg_t *argv);
    134128static cmd_arg_t bench_argv[] = {
     
    144138static cmd_info_t bench_info = {
    145139        .name = "bench",
    146         .description = "<test> <count> Run kernel test as benchmark.",
     140        .description = "Run kernel test as benchmark.",
    147141        .func = cmd_bench,
    148142        .argc = 2,
    149143        .argv = bench_argv
    150144};
    151 
    152 #endif /* CONFIG_TEST */
     145#endif
    153146
    154147/* Data and methods for 'description' command. */
    155148static int cmd_desc(cmd_arg_t *argv);
    156149static void desc_help(void);
    157 static char desc_buf[MAX_CMDLINE + 1];
     150static char desc_buf[MAX_CMDLINE+1];
    158151static cmd_arg_t desc_argv = {
    159152        .type = ARG_TYPE_STRING,
     
    163156static cmd_info_t desc_info = {
    164157        .name = "describe",
    165         .description = "<command> Describe specified command.",
     158        .description = "Describe specified command.",
    166159        .help = desc_help,
    167160        .func = cmd_desc,
     
    172165/* Data and methods for 'symaddr' command. */
    173166static int cmd_symaddr(cmd_arg_t *argv);
    174 static char symaddr_buf[MAX_CMDLINE + 1];
     167static char symaddr_buf[MAX_CMDLINE+1];
    175168static cmd_arg_t symaddr_argv = {
    176169        .type = ARG_TYPE_STRING,
     
    180173static cmd_info_t symaddr_info = {
    181174        .name = "symaddr",
    182         .description = "<symbol> Return symbol address.",
     175        .description = "Return symbol address.",
    183176        .func = cmd_symaddr,
    184177        .argc = 1,
     
    186179};
    187180
    188 /* Data and methods for 'set4' command. */
    189 static char set_buf[MAX_CMDLINE + 1];
     181static char set_buf[MAX_CMDLINE+1];
    190182static int cmd_set4(cmd_arg_t *argv);
    191183static cmd_arg_t set4_argv[] = {
     
    201193static cmd_info_t set4_info = {
    202194        .name = "set4",
    203         .description = "<addr> <value> Set 4B memory location to a value.",
     195        .description = "set <dest_addr> <value> - 4byte version",
    204196        .func = cmd_set4,
    205197        .argc = 2,
     
    221213static cmd_info_t call0_info = {
    222214        .name = "call0",
    223         .description = "<function> Call function().",
     215        .description = "call0 <function> -> call function().",
    224216        .func = cmd_call0,
    225217        .argc = 1,
     
    236228static cmd_info_t mcall0_info = {
    237229        .name = "mcall0",
    238         .description = "<function> Call function() on each CPU.",
     230        .description = "mcall0 <function> -> call function() on each CPU.",
    239231        .func = cmd_mcall0,
    240232        .argc = 1,
     
    258250static cmd_info_t call1_info = {
    259251        .name = "call1",
    260         .description = "<function> <arg1> Call function(arg1).",
     252        .description = "call1 <function> <arg1> -> call function(arg1).",
    261253        .func = cmd_call1,
    262254        .argc = 2,
     
    285277static cmd_info_t call2_info = {
    286278        .name = "call2",
    287         .description = "<function> <arg1> <arg2> Call function(arg1, arg2).",
     279        .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
    288280        .func = cmd_call2,
    289281        .argc = 3,
     
    318310static cmd_info_t call3_info = {
    319311        .name = "call3",
    320         .description = "<function> <arg1> <arg2> <arg3> Call function(arg1, arg2, arg3).",
     312        .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
    321313        .func = cmd_call3,
    322314        .argc = 4,
     
    348340cmd_info_t tlb_info = {
    349341        .name = "tlb",
    350         .description = "Print TLB of the current CPU.",
     342        .description = "Print TLB of current processor.",
    351343        .help = NULL,
    352344        .func = cmd_tlb,
     
    385377};
    386378
    387 #ifdef CONFIG_UDEBUG
    388 
    389 /* Data and methods for 'btrace' command */
    390 static int cmd_btrace(cmd_arg_t *argv);
    391 static cmd_arg_t btrace_argv = {
    392         .type = ARG_TYPE_INT,
    393 };
    394 static cmd_info_t btrace_info = {
    395         .name = "btrace",
    396         .description = "<threadid> Show thread stack trace.",
    397         .func = cmd_btrace,
    398         .argc = 1,
    399         .argv = &btrace_argv
    400 };
    401 
    402 #endif /* CONFIG_UDEBUG */
    403379
    404380static int cmd_sched(cmd_arg_t *argv);
    405381static cmd_info_t sched_info = {
    406382        .name = "scheduler",
    407         .description = "Show scheduler information.",
     383        .description = "List all scheduler information.",
    408384        .func = cmd_sched,
    409385        .argc = 0
     
    430406static cmd_info_t zones_info = {
    431407        .name = "zones",
    432         .description = "List memory zones.",
     408        .description = "List of memory zones.",
    433409        .func = cmd_zones,
    434410        .argc = 0
     411};
     412
     413/* Data and methods for 'ipc' command */
     414static int cmd_ipc(cmd_arg_t *argv);
     415static cmd_arg_t ipc_argv = {
     416        .type = ARG_TYPE_INT,
     417};
     418static cmd_info_t ipc_info = {
     419        .name = "ipc",
     420        .description = "ipc <taskid> Show IPC information of given task.",
     421        .func = cmd_ipc,
     422        .argc = 1,
     423        .argv = &ipc_argv
     424};
     425
     426/* Data and methods for 'kill' command */
     427static int cmd_kill(cmd_arg_t *argv);
     428static cmd_arg_t kill_argv = {
     429        .type = ARG_TYPE_INT,
     430};
     431static cmd_info_t kill_info = {
     432        .name = "kill",
     433        .description = "kill <taskid> Kill a task.",
     434        .func = cmd_kill,
     435        .argc = 1,
     436        .argv = &kill_argv
    435437};
    436438
     
    443445static cmd_info_t zone_info = {
    444446        .name = "zone",
    445         .description = "<zone> Show memory zone structure.",
     447        .description = "Show memory zone structure.",
    446448        .func = cmd_zone,
    447449        .argc = 1,
    448450        .argv = &zone_argv
    449 };
    450 
    451 /* Data and methods for 'ipc' command */
    452 static int cmd_ipc(cmd_arg_t *argv);
    453 static cmd_arg_t ipc_argv = {
    454         .type = ARG_TYPE_INT,
    455 };
    456 static cmd_info_t ipc_info = {
    457         .name = "ipc",
    458         .description = "<taskid> Show IPC information of a task.",
    459         .func = cmd_ipc,
    460         .argc = 1,
    461         .argv = &ipc_argv
    462 };
    463 
    464 /* Data and methods for 'kill' command */
    465 static int cmd_kill(cmd_arg_t *argv);
    466 static cmd_arg_t kill_argv = {
    467         .type = ARG_TYPE_INT,
    468 };
    469 static cmd_info_t kill_info = {
    470         .name = "kill",
    471         .description = "<taskid> Kill a task.",
    472         .func = cmd_kill,
    473         .argc = 1,
    474         .argv = &kill_argv
    475451};
    476452
     
    506482        &cpus_info,
    507483        &desc_info,
     484        &reboot_info,
     485        &uptime_info,
    508486        &halt_info,
    509487        &help_info,
    510488        &ipc_info,
    511489        &kill_info,
    512         &physmem_info,
    513         &reboot_info,
    514         &sched_info,
    515490        &set4_info,
    516491        &slabs_info,
     492        &sysinfo_info,
    517493        &symaddr_info,
    518         &sysinfo_info,
     494        &sched_info,
     495        &threads_info,
    519496        &tasks_info,
    520         &threads_info,
     497        &physmem_info,
    521498        &tlb_info,
    522         &uptime_info,
    523499        &version_info,
    524500        &zones_info,
     
    528504        &bench_info,
    529505#endif
    530 #ifdef CONFIG_UDEBUG
    531         &btrace_info,
    532 #endif
    533506        NULL
    534507};
     
    553526        for (i = 0; basic_commands[i]; i++) {
    554527                cmd_initialize(basic_commands[i]);
    555         }
    556 
    557         for (i = 0; basic_commands[i]; i++) {
    558                 if (!cmd_register(basic_commands[i])) {
    559                         printf("Cannot register command %s\n",
    560                             basic_commands[i]->name);
    561                 }
    562         }
    563 }
     528                if (!cmd_register(basic_commands[i]))
     529                        printf("Cannot register command %s\n", basic_commands[i]->name);
     530        }
     531}
     532
    564533
    565534/** List supported commands.
     
    585554        }
    586555       
    587         unsigned int _len = (unsigned int) len;
    588         if ((_len != len) || (((int) _len) < 0)) {
    589                 printf("Command length overflow\n");
    590                 return 1;
    591         }
    592        
    593556        for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
    594557                cmd_info_t *hlp;
     
    596559               
    597560                spinlock_lock(&hlp->lock);
    598                 printf("%-*s %s\n", _len, hlp->name, hlp->description);
     561                printf("%-*s %s\n", len, hlp->name, hlp->description);
    599562                spinlock_unlock(&hlp->lock);
    600563        }
     
    605568}
    606569
     570
    607571/** Reboot the system.
    608572 *
     
    619583}
    620584
     585
    621586/** Print system uptime information.
    622587 *
     
    630595       
    631596        /* This doesn't have to be very accurate */
    632         sysarg_t sec = uptime->seconds1;
     597        unative_t sec = uptime->seconds1;
    633598       
    634599        printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
     
    685650        uintptr_t symaddr;
    686651        char *symbol;
    687         sysarg_t (*fnc)(void);
     652        unative_t (*fnc)(void);
    688653        fncptr_t fptr;
    689654        int rc;
     
    701666
    702667                ipl = interrupts_disable();
    703                 fnc = (sysarg_t (*)(void)) arch_construct_function(&fptr,
     668                fnc = (unative_t (*)(void)) arch_construct_function(&fptr,
    704669                    (void *) symaddr, (void *) cmd_call0);
    705                 printf("Calling %s() (%p)\n", symbol, (void *) symaddr);
     670                printf("Calling %s() (%p)\n", symbol, symaddr);
    706671                printf("Result: %#" PRIxn "\n", fnc());
    707672                interrupts_restore(ipl);
     
    720685         */
    721686       
    722         unsigned int i;
     687        size_t i;
    723688        for (i = 0; i < config.cpu_count; i++) {
    724689                if (!cpus[i].active)
     
    732697                        irq_spinlock_unlock(&thread->lock, true);
    733698                       
    734                         printf("cpu%u: ", i);
     699                        printf("cpu%" PRIs ": ", i);
    735700                       
    736701                        thread_ready(thread);
     
    738703                        thread_detach(thread);
    739704                } else
    740                         printf("Unable to create thread for cpu%u\n", i);
     705                        printf("Unable to create thread for cpu%" PRIs "\n", i);
    741706        }
    742707       
     
    749714        uintptr_t symaddr;
    750715        char *symbol;
    751         sysarg_t (*fnc)(sysarg_t, ...);
    752         sysarg_t arg1 = argv[1].intval;
     716        unative_t (*fnc)(unative_t, ...);
     717        unative_t arg1 = argv[1].intval;
    753718        fncptr_t fptr;
    754719        int rc;
     
    766731
    767732                ipl = interrupts_disable();
    768                 fnc = (sysarg_t (*)(sysarg_t, ...))
    769                     arch_construct_function(&fptr, (void *) symaddr,
    770                     (void *) cmd_call1);
    771                 printf("Calling f(%#" PRIxn "): %p: %s\n", arg1,
    772                     (void *) symaddr, symbol);
     733                fnc = (unative_t (*)(unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call1);
     734                printf("Calling f(%#" PRIxn "): %p: %s\n", arg1, symaddr, symbol);
    773735                printf("Result: %#" PRIxn "\n", fnc(arg1));
    774736                interrupts_restore(ipl);
     
    785747        uintptr_t symaddr;
    786748        char *symbol;
    787         sysarg_t (*fnc)(sysarg_t, sysarg_t, ...);
    788         sysarg_t arg1 = argv[1].intval;
    789         sysarg_t arg2 = argv[2].intval;
     749        unative_t (*fnc)(unative_t, unative_t, ...);
     750        unative_t arg1 = argv[1].intval;
     751        unative_t arg2 = argv[2].intval;
    790752        fncptr_t fptr;
    791753        int rc;
     
    803765
    804766                ipl = interrupts_disable();
    805                 fnc = (sysarg_t (*)(sysarg_t, sysarg_t, ...))
    806                     arch_construct_function(&fptr, (void *) symaddr,
    807                     (void *) cmd_call2);
     767                fnc = (unative_t (*)(unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call2);
    808768                printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
    809                        arg1, arg2, (void *) symaddr, symbol);
     769                       arg1, arg2, symaddr, symbol);
    810770                printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
    811771                interrupts_restore(ipl);
     
    821781        uintptr_t symaddr;
    822782        char *symbol;
    823         sysarg_t (*fnc)(sysarg_t, sysarg_t, sysarg_t, ...);
    824         sysarg_t arg1 = argv[1].intval;
    825         sysarg_t arg2 = argv[2].intval;
    826         sysarg_t arg3 = argv[3].intval;
     783        unative_t (*fnc)(unative_t, unative_t, unative_t, ...);
     784        unative_t arg1 = argv[1].intval;
     785        unative_t arg2 = argv[2].intval;
     786        unative_t arg3 = argv[3].intval;
    827787        fncptr_t fptr;
    828788        int rc;
     
    840800
    841801                ipl = interrupts_disable();
    842                 fnc = (sysarg_t (*)(sysarg_t, sysarg_t, sysarg_t, ...))
    843                     arch_construct_function(&fptr, (void *) symaddr,
    844                     (void *) cmd_call3);
    845                 printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
    846                        arg1, arg2, arg3, (void *) symaddr, symbol);
     802                fnc = (unative_t (*)(unative_t, unative_t, unative_t, ...)) arch_construct_function(&fptr, (void *) symaddr, (void *) cmd_call3);
     803                printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
     804                       arg1, arg2, arg3, symaddr, symbol);
    847805                printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
    848806                interrupts_restore(ipl);
     
    852810        return 1;
    853811}
     812
    854813
    855814/** Print detailed description of 'describe' command. */
     
    916875       
    917876        if (rc == ENOENT)
    918                 printf("Symbol %s not found.\n", (char *) argv->buffer);
     877                printf("Symbol %s not found.\n", argv->buffer);
    919878        else if (rc == EINVAL)
    920879                printf("Invalid address.\n");
     
    925884                if (pointer)
    926885                        addr = *(uintptr_t *) addr;
    927                 printf("Writing %#" PRIx32" -> %p\n", arg1, (void *) addr);
     886                printf("Writing %#" PRIx64 " -> %p\n", arg1, addr);
    928887                *(uint32_t *) addr = arg1;
    929888        } else
     
    939898 * @return Always 1
    940899 */
    941 int cmd_slabs(cmd_arg_t *argv)
     900int cmd_slabs(cmd_arg_t * argv)
    942901{
    943902        slab_print_list();
     
    951910 * @return Always 1
    952911 */
    953 int cmd_sysinfo(cmd_arg_t *argv)
     912int cmd_sysinfo(cmd_arg_t * argv)
    954913{
    955914        sysinfo_dump(NULL);
     
    957916}
    958917
    959 /** Command for listing thread information
     918
     919/** Command for listings Thread information
    960920 *
    961921 * @param argv Ignored
     
    975935}
    976936
    977 /** Command for listing task information
     937/** Command for listings Task information
    978938 *
    979939 * @param argv Ignored
     
    993953}
    994954
    995 #ifdef CONFIG_UDEBUG
    996 
    997 /** Command for printing thread stack trace
     955/** Command for listings Thread information
     956 *
     957 * @param argv Ignores
     958 *
     959 * @return Always 1
     960 */
     961int cmd_sched(cmd_arg_t * argv)
     962{
     963        sched_print_list();
     964        return 1;
     965}
     966
     967/** Command for listing memory zones
     968 *
     969 * @param argv Ignored
     970 *
     971 * return Always 1
     972 */
     973int cmd_zones(cmd_arg_t * argv)
     974{
     975        zones_print_list();
     976        return 1;
     977}
     978
     979/** Command for memory zone details
    998980 *
    999981 * @param argv Integer argument from cmdline expected
    1000982 *
    1001983 * return Always 1
    1002  *
    1003  */
    1004 int cmd_btrace(cmd_arg_t *argv)
    1005 {
    1006         thread_stack_trace(argv[0].intval);
    1007         return 1;
    1008 }
    1009 
    1010 #endif /* CONFIG_UDEBUG */
    1011 
    1012 /** Command for printing scheduler information
    1013  *
    1014  * @param argv Ignores
    1015  *
    1016  * @return Always 1
    1017  */
    1018 int cmd_sched(cmd_arg_t *argv)
    1019 {
    1020         sched_print_list();
    1021         return 1;
    1022 }
    1023 
    1024 /** Command for listing memory zones
    1025  *
    1026  * @param argv Ignored
     984 */
     985int cmd_zone(cmd_arg_t * argv)
     986{
     987        zone_print_one(argv[0].intval);
     988        return 1;
     989}
     990
     991/** Command for printing task ipc details
     992 *
     993 * @param argv Integer argument from cmdline expected
    1027994 *
    1028995 * return Always 1
    1029996 */
    1030 int cmd_zones(cmd_arg_t *argv)
    1031 {
    1032         zones_print_list();
    1033         return 1;
    1034 }
    1035 
    1036 /** Command for memory zone details
     997int cmd_ipc(cmd_arg_t * argv)
     998{
     999        ipc_print_task(argv[0].intval);
     1000        return 1;
     1001}
     1002
     1003/** Command for killing a task
    10371004 *
    10381005 * @param argv Integer argument from cmdline expected
    10391006 *
    1040  * return Always 1
    1041  */
    1042 int cmd_zone(cmd_arg_t *argv)
    1043 {
    1044         zone_print_one(argv[0].intval);
    1045         return 1;
    1046 }
    1047 
    1048 /** Command for printing task IPC details
    1049  *
    1050  * @param argv Integer argument from cmdline expected
    1051  *
    1052  * return Always 1
    1053  */
    1054 int cmd_ipc(cmd_arg_t *argv)
    1055 {
    1056         ipc_print_task(argv[0].intval);
    1057         return 1;
    1058 }
    1059 
    1060 /** Command for killing a task
    1061  *
    1062  * @param argv Integer argument from cmdline expected
    1063  *
    10641007 * return 0 on failure, 1 on success.
    10651008 */
    1066 int cmd_kill(cmd_arg_t *argv)
     1009int cmd_kill(cmd_arg_t * argv)
    10671010{
    10681011        if (task_kill(argv[0].intval) != EOK)
     
    12291172        }
    12301173       
    1231         unsigned int _len = (unsigned int) len;
    1232         if ((_len != len) || (((int) _len) < 0)) {
    1233                 printf("Command length overflow\n");
    1234                 return;
    1235         }
    1236        
    12371174        for (test = tests; test->name != NULL; test++)
    1238                 printf("%-*s %s%s\n", _len, test->name, test->desc,
    1239                     (test->safe ? "" : " (unsafe)"));
    1240        
    1241         printf("%-*s Run all safe tests\n", _len, "*");
     1175                printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
     1176       
     1177        printf("%-*s Run all safe tests\n", len, "*");
    12421178}
    12431179
Note: See TracChangeset for help on using the changeset viewer.