Rev 4201 | Rev 4420 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4201 | Rev 4296 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | /** @addtogroup genericconsole |
29 | /** @addtogroup genericconsole |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** |
33 | /** |
34 | * @file cmd.c |
34 | * @file cmd.c |
35 | * @brief Kernel console command wrappers. |
35 | * @brief Kernel console command wrappers. |
36 | * |
36 | * |
37 | * This file is meant to contain all wrapper functions for |
37 | * This file is meant to contain all wrapper functions for |
38 | * all kconsole commands. The point is in separating |
38 | * all kconsole commands. The point is in separating |
39 | * kconsole specific wrappers from kconsole-unaware functions |
39 | * kconsole specific wrappers from kconsole-unaware functions |
40 | * from other subsystems. |
40 | * from other subsystems. |
Line 62... | Line 62... | ||
62 | #include <proc/scheduler.h> |
62 | #include <proc/scheduler.h> |
63 | #include <proc/thread.h> |
63 | #include <proc/thread.h> |
64 | #include <proc/task.h> |
64 | #include <proc/task.h> |
65 | #include <ipc/ipc.h> |
65 | #include <ipc/ipc.h> |
66 | #include <ipc/irq.h> |
66 | #include <ipc/irq.h> |
67 | #include <event/event.h> |
67 | #include <ipc/event.h> |
68 | #include <symtab.h> |
68 | #include <symtab.h> |
69 | #include <errno.h> |
69 | #include <errno.h> |
70 | 70 | ||
71 | #ifdef CONFIG_TEST |
71 | #ifdef CONFIG_TEST |
72 | #include <test.h> |
72 | #include <test.h> |
Line 511... | Line 511... | ||
511 | int cmd_help(cmd_arg_t *argv) |
511 | int cmd_help(cmd_arg_t *argv) |
512 | { |
512 | { |
513 | spinlock_lock(&cmd_lock); |
513 | spinlock_lock(&cmd_lock); |
514 | 514 | ||
515 | link_t *cur; |
515 | link_t *cur; |
516 | size_t len = 0; |
516 | count_t len = 0; |
517 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
517 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
518 | cmd_info_t *hlp; |
518 | cmd_info_t *hlp; |
519 | hlp = list_get_instance(cur, cmd_info_t, link); |
519 | hlp = list_get_instance(cur, cmd_info_t, link); |
520 | 520 | ||
521 | spinlock_lock(&hlp->lock); |
521 | spinlock_lock(&hlp->lock); |
522 | if (strlen(hlp->name) > len) |
522 | if (str_length(hlp->name) > len) |
523 | len = strlen(hlp->name); |
523 | len = str_length(hlp->name); |
524 | spinlock_unlock(&hlp->lock); |
524 | spinlock_unlock(&hlp->lock); |
525 | } |
525 | } |
526 | 526 | ||
527 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
527 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
528 | cmd_info_t *hlp; |
528 | cmd_info_t *hlp; |
Line 580... | Line 580... | ||
580 | * @return 0 on failure, 1 on success. |
580 | * @return 0 on failure, 1 on success. |
581 | */ |
581 | */ |
582 | int cmd_desc(cmd_arg_t *argv) |
582 | int cmd_desc(cmd_arg_t *argv) |
583 | { |
583 | { |
584 | link_t *cur; |
584 | link_t *cur; |
585 | 585 | ||
586 | spinlock_lock(&cmd_lock); |
586 | spinlock_lock(&cmd_lock); |
587 | 587 | ||
588 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
588 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
589 | cmd_info_t *hlp; |
589 | cmd_info_t *hlp; |
590 | 590 | ||
591 | hlp = list_get_instance(cur, cmd_info_t, link); |
591 | hlp = list_get_instance(cur, cmd_info_t, link); |
592 | spinlock_lock(&hlp->lock); |
592 | spinlock_lock(&hlp->lock); |
593 | 593 | ||
594 | if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) { |
594 | if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) { |
595 | printf("%s - %s\n", hlp->name, hlp->description); |
595 | printf("%s - %s\n", hlp->name, hlp->description); |
596 | if (hlp->help) |
596 | if (hlp->help) |
597 | hlp->help(); |
597 | hlp->help(); |
598 | spinlock_unlock(&hlp->lock); |
598 | spinlock_unlock(&hlp->lock); |
599 | break; |
599 | break; |
600 | } |
600 | } |
601 | 601 | ||
602 | spinlock_unlock(&hlp->lock); |
602 | spinlock_unlock(&hlp->lock); |
603 | } |
603 | } |
604 | 604 | ||
605 | spinlock_unlock(&cmd_lock); |
605 | spinlock_unlock(&cmd_lock); |
606 | 606 | ||
607 | return 1; |
607 | return 1; |
608 | } |
608 | } |
609 | 609 | ||
610 | /** Search symbol table */ |
610 | /** Search symbol table */ |
611 | int cmd_symaddr(cmd_arg_t *argv) |
611 | int cmd_symaddr(cmd_arg_t *argv) |
Line 967... | Line 967... | ||
967 | * |
967 | * |
968 | * return Always 1. |
968 | * return Always 1. |
969 | */ |
969 | */ |
970 | int cmd_tests(cmd_arg_t *argv) |
970 | int cmd_tests(cmd_arg_t *argv) |
971 | { |
971 | { |
972 | size_t len = 0; |
972 | count_t len = 0; |
973 | test_t *test; |
973 | test_t *test; |
974 | for (test = tests; test->name != NULL; test++) { |
974 | for (test = tests; test->name != NULL; test++) { |
975 | if (strlen(test->name) > len) |
975 | if (str_length(test->name) > len) |
976 | len = strlen(test->name); |
976 | len = str_length(test->name); |
977 | } |
977 | } |
978 | 978 | ||
979 | for (test = tests; test->name != NULL; test++) |
979 | for (test = tests; test->name != NULL; test++) |
980 | printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
980 | printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
981 | 981 | ||
Line 994... | Line 994... | ||
994 | uint64_t t0 = task_get_accounting(TASK); |
994 | uint64_t t0 = task_get_accounting(TASK); |
995 | spinlock_unlock(&TASK->lock); |
995 | spinlock_unlock(&TASK->lock); |
996 | interrupts_restore(ipl); |
996 | interrupts_restore(ipl); |
997 | 997 | ||
998 | /* Execute the test */ |
998 | /* Execute the test */ |
- | 999 | test_quiet = false; |
|
999 | char * ret = test->entry(false); |
1000 | char *ret = test->entry(); |
1000 | 1001 | ||
1001 | /* Update and read thread accounting */ |
1002 | /* Update and read thread accounting */ |
1002 | ipl = interrupts_disable(); |
1003 | ipl = interrupts_disable(); |
1003 | spinlock_lock(&TASK->lock); |
1004 | spinlock_lock(&TASK->lock); |
1004 | uint64_t dt = task_get_accounting(TASK) - t0; |
1005 | uint64_t dt = task_get_accounting(TASK) - t0; |
Line 1046... | Line 1047... | ||
1046 | uint64_t t0 = task_get_accounting(TASK); |
1047 | uint64_t t0 = task_get_accounting(TASK); |
1047 | spinlock_unlock(&TASK->lock); |
1048 | spinlock_unlock(&TASK->lock); |
1048 | interrupts_restore(ipl); |
1049 | interrupts_restore(ipl); |
1049 | 1050 | ||
1050 | /* Execute the test */ |
1051 | /* Execute the test */ |
- | 1052 | test_quiet = true; |
|
1051 | char * ret = test->entry(true); |
1053 | char * ret = test->entry(); |
1052 | 1054 | ||
1053 | /* Update and read thread accounting */ |
1055 | /* Update and read thread accounting */ |
1054 | ipl = interrupts_disable(); |
1056 | ipl = interrupts_disable(); |
1055 | spinlock_lock(&TASK->lock); |
1057 | spinlock_lock(&TASK->lock); |
1056 | uint64_t dt = task_get_accounting(TASK) - t0; |
1058 | uint64_t dt = task_get_accounting(TASK) - t0; |
Line 1094... | Line 1096... | ||
1094 | */ |
1096 | */ |
1095 | int cmd_test(cmd_arg_t *argv) |
1097 | int cmd_test(cmd_arg_t *argv) |
1096 | { |
1098 | { |
1097 | test_t *test; |
1099 | test_t *test; |
1098 | 1100 | ||
1099 | if (strcmp((char *) argv->buffer, "*") == 0) { |
1101 | if (str_cmp((char *) argv->buffer, "*") == 0) { |
1100 | for (test = tests; test->name != NULL; test++) { |
1102 | for (test = tests; test->name != NULL; test++) { |
1101 | if (test->safe) { |
1103 | if (test->safe) { |
1102 | printf("\n"); |
1104 | printf("\n"); |
1103 | if (!run_test(test)) |
1105 | if (!run_test(test)) |
1104 | break; |
1106 | break; |
Line 1106... | Line 1108... | ||
1106 | } |
1108 | } |
1107 | } else { |
1109 | } else { |
1108 | bool fnd = false; |
1110 | bool fnd = false; |
1109 | 1111 | ||
1110 | for (test = tests; test->name != NULL; test++) { |
1112 | for (test = tests; test->name != NULL; test++) { |
1111 | if (strcmp(test->name, (char *) argv->buffer) == 0) { |
1113 | if (str_cmp(test->name, (char *) argv->buffer) == 0) { |
1112 | fnd = true; |
1114 | fnd = true; |
1113 | run_test(test); |
1115 | run_test(test); |
1114 | break; |
1116 | break; |
1115 | } |
1117 | } |
1116 | } |
1118 | } |
Line 1131... | Line 1133... | ||
1131 | int cmd_bench(cmd_arg_t *argv) |
1133 | int cmd_bench(cmd_arg_t *argv) |
1132 | { |
1134 | { |
1133 | test_t *test; |
1135 | test_t *test; |
1134 | uint32_t cnt = argv[1].intval; |
1136 | uint32_t cnt = argv[1].intval; |
1135 | 1137 | ||
1136 | bool fnd = false; |
1138 | if (str_cmp((char *) argv->buffer, "*") == 0) { |
1137 | - | ||
1138 | for (test = tests; test->name != NULL; test++) { |
1139 | for (test = tests; test->name != NULL; test++) { |
1139 | if (strcmp(test->name, (char *) argv->buffer) == 0) { |
- | |
1140 | fnd = true; |
- | |
1141 | - | ||
1142 | if (test->safe) |
1140 | if (test->safe) { |
1143 | run_bench(test, cnt); |
1141 | if (!run_bench(test, cnt)) |
1144 | else |
1142 | break; |
1145 | printf("Unsafe test\n"); |
- | |
1146 | 1143 | } |
|
1147 | break; |
- | |
1148 | } |
1144 | } |
1149 | } |
1145 | } else { |
- | 1146 | bool fnd = false; |
|
1150 | 1147 | ||
- | 1148 | for (test = tests; test->name != NULL; test++) { |
|
- | 1149 | if (str_cmp(test->name, (char *) argv->buffer) == 0) { |
|
- | 1150 | fnd = true; |
|
- | 1151 | ||
- | 1152 | if (test->safe) |
|
- | 1153 | run_bench(test, cnt); |
|
- | 1154 | else |
|
- | 1155 | printf("Unsafe test\n"); |
|
- | 1156 | ||
- | 1157 | break; |
|
- | 1158 | } |
|
- | 1159 | } |
|
- | 1160 | ||
1151 | if (!fnd) |
1161 | if (!fnd) |
1152 | printf("Unknown test\n"); |
1162 | printf("Unknown test\n"); |
- | 1163 | } |
|
1153 | 1164 | ||
1154 | return 1; |
1165 | return 1; |
1155 | } |
1166 | } |
1156 | 1167 | ||
1157 | #endif |
1168 | #endif |
1158 | 1169 |