Changes in kernel/generic/src/console/cmd.c [40fb017:851f33a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/cmd.c
r40fb017 r851f33a 78 78 static cmd_info_t help_info = { 79 79 .name = "help", 80 .description = "List supported commands.",80 .description = "List of supported commands.", 81 81 .func = cmd_help, 82 82 .argc = 0 83 83 }; 84 84 85 /* Data and methods for 'reboot' command. */86 85 static int cmd_reboot(cmd_arg_t *argv); 87 86 static cmd_info_t reboot_info = { 88 87 .name = "reboot", 89 .description = "Reboot system.",88 .description = "Reboot.", 90 89 .func = cmd_reboot, 91 90 .argc = 0 92 91 }; 93 92 94 /* Data and methods for 'uptime' command. */95 93 static int cmd_uptime(cmd_arg_t *argv); 96 94 static cmd_info_t uptime_info = { 97 95 .name = "uptime", 98 .description = " Show system uptime.",96 .description = "Print uptime information.", 99 97 .func = cmd_uptime, 100 98 .argc = 0 101 99 }; 102 100 103 /* Data and methods for 'continue' command. */104 101 static int cmd_continue(cmd_arg_t *argv); 105 102 static cmd_info_t continue_info = { … … 111 108 112 109 #ifdef CONFIG_TEST 113 114 /* Data and methods for 'test' command. */115 110 static char test_buf[MAX_CMDLINE + 1]; 116 111 static int cmd_test(cmd_arg_t *argv); … … 124 119 static cmd_info_t test_info = { 125 120 .name = "test", 126 .description = " <test> Listkernel tests or run a test.",121 .description = "Print list of kernel tests or run a test.", 127 122 .func = cmd_test, 128 123 .argc = 1, … … 130 125 }; 131 126 132 /* Data and methods for 'bench' command. */133 127 static int cmd_bench(cmd_arg_t *argv); 134 128 static cmd_arg_t bench_argv[] = { … … 144 138 static cmd_info_t bench_info = { 145 139 .name = "bench", 146 .description = " <test> <count>Run kernel test as benchmark.",140 .description = "Run kernel test as benchmark.", 147 141 .func = cmd_bench, 148 142 .argc = 2, 149 143 .argv = bench_argv 150 144 }; 151 152 #endif /* CONFIG_TEST */ 145 #endif 153 146 154 147 /* Data and methods for 'description' command. */ 155 148 static int cmd_desc(cmd_arg_t *argv); 156 149 static void desc_help(void); 157 static char desc_buf[MAX_CMDLINE +1];150 static char desc_buf[MAX_CMDLINE+1]; 158 151 static cmd_arg_t desc_argv = { 159 152 .type = ARG_TYPE_STRING, … … 163 156 static cmd_info_t desc_info = { 164 157 .name = "describe", 165 .description = " <command>Describe specified command.",158 .description = "Describe specified command.", 166 159 .help = desc_help, 167 160 .func = cmd_desc, … … 172 165 /* Data and methods for 'symaddr' command. */ 173 166 static int cmd_symaddr(cmd_arg_t *argv); 174 static char symaddr_buf[MAX_CMDLINE +1];167 static char symaddr_buf[MAX_CMDLINE+1]; 175 168 static cmd_arg_t symaddr_argv = { 176 169 .type = ARG_TYPE_STRING, … … 180 173 static cmd_info_t symaddr_info = { 181 174 .name = "symaddr", 182 .description = " <symbol>Return symbol address.",175 .description = "Return symbol address.", 183 176 .func = cmd_symaddr, 184 177 .argc = 1, … … 186 179 }; 187 180 188 /* Data and methods for 'set4' command. */ 189 static char set_buf[MAX_CMDLINE + 1]; 181 static char set_buf[MAX_CMDLINE+1]; 190 182 static int cmd_set4(cmd_arg_t *argv); 191 183 static cmd_arg_t set4_argv[] = { … … 201 193 static cmd_info_t set4_info = { 202 194 .name = "set4", 203 .description = " <addr> <value> Set 4B memory location to a value.",195 .description = "set <dest_addr> <value> - 4byte version", 204 196 .func = cmd_set4, 205 197 .argc = 2, … … 221 213 static cmd_info_t call0_info = { 222 214 .name = "call0", 223 .description = " <function> Call function().",215 .description = "call0 <function> -> call function().", 224 216 .func = cmd_call0, 225 217 .argc = 1, … … 236 228 static cmd_info_t mcall0_info = { 237 229 .name = "mcall0", 238 .description = " <function> Call function() on each CPU.",230 .description = "mcall0 <function> -> call function() on each CPU.", 239 231 .func = cmd_mcall0, 240 232 .argc = 1, … … 258 250 static cmd_info_t call1_info = { 259 251 .name = "call1", 260 .description = " <function> <arg1> Call function(arg1).",252 .description = "call1 <function> <arg1> -> call function(arg1).", 261 253 .func = cmd_call1, 262 254 .argc = 2, … … 285 277 static cmd_info_t call2_info = { 286 278 .name = "call2", 287 .description = " <function> <arg1> <arg2> Call function(arg1,arg2).",279 .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).", 288 280 .func = cmd_call2, 289 281 .argc = 3, … … 318 310 static cmd_info_t call3_info = { 319 311 .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).", 321 313 .func = cmd_call3, 322 314 .argc = 4, … … 348 340 cmd_info_t tlb_info = { 349 341 .name = "tlb", 350 .description = "Print TLB of the current CPU.",342 .description = "Print TLB of current processor.", 351 343 .help = NULL, 352 344 .func = cmd_tlb, … … 385 377 }; 386 378 387 #ifdef CONFIG_UDEBUG388 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_argv400 };401 402 #endif /* CONFIG_UDEBUG */403 379 404 380 static int cmd_sched(cmd_arg_t *argv); 405 381 static cmd_info_t sched_info = { 406 382 .name = "scheduler", 407 .description = " Showscheduler information.",383 .description = "List all scheduler information.", 408 384 .func = cmd_sched, 409 385 .argc = 0 … … 430 406 static cmd_info_t zones_info = { 431 407 .name = "zones", 432 .description = "List memory zones.",408 .description = "List of memory zones.", 433 409 .func = cmd_zones, 434 410 .argc = 0 411 }; 412 413 /* Data and methods for 'ipc' command */ 414 static int cmd_ipc(cmd_arg_t *argv); 415 static cmd_arg_t ipc_argv = { 416 .type = ARG_TYPE_INT, 417 }; 418 static 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 */ 427 static int cmd_kill(cmd_arg_t *argv); 428 static cmd_arg_t kill_argv = { 429 .type = ARG_TYPE_INT, 430 }; 431 static 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 435 437 }; 436 438 … … 443 445 static cmd_info_t zone_info = { 444 446 .name = "zone", 445 .description = " <zone>Show memory zone structure.",447 .description = "Show memory zone structure.", 446 448 .func = cmd_zone, 447 449 .argc = 1, 448 450 .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_argv462 };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_argv475 451 }; 476 452 … … 506 482 &cpus_info, 507 483 &desc_info, 484 &reboot_info, 485 &uptime_info, 508 486 &halt_info, 509 487 &help_info, 510 488 &ipc_info, 511 489 &kill_info, 512 &physmem_info,513 &reboot_info,514 &sched_info,515 490 &set4_info, 516 491 &slabs_info, 492 &sysinfo_info, 517 493 &symaddr_info, 518 &sysinfo_info, 494 &sched_info, 495 &threads_info, 519 496 &tasks_info, 520 & threads_info,497 &physmem_info, 521 498 &tlb_info, 522 &uptime_info,523 499 &version_info, 524 500 &zones_info, … … 528 504 &bench_info, 529 505 #endif 530 #ifdef CONFIG_UDEBUG531 &btrace_info,532 #endif533 506 NULL 534 507 }; … … 553 526 for (i = 0; basic_commands[i]; i++) { 554 527 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 564 533 565 534 /** List supported commands. … … 585 554 } 586 555 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 593 556 for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { 594 557 cmd_info_t *hlp; … … 596 559 597 560 spinlock_lock(&hlp->lock); 598 printf("%-*s %s\n", _len, hlp->name, hlp->description);561 printf("%-*s %s\n", len, hlp->name, hlp->description); 599 562 spinlock_unlock(&hlp->lock); 600 563 } … … 605 568 } 606 569 570 607 571 /** Reboot the system. 608 572 * … … 619 583 } 620 584 585 621 586 /** Print system uptime information. 622 587 * … … 630 595 631 596 /* This doesn't have to be very accurate */ 632 sysarg_t sec = uptime->seconds1;597 unative_t sec = uptime->seconds1; 633 598 634 599 printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n", … … 685 650 uintptr_t symaddr; 686 651 char *symbol; 687 sysarg_t (*fnc)(void);652 unative_t (*fnc)(void); 688 653 fncptr_t fptr; 689 654 int rc; … … 701 666 702 667 ipl = interrupts_disable(); 703 fnc = ( sysarg_t (*)(void)) arch_construct_function(&fptr,668 fnc = (unative_t (*)(void)) arch_construct_function(&fptr, 704 669 (void *) symaddr, (void *) cmd_call0); 705 printf("Calling %s() (%p)\n", symbol, (void *)symaddr);670 printf("Calling %s() (%p)\n", symbol, symaddr); 706 671 printf("Result: %#" PRIxn "\n", fnc()); 707 672 interrupts_restore(ipl); … … 720 685 */ 721 686 722 unsigned int i;687 size_t i; 723 688 for (i = 0; i < config.cpu_count; i++) { 724 689 if (!cpus[i].active) … … 732 697 irq_spinlock_unlock(&thread->lock, true); 733 698 734 printf("cpu% u: ", i);699 printf("cpu%" PRIs ": ", i); 735 700 736 701 thread_ready(thread); … … 738 703 thread_detach(thread); 739 704 } else 740 printf("Unable to create thread for cpu% u\n", i);705 printf("Unable to create thread for cpu%" PRIs "\n", i); 741 706 } 742 707 … … 749 714 uintptr_t symaddr; 750 715 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; 753 718 fncptr_t fptr; 754 719 int rc; … … 766 731 767 732 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); 773 735 printf("Result: %#" PRIxn "\n", fnc(arg1)); 774 736 interrupts_restore(ipl); … … 785 747 uintptr_t symaddr; 786 748 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; 790 752 fncptr_t fptr; 791 753 int rc; … … 803 765 804 766 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); 808 768 printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n", 809 arg1, arg2, (void *)symaddr, symbol);769 arg1, arg2, symaddr, symbol); 810 770 printf("Result: %#" PRIxn "\n", fnc(arg1, arg2)); 811 771 interrupts_restore(ipl); … … 821 781 uintptr_t symaddr; 822 782 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; 827 787 fncptr_t fptr; 828 788 int rc; … … 840 800 841 801 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); 847 805 printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3)); 848 806 interrupts_restore(ipl); … … 852 810 return 1; 853 811 } 812 854 813 855 814 /** Print detailed description of 'describe' command. */ … … 916 875 917 876 if (rc == ENOENT) 918 printf("Symbol %s not found.\n", (char *)argv->buffer);877 printf("Symbol %s not found.\n", argv->buffer); 919 878 else if (rc == EINVAL) 920 879 printf("Invalid address.\n"); … … 925 884 if (pointer) 926 885 addr = *(uintptr_t *) addr; 927 printf("Writing %#" PRIx 32" -> %p\n", arg1, (void *)addr);886 printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); 928 887 *(uint32_t *) addr = arg1; 929 888 } else … … 939 898 * @return Always 1 940 899 */ 941 int cmd_slabs(cmd_arg_t * argv)900 int cmd_slabs(cmd_arg_t * argv) 942 901 { 943 902 slab_print_list(); … … 951 910 * @return Always 1 952 911 */ 953 int cmd_sysinfo(cmd_arg_t * argv)912 int cmd_sysinfo(cmd_arg_t * argv) 954 913 { 955 914 sysinfo_dump(NULL); … … 957 916 } 958 917 959 /** Command for listing thread information 918 919 /** Command for listings Thread information 960 920 * 961 921 * @param argv Ignored … … 975 935 } 976 936 977 /** Command for listing task information937 /** Command for listings Task information 978 938 * 979 939 * @param argv Ignored … … 993 953 } 994 954 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 */ 961 int 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 */ 973 int cmd_zones(cmd_arg_t * argv) 974 { 975 zones_print_list(); 976 return 1; 977 } 978 979 /** Command for memory zone details 998 980 * 999 981 * @param argv Integer argument from cmdline expected 1000 982 * 1001 983 * 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 */ 985 int 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 1027 994 * 1028 995 * return Always 1 1029 996 */ 1030 int cmd_ zones(cmd_arg_t *argv)1031 { 1032 zones_print_list();1033 return 1; 1034 } 1035 1036 /** Command for memory zone details997 int 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 1037 1004 * 1038 1005 * @param argv Integer argument from cmdline expected 1039 1006 * 1040 * return Always 11041 */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 details1049 *1050 * @param argv Integer argument from cmdline expected1051 *1052 * return Always 11053 */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 task1061 *1062 * @param argv Integer argument from cmdline expected1063 *1064 1007 * return 0 on failure, 1 on success. 1065 1008 */ 1066 int cmd_kill(cmd_arg_t * argv)1009 int cmd_kill(cmd_arg_t * argv) 1067 1010 { 1068 1011 if (task_kill(argv[0].intval) != EOK) … … 1229 1172 } 1230 1173 1231 unsigned int _len = (unsigned int) len;1232 if ((_len != len) || (((int) _len) < 0)) {1233 printf("Command length overflow\n");1234 return;1235 }1236 1237 1174 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, "*"); 1242 1178 } 1243 1179
Note:
See TracChangeset
for help on using the changeset viewer.