[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 |
|
---|
[98000fb] | 575 | size_t len = 0;
|
---|
[55b77d9] | 576 | list_foreach(cmd_list, cur) {
|
---|
[442d0ae] | 577 | cmd_info_t *hlp;
|
---|
| 578 | hlp = list_get_instance(cur, cmd_info_t, link);
|
---|
[c1f7f6ea] | 579 |
|
---|
[442d0ae] | 580 | spinlock_lock(&hlp->lock);
|
---|
[20cc877] | 581 | if (str_length(hlp->name) > len)
|
---|
| 582 | len = str_length(hlp->name);
|
---|
[c1f7f6ea] | 583 | spinlock_unlock(&hlp->lock);
|
---|
| 584 | }
|
---|
| 585 |
|
---|
[0b0f4bb] | 586 | unsigned int _len = (unsigned int) len;
|
---|
| 587 | if ((_len != len) || (((int) _len) < 0)) {
|
---|
| 588 | printf("Command length overflow\n");
|
---|
| 589 | return 1;
|
---|
| 590 | }
|
---|
| 591 |
|
---|
[55b77d9] | 592 | list_foreach(cmd_list, cur) {
|
---|
[c1f7f6ea] | 593 | cmd_info_t *hlp;
|
---|
| 594 | hlp = list_get_instance(cur, cmd_info_t, link);
|
---|
[442d0ae] | 595 |
|
---|
[c1f7f6ea] | 596 | spinlock_lock(&hlp->lock);
|
---|
[0b0f4bb] | 597 | printf("%-*s %s\n", _len, hlp->name, hlp->description);
|
---|
[442d0ae] | 598 | spinlock_unlock(&hlp->lock);
|
---|
| 599 | }
|
---|
| 600 |
|
---|
[ae318d3] | 601 | spinlock_unlock(&cmd_lock);
|
---|
[c1f7f6ea] | 602 |
|
---|
[442d0ae] | 603 | return 1;
|
---|
| 604 | }
|
---|
| 605 |
|
---|
[f74bbaf] | 606 | /** Reboot the system.
|
---|
| 607 | *
|
---|
| 608 | * @param argv Argument vector.
|
---|
| 609 | *
|
---|
| 610 | * @return 0 on failure, 1 on success.
|
---|
| 611 | */
|
---|
| 612 | int cmd_reboot(cmd_arg_t *argv)
|
---|
| 613 | {
|
---|
| 614 | reboot();
|
---|
| 615 |
|
---|
| 616 | /* Not reached */
|
---|
| 617 | return 1;
|
---|
| 618 | }
|
---|
| 619 |
|
---|
[4b662f8c] | 620 | /** Print system uptime information.
|
---|
| 621 | *
|
---|
| 622 | * @param argv Argument vector.
|
---|
| 623 | *
|
---|
| 624 | * @return 0 on failure, 1 on success.
|
---|
| 625 | */
|
---|
| 626 | int cmd_uptime(cmd_arg_t *argv)
|
---|
| 627 | {
|
---|
| 628 | ASSERT(uptime);
|
---|
| 629 |
|
---|
| 630 | /* This doesn't have to be very accurate */
|
---|
[96b02eb9] | 631 | sysarg_t sec = uptime->seconds1;
|
---|
[4b662f8c] | 632 |
|
---|
[c859753] | 633 | printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
|
---|
[4b662f8c] | 634 | sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
|
---|
| 635 |
|
---|
| 636 | return 1;
|
---|
| 637 | }
|
---|
| 638 |
|
---|
[442d0ae] | 639 | /** Describe specified command.
|
---|
| 640 | *
|
---|
| 641 | * @param argv Argument vector.
|
---|
| 642 | *
|
---|
| 643 | * @return 0 on failure, 1 on success.
|
---|
| 644 | */
|
---|
| 645 | int cmd_desc(cmd_arg_t *argv)
|
---|
| 646 | {
|
---|
| 647 | spinlock_lock(&cmd_lock);
|
---|
| 648 |
|
---|
[55b77d9] | 649 | list_foreach(cmd_list, cur) {
|
---|
[442d0ae] | 650 | cmd_info_t *hlp;
|
---|
| 651 |
|
---|
| 652 | hlp = list_get_instance(cur, cmd_info_t, link);
|
---|
| 653 | spinlock_lock(&hlp->lock);
|
---|
[20cc877] | 654 |
|
---|
| 655 | if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) {
|
---|
[442d0ae] | 656 | printf("%s - %s\n", hlp->name, hlp->description);
|
---|
| 657 | if (hlp->help)
|
---|
| 658 | hlp->help();
|
---|
| 659 | spinlock_unlock(&hlp->lock);
|
---|
| 660 | break;
|
---|
| 661 | }
|
---|
[20cc877] | 662 |
|
---|
[442d0ae] | 663 | spinlock_unlock(&hlp->lock);
|
---|
| 664 | }
|
---|
| 665 |
|
---|
| 666 | spinlock_unlock(&cmd_lock);
|
---|
[20cc877] | 667 |
|
---|
[442d0ae] | 668 | return 1;
|
---|
| 669 | }
|
---|
| 670 |
|
---|
| 671 | /** Search symbol table */
|
---|
| 672 | int cmd_symaddr(cmd_arg_t *argv)
|
---|
| 673 | {
|
---|
[828aa05] | 674 | symtab_print_search((char *) argv->buffer);
|
---|
[442d0ae] | 675 |
|
---|
| 676 | return 1;
|
---|
| 677 | }
|
---|
| 678 |
|
---|
| 679 | /** Call function with zero parameters */
|
---|
| 680 | int cmd_call0(cmd_arg_t *argv)
|
---|
| 681 | {
|
---|
[7f1c620] | 682 | uintptr_t symaddr;
|
---|
[e16e0d59] | 683 | char *symbol;
|
---|
[96b02eb9] | 684 | sysarg_t (*fnc)(void);
|
---|
[0f81ceb7] | 685 | fncptr_t fptr;
|
---|
[e16e0d59] | 686 | int rc;
|
---|
[e2b762ec] | 687 |
|
---|
[e16e0d59] | 688 | symbol = (char *) argv->buffer;
|
---|
| 689 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 690 |
|
---|
| 691 | if (rc == ENOENT)
|
---|
| 692 | printf("Symbol %s not found.\n", symbol);
|
---|
| 693 | else if (rc == EOVERFLOW) {
|
---|
| 694 | symtab_print_search(symbol);
|
---|
[442d0ae] | 695 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 696 | } else if (rc == EOK) {
|
---|
[c992538a] | 697 | ipl_t ipl;
|
---|
| 698 |
|
---|
| 699 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 700 | fnc = (sysarg_t (*)(void)) arch_construct_function(&fptr,
|
---|
[e16e0d59] | 701 | (void *) symaddr, (void *) cmd_call0);
|
---|
[0b0f4bb] | 702 | printf("Calling %s() (%p)\n", symbol, (void *) symaddr);
|
---|
[0f81ceb7] | 703 | printf("Result: %#" PRIxn "\n", fnc());
|
---|
[c992538a] | 704 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 705 | } else {
|
---|
| 706 | printf("No symbol information available.\n");
|
---|
[442d0ae] | 707 | }
|
---|
| 708 | return 1;
|
---|
| 709 | }
|
---|
| 710 |
|
---|
[e5dbbe5] | 711 | /** Call function with zero parameters on each CPU */
|
---|
| 712 | int cmd_mcall0(cmd_arg_t *argv)
|
---|
| 713 | {
|
---|
| 714 | /*
|
---|
| 715 | * For each CPU, create a thread which will
|
---|
| 716 | * call the function.
|
---|
| 717 | */
|
---|
| 718 |
|
---|
[0b0f4bb] | 719 | unsigned int i;
|
---|
[e5dbbe5] | 720 | for (i = 0; i < config.cpu_count; i++) {
|
---|
[b8f11baa] | 721 | if (!cpus[i].active)
|
---|
| 722 | continue;
|
---|
| 723 |
|
---|
[da1bafb] | 724 | thread_t *thread;
|
---|
| 725 | if ((thread = thread_create((void (*)(void *)) cmd_call0,
|
---|
[6eef3c4] | 726 | (void *) argv, TASK, THREAD_FLAG_NONE, "call0"))) {
|
---|
[0b0f4bb] | 727 | printf("cpu%u: ", i);
|
---|
[6eef3c4] | 728 | thread_wire(thread, &cpus[i]);
|
---|
[da1bafb] | 729 | thread_ready(thread);
|
---|
| 730 | thread_join(thread);
|
---|
| 731 | thread_detach(thread);
|
---|
[e5dbbe5] | 732 | } else
|
---|
[0b0f4bb] | 733 | printf("Unable to create thread for cpu%u\n", i);
|
---|
[e5dbbe5] | 734 | }
|
---|
| 735 |
|
---|
| 736 | return 1;
|
---|
| 737 | }
|
---|
| 738 |
|
---|
[442d0ae] | 739 | /** Call function with one parameter */
|
---|
| 740 | int cmd_call1(cmd_arg_t *argv)
|
---|
| 741 | {
|
---|
[7f1c620] | 742 | uintptr_t symaddr;
|
---|
[442d0ae] | 743 | char *symbol;
|
---|
[96b02eb9] | 744 | sysarg_t (*fnc)(sysarg_t, ...);
|
---|
| 745 | sysarg_t arg1 = argv[1].intval;
|
---|
[0f81ceb7] | 746 | fncptr_t fptr;
|
---|
[e16e0d59] | 747 | int rc;
|
---|
[e2b762ec] | 748 |
|
---|
[e16e0d59] | 749 | symbol = (char *) argv->buffer;
|
---|
| 750 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 751 |
|
---|
| 752 | if (rc == ENOENT) {
|
---|
| 753 | printf("Symbol %s not found.\n", symbol);
|
---|
| 754 | } else if (rc == EOVERFLOW) {
|
---|
| 755 | symtab_print_search(symbol);
|
---|
[442d0ae] | 756 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 757 | } else if (rc == EOK) {
|
---|
[c992538a] | 758 | ipl_t ipl;
|
---|
| 759 |
|
---|
| 760 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 761 | fnc = (sysarg_t (*)(sysarg_t, ...))
|
---|
[0b0f4bb] | 762 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
| 763 | (void *) cmd_call1);
|
---|
| 764 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1,
|
---|
| 765 | (void *) symaddr, symbol);
|
---|
[0f81ceb7] | 766 | printf("Result: %#" PRIxn "\n", fnc(arg1));
|
---|
[c992538a] | 767 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 768 | } else {
|
---|
| 769 | printf("No symbol information available.\n");
|
---|
[442d0ae] | 770 | }
|
---|
[e16e0d59] | 771 |
|
---|
[442d0ae] | 772 | return 1;
|
---|
| 773 | }
|
---|
| 774 |
|
---|
| 775 | /** Call function with two parameters */
|
---|
| 776 | int cmd_call2(cmd_arg_t *argv)
|
---|
| 777 | {
|
---|
[7f1c620] | 778 | uintptr_t symaddr;
|
---|
[442d0ae] | 779 | char *symbol;
|
---|
[96b02eb9] | 780 | sysarg_t (*fnc)(sysarg_t, sysarg_t, ...);
|
---|
| 781 | sysarg_t arg1 = argv[1].intval;
|
---|
| 782 | sysarg_t arg2 = argv[2].intval;
|
---|
[0f81ceb7] | 783 | fncptr_t fptr;
|
---|
[e16e0d59] | 784 | int rc;
|
---|
| 785 |
|
---|
| 786 | symbol = (char *) argv->buffer;
|
---|
| 787 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 788 |
|
---|
| 789 | if (rc == ENOENT) {
|
---|
| 790 | printf("Symbol %s not found.\n", symbol);
|
---|
| 791 | } else if (rc == EOVERFLOW) {
|
---|
| 792 | symtab_print_search(symbol);
|
---|
[442d0ae] | 793 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 794 | } else if (rc == EOK) {
|
---|
[c992538a] | 795 | ipl_t ipl;
|
---|
| 796 |
|
---|
| 797 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 798 | fnc = (sysarg_t (*)(sysarg_t, sysarg_t, ...))
|
---|
[0b0f4bb] | 799 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
| 800 | (void *) cmd_call2);
|
---|
[c859753] | 801 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
|
---|
[0b0f4bb] | 802 | arg1, arg2, (void *) symaddr, symbol);
|
---|
[0f81ceb7] | 803 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
|
---|
[c992538a] | 804 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 805 | } else {
|
---|
| 806 | printf("No symbol information available.\n");
|
---|
| 807 | }
|
---|
[442d0ae] | 808 | return 1;
|
---|
| 809 | }
|
---|
| 810 |
|
---|
| 811 | /** Call function with three parameters */
|
---|
| 812 | int cmd_call3(cmd_arg_t *argv)
|
---|
| 813 | {
|
---|
[7f1c620] | 814 | uintptr_t symaddr;
|
---|
[442d0ae] | 815 | char *symbol;
|
---|
[96b02eb9] | 816 | sysarg_t (*fnc)(sysarg_t, sysarg_t, sysarg_t, ...);
|
---|
| 817 | sysarg_t arg1 = argv[1].intval;
|
---|
| 818 | sysarg_t arg2 = argv[2].intval;
|
---|
| 819 | sysarg_t arg3 = argv[3].intval;
|
---|
[0f81ceb7] | 820 | fncptr_t fptr;
|
---|
[e16e0d59] | 821 | int rc;
|
---|
[0f81ceb7] | 822 |
|
---|
[e16e0d59] | 823 | symbol = (char *) argv->buffer;
|
---|
| 824 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
| 825 |
|
---|
| 826 | if (rc == ENOENT) {
|
---|
| 827 | printf("Symbol %s not found.\n", symbol);
|
---|
| 828 | } else if (rc == EOVERFLOW) {
|
---|
| 829 | symtab_print_search(symbol);
|
---|
[442d0ae] | 830 | printf("Duplicate symbol, be more specific.\n");
|
---|
[e16e0d59] | 831 | } else if (rc == EOK) {
|
---|
[c992538a] | 832 | ipl_t ipl;
|
---|
| 833 |
|
---|
| 834 | ipl = interrupts_disable();
|
---|
[96b02eb9] | 835 | fnc = (sysarg_t (*)(sysarg_t, sysarg_t, sysarg_t, ...))
|
---|
[0b0f4bb] | 836 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
| 837 | (void *) cmd_call3);
|
---|
| 838 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
|
---|
| 839 | arg1, arg2, arg3, (void *) symaddr, symbol);
|
---|
[0f81ceb7] | 840 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
|
---|
[c992538a] | 841 | interrupts_restore(ipl);
|
---|
[e16e0d59] | 842 | } else {
|
---|
| 843 | printf("No symbol information available.\n");
|
---|
[442d0ae] | 844 | }
|
---|
| 845 | return 1;
|
---|
| 846 | }
|
---|
| 847 |
|
---|
| 848 | /** Print detailed description of 'describe' command. */
|
---|
| 849 | void desc_help(void)
|
---|
| 850 | {
|
---|
| 851 | printf("Syntax: describe command_name\n");
|
---|
| 852 | }
|
---|
| 853 |
|
---|
| 854 | /** Halt the kernel.
|
---|
| 855 | *
|
---|
| 856 | * @param argv Argument vector (ignored).
|
---|
| 857 | *
|
---|
| 858 | * @return 0 on failure, 1 on success (never returns).
|
---|
| 859 | */
|
---|
| 860 | int cmd_halt(cmd_arg_t *argv)
|
---|
| 861 | {
|
---|
| 862 | halt();
|
---|
| 863 | return 1;
|
---|
| 864 | }
|
---|
| 865 |
|
---|
| 866 | /** Command for printing TLB contents.
|
---|
| 867 | *
|
---|
| 868 | * @param argv Not used.
|
---|
| 869 | *
|
---|
| 870 | * @return Always returns 1.
|
---|
| 871 | */
|
---|
[0132630] | 872 | int cmd_tlb(cmd_arg_t *argv)
|
---|
[442d0ae] | 873 | {
|
---|
| 874 | tlb_print();
|
---|
| 875 | return 1;
|
---|
| 876 | }
|
---|
[ba276f7] | 877 |
|
---|
[b07c332] | 878 | /** Command for printing physical memory configuration.
|
---|
| 879 | *
|
---|
| 880 | * @param argv Not used.
|
---|
| 881 | *
|
---|
| 882 | * @return Always returns 1.
|
---|
| 883 | */
|
---|
| 884 | int cmd_physmem(cmd_arg_t *argv)
|
---|
| 885 | {
|
---|
| 886 | physmem_print();
|
---|
| 887 | return 1;
|
---|
| 888 | }
|
---|
| 889 |
|
---|
[ba276f7] | 890 | /** Write 4 byte value to address */
|
---|
| 891 | int cmd_set4(cmd_arg_t *argv)
|
---|
| 892 | {
|
---|
[e16e0d59] | 893 | uintptr_t addr;
|
---|
[7f1c620] | 894 | uint32_t arg1 = argv[1].intval;
|
---|
[ba276f7] | 895 | bool pointer = false;
|
---|
[e16e0d59] | 896 | int rc;
|
---|
[4ce914d4] | 897 |
|
---|
| 898 | if (((char *) argv->buffer)[0] == '*') {
|
---|
[e16e0d59] | 899 | rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr);
|
---|
[ba276f7] | 900 | pointer = true;
|
---|
[4ce914d4] | 901 | } else if (((char *) argv->buffer)[0] >= '0' &&
|
---|
| 902 | ((char *) argv->buffer)[0] <= '9') {
|
---|
| 903 | uint64_t value;
|
---|
[059a8e4] | 904 | rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value);
|
---|
[4ce914d4] | 905 | if (rc == EOK)
|
---|
| 906 | addr = (uintptr_t) value;
|
---|
| 907 | } else
|
---|
[e16e0d59] | 908 | rc = symtab_addr_lookup((char *) argv->buffer, &addr);
|
---|
[4ce914d4] | 909 |
|
---|
[e16e0d59] | 910 | if (rc == ENOENT)
|
---|
[0b0f4bb] | 911 | printf("Symbol %s not found.\n", (char *) argv->buffer);
|
---|
[4ce914d4] | 912 | else if (rc == EINVAL)
|
---|
| 913 | printf("Invalid address.\n");
|
---|
[e16e0d59] | 914 | else if (rc == EOVERFLOW) {
|
---|
[828aa05] | 915 | symtab_print_search((char *) argv->buffer);
|
---|
[4ce914d4] | 916 | printf("Duplicate symbol (be more specific) or address overflow.\n");
|
---|
[e16e0d59] | 917 | } else if (rc == EOK) {
|
---|
[ba276f7] | 918 | if (pointer)
|
---|
[e16e0d59] | 919 | addr = *(uintptr_t *) addr;
|
---|
[0b0f4bb] | 920 | printf("Writing %#" PRIx32" -> %p\n", arg1, (void *) addr);
|
---|
[e16e0d59] | 921 | *(uint32_t *) addr = arg1;
|
---|
[4ce914d4] | 922 | } else
|
---|
[e16e0d59] | 923 | printf("No symbol information available.\n");
|
---|
[ba276f7] | 924 |
|
---|
| 925 | return 1;
|
---|
| 926 | }
|
---|
[80bff342] | 927 |
|
---|
[4e147a6] | 928 | /** Command for listings SLAB caches
|
---|
| 929 | *
|
---|
| 930 | * @param argv Ignores
|
---|
| 931 | *
|
---|
| 932 | * @return Always 1
|
---|
| 933 | */
|
---|
[df58e44] | 934 | int cmd_slabs(cmd_arg_t *argv)
|
---|
[095b1534] | 935 | {
|
---|
[4e147a6] | 936 | slab_print_list();
|
---|
| 937 | return 1;
|
---|
| 938 | }
|
---|
| 939 |
|
---|
[b3631bc] | 940 | /** Command for dumping sysinfo
|
---|
| 941 | *
|
---|
| 942 | * @param argv Ignores
|
---|
| 943 | *
|
---|
| 944 | * @return Always 1
|
---|
| 945 | */
|
---|
[df58e44] | 946 | int cmd_sysinfo(cmd_arg_t *argv)
|
---|
[b3631bc] | 947 | {
|
---|
[9dae191e] | 948 | sysinfo_dump(NULL);
|
---|
[b3631bc] | 949 | return 1;
|
---|
| 950 | }
|
---|
| 951 |
|
---|
[df58e44] | 952 | /** Command for listing thread information
|
---|
[55ab0f1] | 953 | *
|
---|
[48dcc69] | 954 | * @param argv Ignored
|
---|
[55ab0f1] | 955 | *
|
---|
| 956 | * @return Always 1
|
---|
| 957 | */
|
---|
[48dcc69] | 958 | int cmd_threads(cmd_arg_t *argv)
|
---|
[095b1534] | 959 | {
|
---|
[48dcc69] | 960 | if (str_cmp(flag_buf, "-a") == 0)
|
---|
| 961 | thread_print_list(true);
|
---|
| 962 | else if (str_cmp(flag_buf, "") == 0)
|
---|
| 963 | thread_print_list(false);
|
---|
| 964 | else
|
---|
| 965 | printf("Unknown argument \"%s\".\n", flag_buf);
|
---|
| 966 |
|
---|
[55ab0f1] | 967 | return 1;
|
---|
| 968 | }
|
---|
| 969 |
|
---|
[df58e44] | 970 | /** Command for listing task information
|
---|
[37c57f2] | 971 | *
|
---|
[48dcc69] | 972 | * @param argv Ignored
|
---|
[37c57f2] | 973 | *
|
---|
| 974 | * @return Always 1
|
---|
| 975 | */
|
---|
[c0f13d2] | 976 | int cmd_tasks(cmd_arg_t *argv)
|
---|
[095b1534] | 977 | {
|
---|
[48dcc69] | 978 | if (str_cmp(flag_buf, "-a") == 0)
|
---|
[c0f13d2] | 979 | task_print_list(true);
|
---|
[48dcc69] | 980 | else if (str_cmp(flag_buf, "") == 0)
|
---|
[c0f13d2] | 981 | task_print_list(false);
|
---|
| 982 | else
|
---|
[48dcc69] | 983 | printf("Unknown argument \"%s\".\n", flag_buf);
|
---|
[c0f13d2] | 984 |
|
---|
[37c57f2] | 985 | return 1;
|
---|
| 986 | }
|
---|
| 987 |
|
---|
[5b7a107] | 988 | #ifdef CONFIG_UDEBUG
|
---|
| 989 |
|
---|
[df58e44] | 990 | /** Command for printing thread stack trace
|
---|
| 991 | *
|
---|
| 992 | * @param argv Integer argument from cmdline expected
|
---|
| 993 | *
|
---|
| 994 | * return Always 1
|
---|
| 995 | *
|
---|
| 996 | */
|
---|
| 997 | int cmd_btrace(cmd_arg_t *argv)
|
---|
| 998 | {
|
---|
| 999 | thread_stack_trace(argv[0].intval);
|
---|
| 1000 | return 1;
|
---|
| 1001 | }
|
---|
| 1002 |
|
---|
[5b7a107] | 1003 | #endif /* CONFIG_UDEBUG */
|
---|
| 1004 |
|
---|
[df58e44] | 1005 | /** Command for printing scheduler information
|
---|
[10e16a7] | 1006 | *
|
---|
| 1007 | * @param argv Ignores
|
---|
| 1008 | *
|
---|
| 1009 | * @return Always 1
|
---|
| 1010 | */
|
---|
[df58e44] | 1011 | int cmd_sched(cmd_arg_t *argv)
|
---|
[095b1534] | 1012 | {
|
---|
[10e16a7] | 1013 | sched_print_list();
|
---|
| 1014 | return 1;
|
---|
| 1015 | }
|
---|
| 1016 |
|
---|
[96cacc1] | 1017 | /** Command for listing memory zones
|
---|
| 1018 | *
|
---|
| 1019 | * @param argv Ignored
|
---|
| 1020 | *
|
---|
| 1021 | * return Always 1
|
---|
| 1022 | */
|
---|
[df58e44] | 1023 | int cmd_zones(cmd_arg_t *argv)
|
---|
[095b1534] | 1024 | {
|
---|
[9dae191e] | 1025 | zones_print_list();
|
---|
[80bff342] | 1026 | return 1;
|
---|
| 1027 | }
|
---|
[0132630] | 1028 |
|
---|
[96cacc1] | 1029 | /** Command for memory zone details
|
---|
| 1030 | *
|
---|
| 1031 | * @param argv Integer argument from cmdline expected
|
---|
| 1032 | *
|
---|
| 1033 | * return Always 1
|
---|
| 1034 | */
|
---|
[df58e44] | 1035 | int cmd_zone(cmd_arg_t *argv)
|
---|
[095b1534] | 1036 | {
|
---|
[dfd9186] | 1037 | zone_print_one(argv[0].intval);
|
---|
[80bff342] | 1038 | return 1;
|
---|
| 1039 | }
|
---|
| 1040 |
|
---|
[df58e44] | 1041 | /** Command for printing task IPC details
|
---|
[c4e4507] | 1042 | *
|
---|
| 1043 | * @param argv Integer argument from cmdline expected
|
---|
| 1044 | *
|
---|
| 1045 | * return Always 1
|
---|
| 1046 | */
|
---|
[df58e44] | 1047 | int cmd_ipc(cmd_arg_t *argv)
|
---|
[095b1534] | 1048 | {
|
---|
[c4e4507] | 1049 | ipc_print_task(argv[0].intval);
|
---|
| 1050 | return 1;
|
---|
| 1051 | }
|
---|
| 1052 |
|
---|
[cb3d641a] | 1053 | /** Command for killing a task
|
---|
[2a75302] | 1054 | *
|
---|
| 1055 | * @param argv Integer argument from cmdline expected
|
---|
| 1056 | *
|
---|
[cb3d641a] | 1057 | * return 0 on failure, 1 on success.
|
---|
[2a75302] | 1058 | */
|
---|
[df58e44] | 1059 | int cmd_kill(cmd_arg_t *argv)
|
---|
[2a75302] | 1060 | {
|
---|
| 1061 | if (task_kill(argv[0].intval) != EOK)
|
---|
| 1062 | return 0;
|
---|
| 1063 |
|
---|
| 1064 | return 1;
|
---|
| 1065 | }
|
---|
[c4e4507] | 1066 |
|
---|
[0132630] | 1067 | /** Command for listing processors.
|
---|
| 1068 | *
|
---|
| 1069 | * @param argv Ignored.
|
---|
| 1070 | *
|
---|
| 1071 | * return Always 1.
|
---|
| 1072 | */
|
---|
| 1073 | int cmd_cpus(cmd_arg_t *argv)
|
---|
| 1074 | {
|
---|
| 1075 | cpu_list();
|
---|
| 1076 | return 1;
|
---|
| 1077 | }
|
---|
| 1078 |
|
---|
| 1079 | /** Command for printing kernel version.
|
---|
| 1080 | *
|
---|
| 1081 | * @param argv Ignored.
|
---|
| 1082 | *
|
---|
| 1083 | * return Always 1.
|
---|
| 1084 | */
|
---|
| 1085 | int cmd_version(cmd_arg_t *argv)
|
---|
| 1086 | {
|
---|
| 1087 | version_print();
|
---|
| 1088 | return 1;
|
---|
| 1089 | }
|
---|
[41d33ac] | 1090 |
|
---|
| 1091 | /** Command for returning console back to userspace.
|
---|
| 1092 | *
|
---|
| 1093 | * @param argv Ignored.
|
---|
| 1094 | *
|
---|
| 1095 | * return Always 1.
|
---|
| 1096 | */
|
---|
| 1097 | int cmd_continue(cmd_arg_t *argv)
|
---|
| 1098 | {
|
---|
[dd054bc2] | 1099 | printf("The kernel will now relinquish the console.\n");
|
---|
[516ff92] | 1100 | release_console();
|
---|
[3ad953c] | 1101 |
|
---|
[f9061b4] | 1102 | event_notify_0(EVENT_KCONSOLE, false);
|
---|
[821cc93] | 1103 | indev_pop_character(stdin);
|
---|
[3ad953c] | 1104 |
|
---|
[41d33ac] | 1105 | return 1;
|
---|
| 1106 | }
|
---|
[b45c443] | 1107 |
|
---|
[50661ab] | 1108 | #ifdef CONFIG_TEST
|
---|
[62b6d17] | 1109 | static bool run_test(const test_t *test)
|
---|
[34db7fa] | 1110 | {
|
---|
[c1f7f6ea] | 1111 | printf("%s (%s)\n", test->name, test->desc);
|
---|
[cce6acf] | 1112 |
|
---|
| 1113 | /* Update and read thread accounting
|
---|
| 1114 | for benchmarking */
|
---|
[da1bafb] | 1115 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1116 | uint64_t ucycles0, kcycles0;
|
---|
| 1117 | task_get_accounting(TASK, &ucycles0, &kcycles0);
|
---|
[da1bafb] | 1118 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
[cce6acf] | 1119 |
|
---|
| 1120 | /* Execute the test */
|
---|
[cb01e1e] | 1121 | test_quiet = false;
|
---|
[a000878c] | 1122 | const char *ret = test->entry();
|
---|
[cce6acf] | 1123 |
|
---|
| 1124 | /* Update and read thread accounting */
|
---|
[da1bafb] | 1125 | uint64_t ucycles1, kcycles1;
|
---|
| 1126 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1127 | task_get_accounting(TASK, &ucycles1, &kcycles1);
|
---|
[da1bafb] | 1128 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
[cce6acf] | 1129 |
|
---|
[1ba37fa] | 1130 | uint64_t ucycles, kcycles;
|
---|
| 1131 | char usuffix, ksuffix;
|
---|
[e535eeb] | 1132 | order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
|
---|
| 1133 | order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
|
---|
[da1bafb] | 1134 |
|
---|
[1ba37fa] | 1135 | printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n",
|
---|
[da1bafb] | 1136 | ucycles, usuffix, kcycles, ksuffix);
|
---|
[34db7fa] | 1137 |
|
---|
| 1138 | if (ret == NULL) {
|
---|
| 1139 | printf("Test passed\n");
|
---|
[62b6d17] | 1140 | return true;
|
---|
[34db7fa] | 1141 | }
|
---|
[da1bafb] | 1142 |
|
---|
[34db7fa] | 1143 | printf("%s\n", ret);
|
---|
[62b6d17] | 1144 | return false;
|
---|
[34db7fa] | 1145 | }
|
---|
| 1146 |
|
---|
[95155b0c] | 1147 | static bool run_bench(const test_t *test, const uint32_t cnt)
|
---|
| 1148 | {
|
---|
| 1149 | uint32_t i;
|
---|
| 1150 | bool ret = true;
|
---|
[1ba37fa] | 1151 | uint64_t ucycles, kcycles;
|
---|
| 1152 | char usuffix, ksuffix;
|
---|
[95155b0c] | 1153 |
|
---|
| 1154 | if (cnt < 1)
|
---|
| 1155 | return true;
|
---|
| 1156 |
|
---|
[828aa05] | 1157 | uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt, 0);
|
---|
[95155b0c] | 1158 | if (data == NULL) {
|
---|
| 1159 | printf("Error allocating memory for statistics\n");
|
---|
| 1160 | return false;
|
---|
| 1161 | }
|
---|
| 1162 |
|
---|
| 1163 | for (i = 0; i < cnt; i++) {
|
---|
[c859753] | 1164 | printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
|
---|
[95155b0c] | 1165 |
|
---|
| 1166 | /* Update and read thread accounting
|
---|
| 1167 | for benchmarking */
|
---|
[da1bafb] | 1168 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1169 | uint64_t ucycles0, kcycles0;
|
---|
| 1170 | task_get_accounting(TASK, &ucycles0, &kcycles0);
|
---|
[da1bafb] | 1171 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
[95155b0c] | 1172 |
|
---|
| 1173 | /* Execute the test */
|
---|
[cb01e1e] | 1174 | test_quiet = true;
|
---|
[21881bd8] | 1175 | const char *test_ret = test->entry();
|
---|
[95155b0c] | 1176 |
|
---|
| 1177 | /* Update and read thread accounting */
|
---|
[da1bafb] | 1178 | irq_spinlock_lock(&TASK->lock, true);
|
---|
[1ba37fa] | 1179 | uint64_t ucycles1, kcycles1;
|
---|
| 1180 | task_get_accounting(TASK, &ucycles1, &kcycles1);
|
---|
[da1bafb] | 1181 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
| 1182 |
|
---|
[21881bd8] | 1183 | if (test_ret != NULL) {
|
---|
| 1184 | printf("%s\n", test_ret);
|
---|
[95155b0c] | 1185 | ret = false;
|
---|
| 1186 | break;
|
---|
| 1187 | }
|
---|
| 1188 |
|
---|
[1ba37fa] | 1189 | data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0;
|
---|
[e535eeb] | 1190 | order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
|
---|
| 1191 | order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
|
---|
[1ba37fa] | 1192 | printf("OK (%" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles)\n",
|
---|
[da1bafb] | 1193 | ucycles, usuffix, kcycles, ksuffix);
|
---|
[95155b0c] | 1194 | }
|
---|
| 1195 |
|
---|
| 1196 | if (ret) {
|
---|
| 1197 | printf("\n");
|
---|
| 1198 |
|
---|
| 1199 | uint64_t sum = 0;
|
---|
| 1200 |
|
---|
| 1201 | for (i = 0; i < cnt; i++) {
|
---|
| 1202 | sum += data[i];
|
---|
| 1203 | }
|
---|
| 1204 |
|
---|
[e535eeb] | 1205 | order_suffix(sum / (uint64_t) cnt, &ucycles, &usuffix);
|
---|
[1ba37fa] | 1206 | printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix);
|
---|
[95155b0c] | 1207 | }
|
---|
| 1208 |
|
---|
| 1209 | free(data);
|
---|
| 1210 |
|
---|
| 1211 | return ret;
|
---|
| 1212 | }
|
---|
| 1213 |
|
---|
[851f33a] | 1214 | static void list_tests(void)
|
---|
| 1215 | {
|
---|
| 1216 | size_t len = 0;
|
---|
| 1217 | test_t *test;
|
---|
| 1218 |
|
---|
| 1219 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1220 | if (str_length(test->name) > len)
|
---|
| 1221 | len = str_length(test->name);
|
---|
| 1222 | }
|
---|
| 1223 |
|
---|
[0b0f4bb] | 1224 | unsigned int _len = (unsigned int) len;
|
---|
| 1225 | if ((_len != len) || (((int) _len) < 0)) {
|
---|
| 1226 | printf("Command length overflow\n");
|
---|
| 1227 | return;
|
---|
| 1228 | }
|
---|
| 1229 |
|
---|
[851f33a] | 1230 | for (test = tests; test->name != NULL; test++)
|
---|
[0b0f4bb] | 1231 | printf("%-*s %s%s\n", _len, test->name, test->desc,
|
---|
| 1232 | (test->safe ? "" : " (unsafe)"));
|
---|
[851f33a] | 1233 |
|
---|
[0b0f4bb] | 1234 | printf("%-*s Run all safe tests\n", _len, "*");
|
---|
[851f33a] | 1235 | }
|
---|
| 1236 |
|
---|
| 1237 | /** Command for listing and running kernel tests
|
---|
[319e60e] | 1238 | *
|
---|
| 1239 | * @param argv Argument vector.
|
---|
| 1240 | *
|
---|
| 1241 | * return Always 1.
|
---|
[851f33a] | 1242 | *
|
---|
[319e60e] | 1243 | */
|
---|
| 1244 | int cmd_test(cmd_arg_t *argv)
|
---|
| 1245 | {
|
---|
| 1246 | test_t *test;
|
---|
| 1247 |
|
---|
[20cc877] | 1248 | if (str_cmp((char *) argv->buffer, "*") == 0) {
|
---|
[50661ab] | 1249 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1250 | if (test->safe) {
|
---|
[34db7fa] | 1251 | printf("\n");
|
---|
| 1252 | if (!run_test(test))
|
---|
| 1253 | break;
|
---|
[50661ab] | 1254 | }
|
---|
| 1255 | }
|
---|
[851f33a] | 1256 | } else if (str_cmp((char *) argv->buffer, "") != 0) {
|
---|
[50661ab] | 1257 | bool fnd = false;
|
---|
| 1258 |
|
---|
| 1259 | for (test = tests; test->name != NULL; test++) {
|
---|
[20cc877] | 1260 | if (str_cmp(test->name, (char *) argv->buffer) == 0) {
|
---|
[50661ab] | 1261 | fnd = true;
|
---|
[34db7fa] | 1262 | run_test(test);
|
---|
[50661ab] | 1263 | break;
|
---|
| 1264 | }
|
---|
[319e60e] | 1265 | }
|
---|
[50661ab] | 1266 |
|
---|
| 1267 | if (!fnd)
|
---|
[34db7fa] | 1268 | printf("Unknown test\n");
|
---|
[851f33a] | 1269 | } else
|
---|
| 1270 | list_tests();
|
---|
[319e60e] | 1271 |
|
---|
| 1272 | return 1;
|
---|
| 1273 | }
|
---|
[95155b0c] | 1274 |
|
---|
| 1275 | /** Command for returning kernel tests as benchmarks
|
---|
| 1276 | *
|
---|
| 1277 | * @param argv Argument vector.
|
---|
| 1278 | *
|
---|
| 1279 | * return Always 1.
|
---|
| 1280 | */
|
---|
| 1281 | int cmd_bench(cmd_arg_t *argv)
|
---|
| 1282 | {
|
---|
| 1283 | test_t *test;
|
---|
| 1284 | uint32_t cnt = argv[1].intval;
|
---|
| 1285 |
|
---|
[3f2177e] | 1286 | if (str_cmp((char *) argv->buffer, "*") == 0) {
|
---|
| 1287 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1288 | if (test->safe) {
|
---|
| 1289 | if (!run_bench(test, cnt))
|
---|
| 1290 | break;
|
---|
| 1291 | }
|
---|
[95155b0c] | 1292 | }
|
---|
[3f2177e] | 1293 | } else {
|
---|
| 1294 | bool fnd = false;
|
---|
[95155b0c] | 1295 |
|
---|
[3f2177e] | 1296 | for (test = tests; test->name != NULL; test++) {
|
---|
| 1297 | if (str_cmp(test->name, (char *) argv->buffer) == 0) {
|
---|
| 1298 | fnd = true;
|
---|
| 1299 |
|
---|
| 1300 | if (test->safe)
|
---|
| 1301 | run_bench(test, cnt);
|
---|
| 1302 | else
|
---|
| 1303 | printf("Unsafe test\n");
|
---|
| 1304 |
|
---|
| 1305 | break;
|
---|
| 1306 | }
|
---|
| 1307 | }
|
---|
| 1308 |
|
---|
| 1309 | if (!fnd)
|
---|
| 1310 | printf("Unknown test\n");
|
---|
| 1311 | }
|
---|
[cb01e1e] | 1312 |
|
---|
[95155b0c] | 1313 | return 1;
|
---|
| 1314 | }
|
---|
| 1315 |
|
---|
[50661ab] | 1316 | #endif
|
---|
[319e60e] | 1317 |
|
---|
[06e1e95] | 1318 | /** @}
|
---|
[b45c443] | 1319 | */
|
---|