[442d0ae] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2005 Jakub Jermar
|
---|
[442d0ae] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[06e1e95] | 29 | /** @addtogroup genericconsole
|
---|
[b45c443] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 |
|
---|
[442d0ae] | 33 | /**
|
---|
[cb01e1e] | 34 | * @file cmd.c
|
---|
| 35 | * @brief Kernel console command wrappers.
|
---|
[cf26ba9] | 36 | *
|
---|
[442d0ae] | 37 | * This file is meant to contain all wrapper functions for
|
---|
| 38 | * all kconsole commands. The point is in separating
|
---|
| 39 | * kconsole specific wrappers from kconsole-unaware functions
|
---|
| 40 | * from other subsystems.
|
---|
| 41 | */
|
---|
| 42 |
|
---|
| 43 | #include <console/cmd.h>
|
---|
[41d33ac] | 44 | #include <console/console.h>
|
---|
[442d0ae] | 45 | #include <console/kconsole.h>
|
---|
| 46 | #include <print.h>
|
---|
| 47 | #include <panic.h>
|
---|
[d99c1d2] | 48 | #include <typedefs.h>
|
---|
[5c9a08b] | 49 | #include <adt/list.h>
|
---|
[442d0ae] | 50 | #include <arch.h>
|
---|
[f74bbaf] | 51 | #include <config.h>
|
---|
[442d0ae] | 52 | #include <func.h>
|
---|
[19f857a] | 53 | #include <str.h>
|
---|
[442d0ae] | 54 | #include <macros.h>
|
---|
| 55 | #include <debug.h>
|
---|
[0132630] | 56 | #include <cpu.h>
|
---|
[442d0ae] | 57 | #include <mm/tlb.h>
|
---|
| 58 | #include <arch/mm/tlb.h>
|
---|
[80bff342] | 59 | #include <mm/frame.h>
|
---|
[0132630] | 60 | #include <main/version.h>
|
---|
[4e147a6] | 61 | #include <mm/slab.h>
|
---|
[10e16a7] | 62 | #include <proc/scheduler.h>
|
---|
[55ab0f1] | 63 | #include <proc/thread.h>
|
---|
[37c57f2] | 64 | #include <proc/task.h>
|
---|
[c4e4507] | 65 | #include <ipc/ipc.h>
|
---|
[62939f7] | 66 | #include <ipc/irq.h>
|
---|
[13a638d] | 67 | #include <ipc/event.h>
|
---|
[b3631bc] | 68 | #include <sysinfo/sysinfo.h>
|
---|
[e2b762ec] | 69 | #include <symtab.h>
|
---|
[e16e0d59] | 70 | #include <errno.h>
|
---|
[e2b762ec] | 71 |
|
---|
[319e60e] | 72 | #ifdef CONFIG_TEST
|
---|
| 73 | #include <test.h>
|
---|
| 74 | #endif
|
---|
| 75 |
|
---|
[b45c443] | 76 | /* Data and methods for 'help' command. */
|
---|
[442d0ae] | 77 | static int cmd_help(cmd_arg_t *argv);
|
---|
| 78 | static cmd_info_t help_info = {
|
---|
| 79 | .name = "help",
|
---|
[df58e44] | 80 | .description = "List supported commands.",
|
---|
[442d0ae] | 81 | .func = cmd_help,
|
---|
| 82 | .argc = 0
|
---|
| 83 | };
|
---|
| 84 |
|
---|
[df58e44] | 85 | /* Data and methods for 'reboot' command. */
|
---|
[f74bbaf] | 86 | static int cmd_reboot(cmd_arg_t *argv);
|
---|
| 87 | static cmd_info_t reboot_info = {
|
---|
| 88 | .name = "reboot",
|
---|
[df58e44] | 89 | .description = "Reboot system.",
|
---|
[f74bbaf] | 90 | .func = cmd_reboot,
|
---|
[e07fe0c] | 91 | .argc = 0
|
---|
| 92 | };
|
---|
| 93 |
|
---|
[df58e44] | 94 | /* Data and methods for 'uptime' command. */
|
---|
[4b662f8c] | 95 | static int cmd_uptime(cmd_arg_t *argv);
|
---|
| 96 | static cmd_info_t uptime_info = {
|
---|
| 97 | .name = "uptime",
|
---|
[df58e44] | 98 | .description = "Show system uptime.",
|
---|
[4b662f8c] | 99 | .func = cmd_uptime,
|
---|
| 100 | .argc = 0
|
---|
| 101 | };
|
---|
| 102 |
|
---|
[df58e44] | 103 | /* Data and methods for 'continue' command. */
|
---|
[41d33ac] | 104 | static int cmd_continue(cmd_arg_t *argv);
|
---|
| 105 | static cmd_info_t continue_info = {
|
---|
| 106 | .name = "continue",
|
---|
[319e60e] | 107 | .description = "Return console back to userspace.",
|
---|
[41d33ac] | 108 | .func = cmd_continue,
|
---|
| 109 | .argc = 0
|
---|
| 110 | };
|
---|
| 111 |
|
---|
[319e60e] | 112 | #ifdef CONFIG_TEST
|
---|
[5b7a107] | 113 |
|
---|
[df58e44] | 114 | /* Data and methods for 'test' command. */
|
---|
[319e60e] | 115 | static char test_buf[MAX_CMDLINE + 1];
|
---|
| 116 | static int cmd_test(cmd_arg_t *argv);
|
---|
| 117 | static cmd_arg_t test_argv[] = {
|
---|
| 118 | {
|
---|
[851f33a] | 119 | .type = ARG_TYPE_STRING_OPTIONAL,
|
---|
[319e60e] | 120 | .buffer = test_buf,
|
---|
| 121 | .len = sizeof(test_buf)
|
---|
| 122 | }
|
---|
| 123 | };
|
---|
| 124 | static cmd_info_t test_info = {
|
---|
| 125 | .name = "test",
|
---|
[df58e44] | 126 | .description = "<test> List kernel tests or run a test.",
|
---|
[319e60e] | 127 | .func = cmd_test,
|
---|
| 128 | .argc = 1,
|
---|
| 129 | .argv = test_argv
|
---|
| 130 | };
|
---|
[95155b0c] | 131 |
|
---|
[df58e44] | 132 | /* Data and methods for 'bench' command. */
|
---|
[95155b0c] | 133 | static int cmd_bench(cmd_arg_t *argv);
|
---|
| 134 | static cmd_arg_t bench_argv[] = {
|
---|
| 135 | {
|
---|
| 136 | .type = ARG_TYPE_STRING,
|
---|
| 137 | .buffer = test_buf,
|
---|
| 138 | .len = sizeof(test_buf)
|
---|
| 139 | },
|
---|
| 140 | {
|
---|
| 141 | .type = ARG_TYPE_INT,
|
---|
| 142 | }
|
---|
| 143 | };
|
---|
| 144 | static cmd_info_t bench_info = {
|
---|
| 145 | .name = "bench",
|
---|
[df58e44] | 146 | .description = "<test> <count> Run kernel test as benchmark.",
|
---|
[95155b0c] | 147 | .func = cmd_bench,
|
---|
| 148 | .argc = 2,
|
---|
| 149 | .argv = bench_argv
|
---|
| 150 | };
|
---|
[5b7a107] | 151 |
|
---|
| 152 | #endif /* CONFIG_TEST */
|
---|
[319e60e] | 153 |
|
---|
[b45c443] | 154 | /* Data and methods for 'description' command. */
|
---|
[442d0ae] | 155 | static int cmd_desc(cmd_arg_t *argv);
|
---|
| 156 | static void desc_help(void);
|
---|
[df58e44] | 157 | static char desc_buf[MAX_CMDLINE + 1];
|
---|
[442d0ae] | 158 | static cmd_arg_t desc_argv = {
|
---|
| 159 | .type = ARG_TYPE_STRING,
|
---|
| 160 | .buffer = desc_buf,
|
---|
| 161 | .len = sizeof(desc_buf)
|
---|
| 162 | };
|
---|
| 163 | static cmd_info_t desc_info = {
|
---|
| 164 | .name = "describe",
|
---|
[df58e44] | 165 | .description = "<command> Describe specified command.",
|
---|
[442d0ae] | 166 | .help = desc_help,
|
---|
| 167 | .func = cmd_desc,
|
---|
| 168 | .argc = 1,
|
---|
| 169 | .argv = &desc_argv
|
---|
| 170 | };
|
---|
| 171 |
|
---|
[b45c443] | 172 | /* Data and methods for 'symaddr' command. */
|
---|
[442d0ae] | 173 | static int cmd_symaddr(cmd_arg_t *argv);
|
---|
[df58e44] | 174 | static char symaddr_buf[MAX_CMDLINE + 1];
|
---|
[442d0ae] | 175 | static cmd_arg_t symaddr_argv = {
|
---|
| 176 | .type = ARG_TYPE_STRING,
|
---|
| 177 | .buffer = symaddr_buf,
|
---|
| 178 | .len = sizeof(symaddr_buf)
|
---|
| 179 | };
|
---|
| 180 | static cmd_info_t symaddr_info = {
|
---|
| 181 | .name = "symaddr",
|
---|
[df58e44] | 182 | .description = "<symbol> Return symbol address.",
|
---|
[442d0ae] | 183 | .func = cmd_symaddr,
|
---|
| 184 | .argc = 1,
|
---|
| 185 | .argv = &symaddr_argv
|
---|
| 186 | };
|
---|
| 187 |
|
---|
[df58e44] | 188 | /* Data and methods for 'set4' command. */
|
---|
| 189 | static char set_buf[MAX_CMDLINE + 1];
|
---|
[ba276f7] | 190 | static int cmd_set4(cmd_arg_t *argv);
|
---|
| 191 | static cmd_arg_t set4_argv[] = {
|
---|
| 192 | {
|
---|
| 193 | .type = ARG_TYPE_STRING,
|
---|
| 194 | .buffer = set_buf,
|
---|
| 195 | .len = sizeof(set_buf)
|
---|
| 196 | },
|
---|
| 197 | {
|
---|
| 198 | .type = ARG_TYPE_INT
|
---|
| 199 | }
|
---|
| 200 | };
|
---|
| 201 | static cmd_info_t set4_info = {
|
---|
| 202 | .name = "set4",
|
---|
[df58e44] | 203 | .description = "<addr> <value> Set 4B memory location to a value.",
|
---|
[ba276f7] | 204 | .func = cmd_set4,
|
---|
| 205 | .argc = 2,
|
---|
| 206 | .argv = set4_argv
|
---|
| 207 | };
|
---|
| 208 |
|
---|
[c0f13d2] | 209 | /* Data and methods for 'call0' and 'mcall0' command. */
|
---|
[e5dbbe5] | 210 | static char call0_buf[MAX_CMDLINE + 1];
|
---|
| 211 | static char carg1_buf[MAX_CMDLINE + 1];
|
---|
| 212 | static char carg2_buf[MAX_CMDLINE + 1];
|
---|
| 213 | static char carg3_buf[MAX_CMDLINE + 1];
|
---|
[442d0ae] | 214 |
|
---|
| 215 | static int cmd_call0(cmd_arg_t *argv);
|
---|
| 216 | static cmd_arg_t call0_argv = {
|
---|
| 217 | .type = ARG_TYPE_STRING,
|
---|
| 218 | .buffer = call0_buf,
|
---|
| 219 | .len = sizeof(call0_buf)
|
---|
| 220 | };
|
---|
| 221 | static cmd_info_t call0_info = {
|
---|
| 222 | .name = "call0",
|
---|
[df58e44] | 223 | .description = "<function> Call function().",
|
---|
[442d0ae] | 224 | .func = cmd_call0,
|
---|
| 225 | .argc = 1,
|
---|
| 226 | .argv = &call0_argv
|
---|
| 227 | };
|
---|
| 228 |
|
---|
[e5dbbe5] | 229 | /* Data and methods for 'mcall0' command. */
|
---|
| 230 | static int cmd_mcall0(cmd_arg_t *argv);
|
---|
| 231 | static cmd_arg_t mcall0_argv = {
|
---|
| 232 | .type = ARG_TYPE_STRING,
|
---|
| 233 | .buffer = call0_buf,
|
---|
| 234 | .len = sizeof(call0_buf)
|
---|
| 235 | };
|
---|
| 236 | static cmd_info_t mcall0_info = {
|
---|
| 237 | .name = "mcall0",
|
---|
[df58e44] | 238 | .description = "<function> Call function() on each CPU.",
|
---|
[e5dbbe5] | 239 | .func = cmd_mcall0,
|
---|
| 240 | .argc = 1,
|
---|
| 241 | .argv = &mcall0_argv
|
---|
| 242 | };
|
---|
| 243 |
|
---|
[b45c443] | 244 | /* Data and methods for 'call1' command. */
|
---|
[442d0ae] | 245 | static int cmd_call1(cmd_arg_t *argv);
|
---|
| 246 | static cmd_arg_t call1_argv[] = {
|
---|
| 247 | {
|
---|
| 248 | .type = ARG_TYPE_STRING,
|
---|
| 249 | .buffer = call0_buf,
|
---|
| 250 | .len = sizeof(call0_buf)
|
---|
| 251 | },
|
---|
| 252 | {
|
---|
| 253 | .type = ARG_TYPE_VAR,
|
---|
| 254 | .buffer = carg1_buf,
|
---|
| 255 | .len = sizeof(carg1_buf)
|
---|
| 256 | }
|
---|
| 257 | };
|
---|
| 258 | static cmd_info_t call1_info = {
|
---|
| 259 | .name = "call1",
|
---|
[df58e44] | 260 | .description = "<function> <arg1> Call function(arg1).",
|
---|
[442d0ae] | 261 | .func = cmd_call1,
|
---|
| 262 | .argc = 2,
|
---|
| 263 | .argv = call1_argv
|
---|
| 264 | };
|
---|
| 265 |
|
---|
[b45c443] | 266 | /* Data and methods for 'call2' command. */
|
---|
[442d0ae] | 267 | static int cmd_call2(cmd_arg_t *argv);
|
---|
| 268 | static cmd_arg_t call2_argv[] = {
|
---|
| 269 | {
|
---|
| 270 | .type = ARG_TYPE_STRING,
|
---|
| 271 | .buffer = call0_buf,
|
---|
| 272 | .len = sizeof(call0_buf)
|
---|
| 273 | },
|
---|
| 274 | {
|
---|
| 275 | .type = ARG_TYPE_VAR,
|
---|
| 276 | .buffer = carg1_buf,
|
---|
| 277 | .len = sizeof(carg1_buf)
|
---|
| 278 | },
|
---|
| 279 | {
|
---|
| 280 | .type = ARG_TYPE_VAR,
|
---|
| 281 | .buffer = carg2_buf,
|
---|
| 282 | .len = sizeof(carg2_buf)
|
---|
| 283 | }
|
---|
| 284 | };
|
---|
| 285 | static cmd_info_t call2_info = {
|
---|
| 286 | .name = "call2",
|
---|
[df58e44] | 287 | .description = "<function> <arg1> <arg2> Call function(arg1, arg2).",
|
---|
[442d0ae] | 288 | .func = cmd_call2,
|
---|
| 289 | .argc = 3,
|
---|
| 290 | .argv = call2_argv
|
---|
| 291 | };
|
---|
| 292 |
|
---|
[b45c443] | 293 | /* Data and methods for 'call3' command. */
|
---|
[442d0ae] | 294 | static int cmd_call3(cmd_arg_t *argv);
|
---|
| 295 | static cmd_arg_t call3_argv[] = {
|
---|
| 296 | {
|
---|
| 297 | .type = ARG_TYPE_STRING,
|
---|
| 298 | .buffer = call0_buf,
|
---|
| 299 | .len = sizeof(call0_buf)
|
---|
| 300 | },
|
---|
| 301 | {
|
---|
| 302 | .type = ARG_TYPE_VAR,
|
---|
| 303 | .buffer = carg1_buf,
|
---|
| 304 | .len = sizeof(carg1_buf)
|
---|
| 305 | },
|
---|
| 306 | {
|
---|
| 307 | .type = ARG_TYPE_VAR,
|
---|
| 308 | .buffer = carg2_buf,
|
---|
| 309 | .len = sizeof(carg2_buf)
|
---|
| 310 | },
|
---|
| 311 | {
|
---|
| 312 | .type = ARG_TYPE_VAR,
|
---|
| 313 | .buffer = carg3_buf,
|
---|
| 314 | .len = sizeof(carg3_buf)
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 | };
|
---|
| 318 | static cmd_info_t call3_info = {
|
---|
| 319 | .name = "call3",
|
---|
[df58e44] | 320 | .description = "<function> <arg1> <arg2> <arg3> Call function(arg1, arg2, arg3).",
|
---|
[442d0ae] | 321 | .func = cmd_call3,
|
---|
| 322 | .argc = 4,
|
---|
| 323 | .argv = call3_argv
|
---|
| 324 | };
|
---|
| 325 |
|
---|
[b45c443] | 326 | /* Data and methods for 'halt' command. */
|
---|
[442d0ae] | 327 | static int cmd_halt(cmd_arg_t *argv);
|
---|
| 328 | static cmd_info_t halt_info = {
|
---|
| 329 | .name = "halt",
|
---|
| 330 | .description = "Halt the kernel.",
|
---|
| 331 | .func = cmd_halt,
|
---|
| 332 | .argc = 0
|
---|
| 333 | };
|
---|
| 334 |
|
---|
[b07c332] | 335 | /* Data and methods for 'physmem' command. */
|
---|
| 336 | static int cmd_physmem(cmd_arg_t *argv);
|
---|
| 337 | cmd_info_t physmem_info = {
|
---|
| 338 | .name = "physmem",
|
---|
| 339 | .description = "Print physical memory configuration.",
|
---|
| 340 | .help = NULL,
|
---|
| 341 | .func = cmd_physmem,
|
---|
| 342 | .argc = 0,
|
---|
| 343 | .argv = NULL
|
---|
| 344 | };
|
---|
| 345 |
|
---|
[b45c443] | 346 | /* Data and methods for 'tlb' command. */
|
---|
[0132630] | 347 | static int cmd_tlb(cmd_arg_t *argv);
|
---|
| 348 | cmd_info_t tlb_info = {
|
---|
| 349 | .name = "tlb",
|
---|
[df58e44] | 350 | .description = "Print TLB of the current CPU.",
|
---|
[442d0ae] | 351 | .help = NULL,
|
---|
[0132630] | 352 | .func = cmd_tlb,
|
---|
[442d0ae] | 353 | .argc = 0,
|
---|
| 354 | .argv = NULL
|
---|
| 355 | };
|
---|
| 356 |
|
---|
[48dcc69] | 357 | static char flag_buf[MAX_CMDLINE + 1];
|
---|
| 358 |
|
---|
[55ab0f1] | 359 | static int cmd_threads(cmd_arg_t *argv);
|
---|
[48dcc69] | 360 | static cmd_arg_t threads_argv = {
|
---|
| 361 | .type = ARG_TYPE_STRING_OPTIONAL,
|
---|
| 362 | .buffer = flag_buf,
|
---|
| 363 | .len = sizeof(flag_buf)
|
---|
| 364 | };
|
---|
[55ab0f1] | 365 | static cmd_info_t threads_info = {
|
---|
| 366 | .name = "threads",
|
---|
[48dcc69] | 367 | .description = "List all threads (use -a for additional information).",
|
---|
[55ab0f1] | 368 | .func = cmd_threads,
|
---|
[48dcc69] | 369 | .argc = 1,
|
---|
| 370 | .argv = &threads_argv
|
---|
[55ab0f1] | 371 | };
|
---|
| 372 |
|
---|
[37c57f2] | 373 | static int cmd_tasks(cmd_arg_t *argv);
|
---|
[c0f13d2] | 374 | static cmd_arg_t tasks_argv = {
|
---|
| 375 | .type = ARG_TYPE_STRING_OPTIONAL,
|
---|
[48dcc69] | 376 | .buffer = flag_buf,
|
---|
| 377 | .len = sizeof(flag_buf)
|
---|
[c0f13d2] | 378 | };
|
---|
[37c57f2] | 379 | static cmd_info_t tasks_info = {
|
---|
| 380 | .name = "tasks",
|
---|
[c0f13d2] | 381 | .description = "List all tasks (use -a for additional information).",
|
---|
[37c57f2] | 382 | .func = cmd_tasks,
|
---|
[c0f13d2] | 383 | .argc = 1,
|
---|
| 384 | .argv = &tasks_argv
|
---|
[37c57f2] | 385 | };
|
---|
| 386 |
|
---|
[5b7a107] | 387 | #ifdef CONFIG_UDEBUG
|
---|
| 388 |
|
---|
[df58e44] | 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 | };
|
---|
[80bff342] | 401 |
|
---|
[5b7a107] | 402 | #endif /* CONFIG_UDEBUG */
|
---|
[80bff342] | 403 |
|
---|
[10e16a7] | 404 | static int cmd_sched(cmd_arg_t *argv);
|
---|
| 405 | static cmd_info_t sched_info = {
|
---|
| 406 | .name = "scheduler",
|
---|
[df58e44] | 407 | .description = "Show scheduler information.",
|
---|
[10e16a7] | 408 | .func = cmd_sched,
|
---|
| 409 | .argc = 0
|
---|
| 410 | };
|
---|
| 411 |
|
---|
[4e147a6] | 412 | static int cmd_slabs(cmd_arg_t *argv);
|
---|
| 413 | static cmd_info_t slabs_info = {
|
---|
| 414 | .name = "slabs",
|
---|
[dd054bc2] | 415 | .description = "List slab caches.",
|
---|
[4e147a6] | 416 | .func = cmd_slabs,
|
---|
| 417 | .argc = 0
|
---|
| 418 | };
|
---|
| 419 |
|
---|
[b3631bc] | 420 | static int cmd_sysinfo(cmd_arg_t *argv);
|
---|
| 421 | static cmd_info_t sysinfo_info = {
|
---|
| 422 | .name = "sysinfo",
|
---|
| 423 | .description = "Dump sysinfo.",
|
---|
| 424 | .func = cmd_sysinfo,
|
---|
| 425 | .argc = 0
|
---|
| 426 | };
|
---|
| 427 |
|
---|
[b45c443] | 428 | /* Data and methods for 'zones' command */
|
---|
[80bff342] | 429 | static int cmd_zones(cmd_arg_t *argv);
|
---|
| 430 | static cmd_info_t zones_info = {
|
---|
| 431 | .name = "zones",
|
---|
[df58e44] | 432 | .description = "List memory zones.",
|
---|
[80bff342] | 433 | .func = cmd_zones,
|
---|
| 434 | .argc = 0
|
---|
| 435 | };
|
---|
| 436 |
|
---|
[df58e44] | 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
|
---|
| 449 | };
|
---|
| 450 |
|
---|
[073c9e6] | 451 | /* Data and methods for 'ipc' command */
|
---|
| 452 | static int cmd_ipc(cmd_arg_t *argv);
|
---|
| 453 | static cmd_arg_t ipc_argv = {
|
---|
[c4e4507] | 454 | .type = ARG_TYPE_INT,
|
---|
| 455 | };
|
---|
[073c9e6] | 456 | static cmd_info_t ipc_info = {
|
---|
| 457 | .name = "ipc",
|
---|
[df58e44] | 458 | .description = "<taskid> Show IPC information of a task.",
|
---|
[073c9e6] | 459 | .func = cmd_ipc,
|
---|
[c4e4507] | 460 | .argc = 1,
|
---|
[073c9e6] | 461 | .argv = &ipc_argv
|
---|
[c4e4507] | 462 | };
|
---|
| 463 |
|
---|
[2a75302] | 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",
|
---|
[df58e44] | 471 | .description = "<taskid> Kill a task.",
|
---|
[2a75302] | 472 | .func = cmd_kill,
|
---|
| 473 | .argc = 1,
|
---|
| 474 | .argv = &kill_argv
|
---|
| 475 | };
|
---|
| 476 |
|
---|
[b45c443] | 477 | /* Data and methods for 'cpus' command. */
|
---|
[0132630] | 478 | static int cmd_cpus(cmd_arg_t *argv);
|
---|
| 479 | cmd_info_t cpus_info = {
|
---|
| 480 | .name = "cpus",
|
---|
| 481 | .description = "List all processors.",
|
---|
| 482 | .help = NULL,
|
---|
| 483 | .func = cmd_cpus,
|
---|
| 484 | .argc = 0,
|
---|
| 485 | .argv = NULL
|
---|
| 486 | };
|
---|
| 487 |
|
---|
[b45c443] | 488 | /* Data and methods for 'version' command. */
|
---|
[0132630] | 489 | static int cmd_version(cmd_arg_t *argv);
|
---|
| 490 | cmd_info_t version_info = {
|
---|
| 491 | .name = "version",
|
---|
| 492 | .description = "Print version information.",
|
---|
| 493 | .help = NULL,
|
---|
| 494 | .func = cmd_version,
|
---|
| 495 | .argc = 0,
|
---|
| 496 | .argv = NULL
|
---|
| 497 | };
|
---|
| 498 |
|
---|
[10e16a7] | 499 | static cmd_info_t *basic_commands[] = {
|
---|
| 500 | &call0_info,
|
---|
[e5dbbe5] | 501 | &mcall0_info,
|
---|
[10e16a7] | 502 | &call1_info,
|
---|
| 503 | &call2_info,
|
---|
| 504 | &call3_info,
|
---|
[41d33ac] | 505 | &continue_info,
|
---|
[10e16a7] | 506 | &cpus_info,
|
---|
| 507 | &desc_info,
|
---|
| 508 | &halt_info,
|
---|
| 509 | &help_info,
|
---|
[073c9e6] | 510 | &ipc_info,
|
---|
[2a75302] | 511 | &kill_info,
|
---|
[df58e44] | 512 | &physmem_info,
|
---|
| 513 | &reboot_info,
|
---|
| 514 | &sched_info,
|
---|
[10e16a7] | 515 | &set4_info,
|
---|
| 516 | &slabs_info,
|
---|
| 517 | &symaddr_info,
|
---|
[df58e44] | 518 | &sysinfo_info,
|
---|
[37c57f2] | 519 | &tasks_info,
|
---|
[df58e44] | 520 | &threads_info,
|
---|
[10e16a7] | 521 | &tlb_info,
|
---|
[df58e44] | 522 | &uptime_info,
|
---|
[10e16a7] | 523 | &version_info,
|
---|
| 524 | &zones_info,
|
---|
| 525 | &zone_info,
|
---|
[319e60e] | 526 | #ifdef CONFIG_TEST
|
---|
| 527 | &test_info,
|
---|
[95155b0c] | 528 | &bench_info,
|
---|
[5b7a107] | 529 | #endif
|
---|
| 530 | #ifdef CONFIG_UDEBUG
|
---|
| 531 | &btrace_info,
|
---|
[319e60e] | 532 | #endif
|
---|
[10e16a7] | 533 | NULL
|
---|
| 534 | };
|
---|
[80bff342] | 535 |
|
---|
| 536 |
|
---|
[442d0ae] | 537 | /** Initialize command info structure.
|
---|
| 538 | *
|
---|
| 539 | * @param cmd Command info structure.
|
---|
| 540 | *
|
---|
| 541 | */
|
---|
| 542 | void cmd_initialize(cmd_info_t *cmd)
|
---|
| 543 | {
|
---|
[da1bafb] | 544 | spinlock_initialize(&cmd->lock, "cmd.lock");
|
---|
[442d0ae] | 545 | link_initialize(&cmd->link);
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /** Initialize and register commands. */
|
---|
| 549 | void cmd_init(void)
|
---|
| 550 | {
|
---|
[b07c332] | 551 | unsigned int i;
|
---|
[80bff342] | 552 |
|
---|
[b07c332] | 553 | for (i = 0; basic_commands[i]; i++) {
|
---|
[10e16a7] | 554 | cmd_initialize(basic_commands[i]);
|
---|
[40fb017] | 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 | }
|
---|
[10e16a7] | 562 | }
|
---|
[442d0ae] | 563 | }
|
---|
| 564 |
|
---|
| 565 | /** List supported commands.
|
---|
| 566 | *
|
---|
| 567 | * @param argv Argument vector.
|
---|
| 568 | *
|
---|
| 569 | * @return 0 on failure, 1 on success.
|
---|
| 570 | */
|
---|
| 571 | int cmd_help(cmd_arg_t *argv)
|
---|
| 572 | {
|
---|
| 573 | spinlock_lock(&cmd_lock);
|
---|
| 574 |
|
---|
[c1f7f6ea] | 575 | link_t *cur;
|
---|
[98000fb] | 576 | size_t len = 0;
|
---|
[442d0ae] | 577 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
|
---|
| 578 | cmd_info_t *hlp;
|
---|
| 579 | hlp = list_get_instance(cur, cmd_info_t, link);
|
---|
[c1f7f6ea] | 580 |
|
---|
[442d0ae] | 581 | spinlock_lock(&hlp->lock);
|
---|
[20cc877] | 582 | if (str_length(hlp->name) > len)
|
---|
| 583 | len = str_length(hlp->name);
|
---|
[c1f7f6ea] | 584 | spinlock_unlock(&hlp->lock);
|
---|
| 585 | }
|
---|
| 586 |
|
---|
[0b0f4bb] | 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 |
|
---|
[c1f7f6ea] | 593 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
|
---|
| 594 | cmd_info_t *hlp;
|
---|
| 595 | hlp = list_get_instance(cur, cmd_info_t, link);
|
---|
[442d0ae] | 596 |
|
---|
[c1f7f6ea] | 597 | spinlock_lock(&hlp->lock);
|
---|
[0b0f4bb] | 598 | printf("%-*s %s\n", _len, hlp->name, hlp->description);
|
---|
[442d0ae] | 599 | spinlock_unlock(&hlp->lock);
|
---|
| 600 | }
|
---|
| 601 |
|
---|
[ae318d3] | 602 | spinlock_unlock(&cmd_lock);
|
---|
[c1f7f6ea] | 603 |
|
---|
[442d0ae] | 604 | return 1;
|
---|
| 605 | }
|
---|
| 606 |
|
---|
[f74bbaf] | 607 | /** Reboot the system.
|
---|
| 608 | *
|
---|
| 609 | * @param argv Argument vector.
|
---|
| 610 | *
|
---|
| 611 | * @return 0 on failure, 1 on success.
|
---|
| 612 | */
|
---|
| 613 | int cmd_reboot(cmd_arg_t *argv)
|
---|
| 614 | {
|
---|
| 615 | reboot();
|
---|
| 616 |
|
---|
| 617 | /* Not reached */
|
---|
| 618 | return 1;
|
---|
| 619 | }
|
---|
| 620 |
|
---|
[4b662f8c] | 621 | /** Print system uptime information.
|
---|
| 622 | *
|
---|
| 623 | * @param argv Argument vector.
|
---|
| 624 | *
|
---|
| 625 | * @return 0 on failure, 1 on success.
|
---|
| 626 | */
|
---|
| 627 | int cmd_uptime(cmd_arg_t *argv)
|
---|
| 628 | {
|
---|
| 629 | ASSERT(uptime);
|
---|
| 630 |
|
---|
| 631 | /* This doesn't have to be very accurate */
|
---|
[96b02eb9] | 632 | sysarg_t sec = uptime->seconds1;
|
---|
[4b662f8c] | 633 |
|
---|
[c859753] | 634 | printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
|
---|
[4b662f8c] | 635 | sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
|
---|
| 636 |
|
---|
| 637 | return 1;
|
---|
| 638 | }
|
---|
| 639 |
|
---|
[442d0ae] | 640 | /** Describe specified command.
|
---|
| 641 | *
|
---|
| 642 | * @param argv Argument vector.
|
---|
| 643 | *
|
---|
| 644 | * @return 0 on failure, 1 on success.
|
---|
| 645 | */
|
---|
| 646 | int cmd_desc(cmd_arg_t *argv)
|
---|
| 647 | {
|
---|
| 648 | link_t *cur;
|
---|
[20cc877] | 649 |
|
---|
[442d0ae] | 650 | spinlock_lock(&cmd_lock);
|
---|
| 651 |
|
---|
| 652 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
|
---|
| 653 | cmd_info_t *hlp;
|
---|
| 654 |
|
---|
| 655 | hlp = list_get_instance(cur, cmd_info_t, link);
|
---|
| 656 | spinlock_lock(&hlp->lock);
|
---|
[20cc877] | 657 |
|
---|
| 658 | if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) {
|
---|
[442d0ae] | 659 | printf("%s - %s\n", hlp->name, hlp->description);
|
---|
| 660 | if (hlp->help)
|
---|
| 661 | hlp->help();
|
---|
| 662 | spinlock_unlock(&hlp->lock);
|
---|
| 663 | break;
|
---|
| 664 | }
|
---|
[20cc877] | 665 |
|
---|
[442d0ae] | 666 | spinlock_unlock(&hlp->lock);
|
---|
| 667 | }
|
---|
| 668 |
|
---|
| 669 | spinlock_unlock(&cmd_lock);
|
---|
[20cc877] | 670 |
|
---|
[442d0ae] | 671 | return 1;
|
---|
| 672 | }
|
---|
| 673 |
|
---|
| 674 | /** Search symbol table */
|
---|
| 675 | int cmd_symaddr(cmd_arg_t *argv)
|
---|
| 676 | {
|
---|
[828aa05] | 677 | symtab_print_search((char *) argv->buffer);
|
---|
[442d0ae] | 678 |
|
---|
| 679 | return 1;
|
---|
| 680 | }
|
---|
| 681 |
|
---|
| 682 | /** Call function with zero parameters */
|
---|
| 683 | int cmd_call0(cmd_arg_t *argv)
|
---|
| 684 | {
|
---|
[7f1c620] | 685 | uintptr_t symaddr;
|
---|
[e16e0d59] | 686 | char *symbol;
|
---|
[96b02eb9] | 687 | sysarg_t (*fnc)(void);
|
---|
[0f81ceb7] | 688 | fncptr_t fptr;
|
---|
[e16e0d59] | 689 | int rc;
|
---|
[e2b762ec] | 690 |
|
---|
[e16e0d59] | 691 | symbol = (char *) argv->buffer;
|
---|
| 692 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 693 |
|
---|
| 694 | if (rc == ENOENT)
|
---|
| 695 | printf("Symbol %s not found.\n", symbol);
|
---|
| 696 | else if (rc == EOVERFLOW) {
|
---|
| 697 | symtab_print_search(symbol);
|
---|
[442d0ae] | 698 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 699 | } else if (rc == EOK) {
|
---|
[c992538a] | 700 | ipl_t ipl;
|
---|
| 701 |
|
---|
| 702 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 703 | fnc = (sysarg_t (*)(void)) arch_construct_function(&fptr,
|
---|
[e16e0d59] | 704 | (void *) symaddr, (void *) cmd_call0);
|
---|
[0b0f4bb] | 705 | printf("Calling %s() (%p)\n", symbol, (void *) symaddr);
|
---|
[0f81ceb7] | 706 | printf("Result: %#" PRIxn "\n", fnc());
|
---|
[c992538a] | 707 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 708 | } else {
|
---|
| 709 | printf("No symbol information available.\n");
|
---|
[442d0ae] | 710 | }
|
---|
| 711 | return 1;
|
---|
| 712 | }
|
---|
| 713 |
|
---|
[e5dbbe5] | 714 | /** Call function with zero parameters on each CPU */
|
---|
| 715 | int cmd_mcall0(cmd_arg_t *argv)
|
---|
| 716 | {
|
---|
| 717 | /*
|
---|
| 718 | * For each CPU, create a thread which will
|
---|
| 719 | * call the function.
|
---|
| 720 | */
|
---|
| 721 |
|
---|
[0b0f4bb] | 722 | unsigned int i;
|
---|
[e5dbbe5] | 723 | for (i = 0; i < config.cpu_count; i++) {
|
---|
[b8f11baa] | 724 | if (!cpus[i].active)
|
---|
| 725 | continue;
|
---|
| 726 |
|
---|
[da1bafb] | 727 | thread_t *thread;
|
---|
| 728 | if ((thread = thread_create((void (*)(void *)) cmd_call0,
|
---|
| 729 | (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) {
|
---|
| 730 | irq_spinlock_lock(&thread->lock, true);
|
---|
| 731 | thread->cpu = &cpus[i];
|
---|
| 732 | irq_spinlock_unlock(&thread->lock, true);
|
---|
| 733 |
|
---|
[0b0f4bb] | 734 | printf("cpu%u: ", i);
|
---|
[da1bafb] | 735 |
|
---|
| 736 | thread_ready(thread);
|
---|
| 737 | thread_join(thread);
|
---|
| 738 | thread_detach(thread);
|
---|
[e5dbbe5] | 739 | } else
|
---|
[0b0f4bb] | 740 | printf("Unable to create thread for cpu%u\n", i);
|
---|
[e5dbbe5] | 741 | }
|
---|
| 742 |
|
---|
| 743 | return 1;
|
---|
| 744 | }
|
---|
| 745 |
|
---|
[442d0ae] | 746 | /** Call function with one parameter */
|
---|
| 747 | int cmd_call1(cmd_arg_t *argv)
|
---|
| 748 | {
|
---|
[7f1c620] | 749 | uintptr_t symaddr;
|
---|
[442d0ae] | 750 | char *symbol;
|
---|
[96b02eb9] | 751 | sysarg_t (*fnc)(sysarg_t, ...);
|
---|
| 752 | sysarg_t arg1 = argv[1].intval;
|
---|
[0f81ceb7] | 753 | fncptr_t fptr;
|
---|
[e16e0d59] | 754 | int rc;
|
---|
[e2b762ec] | 755 |
|
---|
[e16e0d59] | 756 | symbol = (char *) argv->buffer;
|
---|
| 757 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 758 |
|
---|
| 759 | if (rc == ENOENT) {
|
---|
| 760 | printf("Symbol %s not found.\n", symbol);
|
---|
| 761 | } else if (rc == EOVERFLOW) {
|
---|
| 762 | symtab_print_search(symbol);
|
---|
[442d0ae] | 763 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 764 | } else if (rc == EOK) {
|
---|
[c992538a] | 765 | ipl_t ipl;
|
---|
| 766 |
|
---|
| 767 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 768 | fnc = (sysarg_t (*)(sysarg_t, ...))
|
---|
[0b0f4bb] | 769 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
| 770 | (void *) cmd_call1);
|
---|
| 771 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1,
|
---|
| 772 | (void *) symaddr, symbol);
|
---|
[0f81ceb7] | 773 | printf("Result: %#" PRIxn "\n", fnc(arg1));
|
---|
[c992538a] | 774 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 775 | } else {
|
---|
| 776 | printf("No symbol information available.\n");
|
---|
[442d0ae] | 777 | }
|
---|
[e16e0d59] | 778 |
|
---|
[442d0ae] | 779 | return 1;
|
---|
| 780 | }
|
---|
| 781 |
|
---|
| 782 | /** Call function with two parameters */
|
---|
| 783 | int cmd_call2(cmd_arg_t *argv)
|
---|
| 784 | {
|
---|
[7f1c620] | 785 | uintptr_t symaddr;
|
---|
[442d0ae] | 786 | char *symbol;
|
---|
[96b02eb9] | 787 | sysarg_t (*fnc)(sysarg_t, sysarg_t, ...);
|
---|
| 788 | sysarg_t arg1 = argv[1].intval;
|
---|
| 789 | sysarg_t arg2 = argv[2].intval;
|
---|
[0f81ceb7] | 790 | fncptr_t fptr;
|
---|
[e16e0d59] | 791 | int rc;
|
---|
| 792 |
|
---|
| 793 | symbol = (char *) argv->buffer;
|
---|
| 794 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 795 |
|
---|
| 796 | if (rc == ENOENT) {
|
---|
| 797 | printf("Symbol %s not found.\n", symbol);
|
---|
| 798 | } else if (rc == EOVERFLOW) {
|
---|
| 799 | symtab_print_search(symbol);
|
---|
[442d0ae] | 800 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 801 | } else if (rc == EOK) {
|
---|
[c992538a] | 802 | ipl_t ipl;
|
---|
| 803 |
|
---|
| 804 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 805 | fnc = (sysarg_t (*)(sysarg_t, sysarg_t, ...))
|
---|
[0b0f4bb] | 806 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
| 807 | (void *) cmd_call2);
|
---|
[c859753] | 808 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
|
---|
[0b0f4bb] | 809 | arg1, arg2, (void *) symaddr, symbol);
|
---|
[0f81ceb7] | 810 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
|
---|
[c992538a] | 811 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 812 | } else {
|
---|
| 813 | printf("No symbol information available.\n");
|
---|
| 814 | }
|
---|
[442d0ae] | 815 | return 1;
|
---|
| 816 | }
|
---|
| 817 |
|
---|
| 818 | /** Call function with three parameters */
|
---|
| 819 | int cmd_call3(cmd_arg_t *argv)
|
---|
| 820 | {
|
---|
[7f1c620] | 821 | uintptr_t symaddr;
|
---|
[442d0ae] | 822 | char *symbol;
|
---|
[96b02eb9] | 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;
|
---|
[0f81ceb7] | 827 | fncptr_t fptr;
|
---|
[e16e0d59] | 828 | int rc;
|
---|
[0f81ceb7] | 829 |
|
---|
[e16e0d59] | 830 | symbol = (char *) argv->buffer;
|
---|
| 831 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 832 |
|
---|
| 833 | if (rc == ENOENT) {
|
---|
| 834 | printf("Symbol %s not found.\n", symbol);
|
---|
| 835 | } else if (rc == EOVERFLOW) {
|
---|
| 836 | symtab_print_search(symbol);
|
---|
[442d0ae] | 837 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 838 | } else if (rc == EOK) {
|
---|
[c992538a] | 839 | ipl_t ipl;
|
---|
| 840 |
|
---|
| 841 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 842 | fnc = (sysarg_t (*)(sysarg_t, sysarg_t, sysarg_t, ...))
|
---|
[0b0f4bb] | 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);
|
---|
[0f81ceb7] | 847 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
|
---|
[c992538a] | 848 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 849 | } else {
|
---|
| 850 | printf("No symbol information available.\n");
|
---|
[442d0ae] | 851 | }
|
---|
| 852 | return 1;
|
---|
| 853 | }
|
---|
| 854 |
|
---|
| 855 | /** Print detailed description of 'describe' command. */
|
---|
| 856 | void desc_help(void)
|
---|
| 857 | {
|
---|
| 858 | printf("Syntax: describe command_name\n");
|
---|
| 859 | }
|
---|
| 860 |
|
---|
| 861 | /** Halt the kernel.
|
---|
| 862 | *
|
---|
| 863 | * @param argv Argument vector (ignored).
|
---|
| 864 | *
|
---|
| 865 | * @return 0 on failure, 1 on success (never returns).
|
---|
| 866 | */
|
---|
| 867 | int cmd_halt(cmd_arg_t *argv)
|
---|
| 868 | {
|
---|
| 869 | halt();
|
---|
| 870 | return 1;
|
---|
| 871 | }
|
---|
| 872 |
|
---|
| 873 | /** Command for printing TLB contents.
|
---|
| 874 | *
|
---|
| 875 | * @param argv Not used.
|
---|
| 876 | *
|
---|
| 877 | * @return Always returns 1.
|
---|
| 878 | */
|
---|
[0132630] | 879 | int cmd_tlb(cmd_arg_t *argv)
|
---|
[442d0ae] | 880 | {
|
---|
| 881 | tlb_print();
|
---|
| 882 | return 1;
|
---|
| 883 | }
|
---|
[ba276f7] | 884 |
|
---|
[b07c332] | 885 | /** Command for printing physical memory configuration.
|
---|
| 886 | *
|
---|
| 887 | * @param argv Not used.
|
---|
| 888 | *
|
---|
| 889 | * @return Always returns 1.
|
---|
| 890 | */
|
---|
| 891 | int cmd_physmem(cmd_arg_t *argv)
|
---|
| 892 | {
|
---|
| 893 | physmem_print();
|
---|
| 894 | return 1;
|
---|
| 895 | }
|
---|
| 896 |
|
---|
[ba276f7] | 897 | /** Write 4 byte value to address */
|
---|
| 898 | int cmd_set4(cmd_arg_t *argv)
|
---|
| 899 | {
|
---|
[e16e0d59] | 900 | uintptr_t addr;
|
---|
[7f1c620] | 901 | uint32_t arg1 = argv[1].intval;
|
---|
[ba276f7] | 902 | bool pointer = false;
|
---|
[e16e0d59] | 903 | int rc;
|
---|
[4ce914d4] | 904 |
|
---|
| 905 | if (((char *) argv->buffer)[0] == '*') {
|
---|
[e16e0d59] | 906 | rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr);
|
---|
[ba276f7] | 907 | pointer = true;
|
---|
[4ce914d4] | 908 | } else if (((char *) argv->buffer)[0] >= '0' &&
|
---|
| 909 | ((char *) argv->buffer)[0] <= '9') {
|
---|
| 910 | uint64_t value;
|
---|
| 911 | rc = str_uint64((char *) argv->buffer, NULL, 0, true, &value);
|
---|
| 912 | if (rc == EOK)
|
---|
| 913 | addr = (uintptr_t) value;
|
---|
| 914 | } else
|
---|
[e16e0d59] | 915 | rc = symtab_addr_lookup((char *) argv->buffer, &addr);
|
---|
[4ce914d4] | 916 |
|
---|
[e16e0d59] | 917 | if (rc == ENOENT)
|
---|
[0b0f4bb] | 918 | printf("Symbol %s not found.\n", (char *) argv->buffer);
|
---|
[4ce914d4] | 919 | else if (rc == EINVAL)
|
---|
| 920 | printf("Invalid address.\n");
|
---|
[e16e0d59] | 921 | else if (rc == EOVERFLOW) {
|
---|
[828aa05] | 922 | symtab_print_search((char *) argv->buffer);
|
---|
[4ce914d4] | 923 | printf("Duplicate symbol (be more specific) or address overflow.\n");
|
---|
[e16e0d59] | 924 | } else if (rc == EOK) {
|
---|
[ba276f7] | 925 | if (pointer)
|
---|
[e16e0d59] | 926 | addr = *(uintptr_t *) addr;
|
---|
[0b0f4bb] | 927 | printf("Writing %#" PRIx32" -> %p\n", arg1, (void *) addr);
|
---|
[e16e0d59] | 928 | *(uint32_t *) addr = arg1;
|
---|
[4ce914d4] | 929 | } else
|
---|
[e16e0d59] | 930 | printf("No symbol information available.\n");
|
---|
[ba276f7] | 931 |
|
---|
| 932 | return 1;
|
---|
| 933 | }
|
---|
[80bff342] | 934 |
|
---|
[4e147a6] | 935 | /** Command for listings SLAB caches
|
---|
| 936 | *
|
---|
| 937 | * @param argv Ignores
|
---|
| 938 | *
|
---|
| 939 | * @return Always 1
|
---|
| 940 | */
|
---|
[df58e44] | 941 | int cmd_slabs(cmd_arg_t *argv)
|
---|
[095b1534] | 942 | {
|
---|
[4e147a6] | 943 | slab_print_list();
|
---|
| 944 | return 1;
|
---|
| 945 | }
|
---|
| 946 |
|
---|
[b3631bc] | 947 | /** Command for dumping sysinfo
|
---|
| 948 | *
|
---|
| 949 | * @param argv Ignores
|
---|
| 950 | *
|
---|
| 951 | * @return Always 1
|
---|
| 952 | */
|
---|
[df58e44] | 953 | int cmd_sysinfo(cmd_arg_t *argv)
|
---|
[b3631bc] | 954 | {
|
---|
[9dae191e] | 955 | sysinfo_dump(NULL);
|
---|
[b3631bc] | 956 | return 1;
|
---|
| 957 | }
|
---|
| 958 |
|
---|
[df58e44] | 959 | /** Command for listing thread information
|
---|
[55ab0f1] | 960 | *
|
---|
[48dcc69] | 961 | * @param argv Ignored
|
---|
[55ab0f1] | 962 | *
|
---|
| 963 | * @return Always 1
|
---|
| 964 | */
|
---|
[48dcc69] | 965 | int cmd_threads(cmd_arg_t *argv)
|
---|
[095b1534] | 966 | {
|
---|
[48dcc69] | 967 | if (str_cmp(flag_buf, "-a") == 0)
|
---|
| 968 | thread_print_list(true);
|
---|
| 969 | else if (str_cmp(flag_buf, "") == 0)
|
---|
| 970 | thread_print_list(false);
|
---|
| 971 | else
|
---|
| 972 | printf("Unknown argument \"%s\".\n", flag_buf);
|
---|
| 973 |
|
---|
[55ab0f1] | 974 | return 1;
|
---|
| 975 | }
|
---|
| 976 |
|
---|
[df58e44] | 977 | /** Command for listing task information
|
---|
[37c57f2] | 978 | *
|
---|
[48dcc69] | 979 | * @param argv Ignored
|
---|
[37c57f2] | 980 | *
|
---|
| 981 | * @return Always 1
|
---|
| 982 | */
|
---|
[c0f13d2] | 983 | int cmd_tasks(cmd_arg_t *argv)
|
---|
[095b1534] | 984 | {
|
---|
[48dcc69] | 985 | if (str_cmp(flag_buf, "-a") == 0)
|
---|
[c0f13d2] | 986 | task_print_list(true);
|
---|
[48dcc69] | 987 | else if (str_cmp(flag_buf, "") == 0)
|
---|
[c0f13d2] | 988 | task_print_list(false);
|
---|
| 989 | else
|
---|
[48dcc69] | 990 | printf("Unknown argument \"%s\".\n", flag_buf);
|
---|
[c0f13d2] | 991 |
|
---|
[37c57f2] | 992 | return 1;
|
---|
| 993 | }
|
---|
| 994 |
|
---|
[5b7a107] | 995 | #ifdef CONFIG_UDEBUG
|
---|
| 996 |
|
---|
[df58e44] | 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 |
|
---|
[5b7a107] | 1010 | #endif /* CONFIG_UDEBUG */
|
---|
| 1011 |
|
---|
[df58e44] | 1012 | /** Command for printing scheduler information
|
---|
[10e16a7] | 1013 | *
|
---|
| 1014 | * @param argv Ignores
|
---|
| 1015 | *
|
---|
| 1016 | * @return Always 1
|
---|
| 1017 | */
|
---|
[df58e44] | 1018 | int cmd_sched(cmd_arg_t *argv)
|
---|
[095b1534] | 1019 | {
|
---|
[10e16a7] | 1020 | sched_print_list();
|
---|
| 1021 | return 1;
|
---|
| 1022 | }
|
---|
| 1023 |
|
---|
[96cacc1] | 1024 | /** Command for listing memory zones
|
---|
| 1025 | *
|
---|
| 1026 | * @param argv Ignored
|
---|
| 1027 | *
|
---|
| 1028 | * return Always 1
|
---|
| 1029 | */
|
---|
[df58e44] | 1030 | int cmd_zones(cmd_arg_t *argv)
|
---|
[095b1534] | 1031 | {
|
---|
[9dae191e] | 1032 | zones_print_list();
|
---|
[80bff342] | 1033 | return 1;
|
---|
| 1034 | }
|
---|
[0132630] | 1035 |
|
---|
[96cacc1] | 1036 | /** Command for memory zone details
|
---|
| 1037 | *
|
---|
| 1038 | * @param argv Integer argument from cmdline expected
|
---|
| 1039 | *
|
---|
| 1040 | * return Always 1
|
---|
| 1041 | */
|
---|
[df58e44] | 1042 | int cmd_zone(cmd_arg_t *argv)
|
---|
[095b1534] | 1043 | {
|
---|
[dfd9186] | 1044 | zone_print_one(argv[0].intval);
|
---|
[80bff342] | 1045 | return 1;
|
---|
| 1046 | }
|
---|
| 1047 |
|
---|
[df58e44] | 1048 | /** Command for printing task IPC details
|
---|
[c4e4507] | 1049 | *
|
---|
| 1050 | * @param argv Integer argument from cmdline expected
|
---|
| 1051 | *
|
---|
| 1052 | * return Always 1
|
---|
| 1053 | */
|
---|
[df58e44] | 1054 | int cmd_ipc(cmd_arg_t *argv)
|
---|
[095b1534] | 1055 | {
|
---|
[c4e4507] | 1056 | ipc_print_task(argv[0].intval);
|
---|
| 1057 | return 1;
|
---|
| 1058 | }
|
---|
| 1059 |
|
---|
[cb3d641a] | 1060 | /** Command for killing a task
|
---|
[2a75302] | 1061 | *
|
---|
| 1062 | * @param argv Integer argument from cmdline expected
|
---|
| 1063 | *
|
---|
[cb3d641a] | 1064 | * return 0 on failure, 1 on success.
|
---|
[2a75302] | 1065 | */
|
---|
[df58e44] | 1066 | int cmd_kill(cmd_arg_t *argv)
|
---|
[2a75302] | 1067 | {
|
---|
| 1068 | if (task_kill(argv[0].intval) != EOK)
|
---|
| 1069 | return 0;
|
---|
| 1070 |
|
---|
| 1071 | return 1;
|
---|
| 1072 | }
|
---|
[c4e4507] | 1073 |
|
---|
[0132630] | 1074 | /** Command for listing processors.
|
---|
| 1075 | *
|
---|
| 1076 | * @param argv Ignored.
|
---|
| 1077 | *
|
---|
| 1078 | * return Always 1.
|
---|
| 1079 | */
|
---|
| 1080 | int cmd_cpus(cmd_arg_t *argv)
|
---|
| 1081 | {
|
---|
| 1082 | cpu_list();
|
---|
| 1083 | return 1;
|
---|
| 1084 | }
|
---|
| 1085 |
|
---|
| 1086 | /** Command for printing kernel version.
|
---|
| 1087 | *
|
---|
| 1088 | * @param argv Ignored.
|
---|
| 1089 | *
|
---|
| 1090 | * return Always 1.
|
---|
| 1091 | */
|
---|
| 1092 | int cmd_version(cmd_arg_t *argv)
|
---|
| 1093 | {
|
---|
| 1094 | version_print();
|
---|
| 1095 | return 1;
|
---|
| 1096 | }
|
---|
[41d33ac] | 1097 |
|
---|
| 1098 | /** Command for returning console back to userspace.
|
---|
| 1099 | *
|
---|
| 1100 | * @param argv Ignored.
|
---|
| 1101 | *
|
---|
| 1102 | * return Always 1.
|
---|
| 1103 | */
|
---|
| 1104 | int cmd_continue(cmd_arg_t *argv)
|
---|
| 1105 | {
|
---|
[dd054bc2] | 1106 | printf("The kernel will now relinquish the console.\n");
|
---|
[516ff92] | 1107 | release_console();
|
---|
[3ad953c] | 1108 |
|
---|
[f9061b4] | 1109 | event_notify_0(EVENT_KCONSOLE, false);
|
---|
[821cc93] | 1110 | indev_pop_character(stdin);
|
---|
[3ad953c] | 1111 |
|
---|
[41d33ac] | 1112 | return 1;
|
---|
| 1113 | }
|
---|
[b45c443] | 1114 |
|
---|
[50661ab] | 1115 | #ifdef CONFIG_TEST
|
---|
[62b6d17] | 1116 | static bool run_test(const test_t *test)
|
---|
[34db7fa] | 1117 | {
|
---|
[c1f7f6ea] | 1118 | printf("%s (%s)\n", test->name, test->desc);
|
---|
[cce6acf] | 1119 |
|
---|
| 1120 | /* Update and read thread accounting
|
---|
| 1121 | for benchmarking */
|
---|
[da1bafb] | 1122 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1123 | uint64_t ucycles0, kcycles0;
|
---|
| 1124 | task_get_accounting(TASK, &ucycles0, &kcycles0);
|
---|
[da1bafb] | 1125 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
[cce6acf] | 1126 |
|
---|
| 1127 | /* Execute the test */
|
---|
[cb01e1e] | 1128 | test_quiet = false;
|
---|
[a000878c] | 1129 | const char *ret = test->entry();
|
---|
[cce6acf] | 1130 |
|
---|
| 1131 | /* Update and read thread accounting */
|
---|
[da1bafb] | 1132 | uint64_t ucycles1, kcycles1;
|
---|
| 1133 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1134 | task_get_accounting(TASK, &ucycles1, &kcycles1);
|
---|
[da1bafb] | 1135 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
[cce6acf] | 1136 |
|
---|
[1ba37fa] | 1137 | uint64_t ucycles, kcycles;
|
---|
| 1138 | char usuffix, ksuffix;
|
---|
[e535eeb] | 1139 | order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
|
---|
| 1140 | order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
|
---|
[da1bafb] | 1141 |
|
---|
[1ba37fa] | 1142 | printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n",
|
---|
[da1bafb] | 1143 | ucycles, usuffix, kcycles, ksuffix);
|
---|
[34db7fa] | 1144 |
|
---|
| 1145 | if (ret == NULL) {
|
---|
| 1146 | printf("Test passed\n");
|
---|
[62b6d17] | 1147 | return true;
|
---|
[34db7fa] | 1148 | }
|
---|
[da1bafb] | 1149 |
|
---|
[34db7fa] | 1150 | printf("%s\n", ret);
|
---|
[62b6d17] | 1151 | return false;
|
---|
[34db7fa] | 1152 | }
|
---|
| 1153 |
|
---|
[95155b0c] | 1154 | static bool run_bench(const test_t *test, const uint32_t cnt)
|
---|
| 1155 | {
|
---|
| 1156 | uint32_t i;
|
---|
| 1157 | bool ret = true;
|
---|
[1ba37fa] | 1158 | uint64_t ucycles, kcycles;
|
---|
| 1159 | char usuffix, ksuffix;
|
---|
[95155b0c] | 1160 |
|
---|
| 1161 | if (cnt < 1)
|
---|
| 1162 | return true;
|
---|
| 1163 |
|
---|
[828aa05] | 1164 | uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt, 0);
|
---|
[95155b0c] | 1165 | if (data == NULL) {
|
---|
| 1166 | printf("Error allocating memory for statistics\n");
|
---|
| 1167 | return false;
|
---|
| 1168 | }
|
---|
| 1169 |
|
---|
| 1170 | for (i = 0; i < cnt; i++) {
|
---|
[c859753] | 1171 | printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
|
---|
[95155b0c] | 1172 |
|
---|
| 1173 | /* Update and read thread accounting
|
---|
| 1174 | for benchmarking */
|
---|
[da1bafb] | 1175 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1176 | uint64_t ucycles0, kcycles0;
|
---|
| 1177 | task_get_accounting(TASK, &ucycles0, &kcycles0);
|
---|
[da1bafb] | 1178 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
[95155b0c] | 1179 |
|
---|
| 1180 | /* Execute the test */
|
---|
[cb01e1e] | 1181 | test_quiet = true;
|
---|
[a000878c] | 1182 | const char *ret = test->entry();
|
---|
[95155b0c] | 1183 |
|
---|
| 1184 | /* Update and read thread accounting */
|
---|
[da1bafb] | 1185 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1186 | uint64_t ucycles1, kcycles1;
|
---|
| 1187 | task_get_accounting(TASK, &ucycles1, &kcycles1);
|
---|
[da1bafb] | 1188 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
| 1189 |
|
---|
[95155b0c] | 1190 | if (ret != NULL) {
|
---|
| 1191 | printf("%s\n", ret);
|
---|
| 1192 | ret = false;
|
---|
| 1193 | break;
|
---|
| 1194 | }
|
---|
| 1195 |
|
---|
[1ba37fa] | 1196 | data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0;
|
---|
[e535eeb] | 1197 | order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
|
---|
| 1198 | order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
|
---|
[1ba37fa] | 1199 | printf("OK (%" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles)\n",
|
---|
[da1bafb] | 1200 | ucycles, usuffix, kcycles, ksuffix);
|
---|
[95155b0c] | 1201 | }
|
---|
| 1202 |
|
---|
| 1203 | if (ret) {
|
---|
| 1204 | printf("\n");
|
---|
| 1205 |
|
---|
| 1206 | uint64_t sum = 0;
|
---|
| 1207 |
|
---|
| 1208 | for (i = 0; i < cnt; i++) {
|
---|
| 1209 | sum += data[i];
|
---|
| 1210 | }
|
---|
| 1211 |
|
---|
[e535eeb] | 1212 | order_suffix(sum / (uint64_t) cnt, &ucycles, &usuffix);
|
---|
[1ba37fa] | 1213 | printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix);
|
---|
[95155b0c] | 1214 | }
|
---|
| 1215 |
|
---|
| 1216 | free(data);
|
---|
| 1217 |
|
---|
| 1218 | return ret;
|
---|
| 1219 | }
|
---|
| 1220 |
|
---|
[851f33a] | 1221 | static void list_tests(void)
|
---|
| 1222 | {
|
---|
| 1223 | size_t len = 0;
|
---|
| 1224 | test_t *test;
|
---|
| 1225 |
|
---|
| 1226 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1227 | if (str_length(test->name) > len)
|
---|
| 1228 | len = str_length(test->name);
|
---|
| 1229 | }
|
---|
| 1230 |
|
---|
[0b0f4bb] | 1231 | unsigned int _len = (unsigned int) len;
|
---|
| 1232 | if ((_len != len) || (((int) _len) < 0)) {
|
---|
| 1233 | printf("Command length overflow\n");
|
---|
| 1234 | return;
|
---|
| 1235 | }
|
---|
| 1236 |
|
---|
[851f33a] | 1237 | for (test = tests; test->name != NULL; test++)
|
---|
[0b0f4bb] | 1238 | printf("%-*s %s%s\n", _len, test->name, test->desc,
|
---|
| 1239 | (test->safe ? "" : " (unsafe)"));
|
---|
[851f33a] | 1240 |
|
---|
[0b0f4bb] | 1241 | printf("%-*s Run all safe tests\n", _len, "*");
|
---|
[851f33a] | 1242 | }
|
---|
| 1243 |
|
---|
| 1244 | /** Command for listing and running kernel tests
|
---|
[319e60e] | 1245 | *
|
---|
| 1246 | * @param argv Argument vector.
|
---|
| 1247 | *
|
---|
| 1248 | * return Always 1.
|
---|
[851f33a] | 1249 | *
|
---|
[319e60e] | 1250 | */
|
---|
| 1251 | int cmd_test(cmd_arg_t *argv)
|
---|
| 1252 | {
|
---|
| 1253 | test_t *test;
|
---|
| 1254 |
|
---|
[20cc877] | 1255 | if (str_cmp((char *) argv->buffer, "*") == 0) {
|
---|
[50661ab] | 1256 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1257 | if (test->safe) {
|
---|
[34db7fa] | 1258 | printf("\n");
|
---|
| 1259 | if (!run_test(test))
|
---|
| 1260 | break;
|
---|
[50661ab] | 1261 | }
|
---|
| 1262 | }
|
---|
[851f33a] | 1263 | } else if (str_cmp((char *) argv->buffer, "") != 0) {
|
---|
[50661ab] | 1264 | bool fnd = false;
|
---|
| 1265 |
|
---|
| 1266 | for (test = tests; test->name != NULL; test++) {
|
---|
[20cc877] | 1267 | if (str_cmp(test->name, (char *) argv->buffer) == 0) {
|
---|
[50661ab] | 1268 | fnd = true;
|
---|
[34db7fa] | 1269 | run_test(test);
|
---|
[50661ab] | 1270 | break;
|
---|
| 1271 | }
|
---|
[319e60e] | 1272 | }
|
---|
[50661ab] | 1273 |
|
---|
| 1274 | if (!fnd)
|
---|
[34db7fa] | 1275 | printf("Unknown test\n");
|
---|
[851f33a] | 1276 | } else
|
---|
| 1277 | list_tests();
|
---|
[319e60e] | 1278 |
|
---|
| 1279 | return 1;
|
---|
| 1280 | }
|
---|
[95155b0c] | 1281 |
|
---|
| 1282 | /** Command for returning kernel tests as benchmarks
|
---|
| 1283 | *
|
---|
| 1284 | * @param argv Argument vector.
|
---|
| 1285 | *
|
---|
| 1286 | * return Always 1.
|
---|
| 1287 | */
|
---|
| 1288 | int cmd_bench(cmd_arg_t *argv)
|
---|
| 1289 | {
|
---|
| 1290 | test_t *test;
|
---|
| 1291 | uint32_t cnt = argv[1].intval;
|
---|
| 1292 |
|
---|
[3f2177e] | 1293 | if (str_cmp((char *) argv->buffer, "*") == 0) {
|
---|
| 1294 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1295 | if (test->safe) {
|
---|
| 1296 | if (!run_bench(test, cnt))
|
---|
| 1297 | break;
|
---|
| 1298 | }
|
---|
[95155b0c] | 1299 | }
|
---|
[3f2177e] | 1300 | } else {
|
---|
| 1301 | bool fnd = false;
|
---|
[95155b0c] | 1302 |
|
---|
[3f2177e] | 1303 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1304 | if (str_cmp(test->name, (char *) argv->buffer) == 0) {
|
---|
| 1305 | fnd = true;
|
---|
| 1306 |
|
---|
| 1307 | if (test->safe)
|
---|
| 1308 | run_bench(test, cnt);
|
---|
| 1309 | else
|
---|
| 1310 | printf("Unsafe test\n");
|
---|
| 1311 |
|
---|
| 1312 | break;
|
---|
| 1313 | }
|
---|
| 1314 | }
|
---|
| 1315 |
|
---|
| 1316 | if (!fnd)
|
---|
| 1317 | printf("Unknown test\n");
|
---|
| 1318 | }
|
---|
[cb01e1e] | 1319 |
|
---|
[95155b0c] | 1320 | return 1;
|
---|
| 1321 | }
|
---|
| 1322 |
|
---|
[50661ab] | 1323 | #endif
|
---|
[319e60e] | 1324 |
|
---|
[06e1e95] | 1325 | /** @}
|
---|
[b45c443] | 1326 | */
|
---|