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