1 | /*
|
---|
2 | * Copyright (c) 2005 Jakub Jermar
|
---|
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 |
|
---|
29 | /** @addtogroup kernel_generic_console
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * @file cmd.c
|
---|
35 | * @brief Kernel console command wrappers.
|
---|
36 | *
|
---|
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 <assert.h>
|
---|
44 | #include <console/cmd.h>
|
---|
45 | #include <console/console.h>
|
---|
46 | #include <console/kconsole.h>
|
---|
47 | #include <stdio.h>
|
---|
48 | #include <log.h>
|
---|
49 | #include <panic.h>
|
---|
50 | #include <typedefs.h>
|
---|
51 | #include <adt/list.h>
|
---|
52 | #include <arch.h>
|
---|
53 | #include <config.h>
|
---|
54 | #include <halt.h>
|
---|
55 | #include <str.h>
|
---|
56 | #include <macros.h>
|
---|
57 | #include <cpu.h>
|
---|
58 | #include <mm/tlb.h>
|
---|
59 | #include <mm/km.h>
|
---|
60 | #include <arch/mm/tlb.h>
|
---|
61 | #include <mm/frame.h>
|
---|
62 | #include <main/version.h>
|
---|
63 | #include <mm/slab.h>
|
---|
64 | #include <proc/scheduler.h>
|
---|
65 | #include <proc/thread.h>
|
---|
66 | #include <proc/task.h>
|
---|
67 | #include <ipc/ipc.h>
|
---|
68 | #include <ipc/irq.h>
|
---|
69 | #include <ipc/event.h>
|
---|
70 | #include <sysinfo/sysinfo.h>
|
---|
71 | #include <symtab.h>
|
---|
72 | #include <errno.h>
|
---|
73 |
|
---|
74 | #ifdef CONFIG_TEST
|
---|
75 | #include <test.h>
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | /* Data and methods for 'help' command. */
|
---|
79 | static int cmd_help(cmd_arg_t *argv);
|
---|
80 | static cmd_info_t help_info = {
|
---|
81 | .name = "help",
|
---|
82 | .description = "List supported commands.",
|
---|
83 | .func = cmd_help,
|
---|
84 | .argc = 0
|
---|
85 | };
|
---|
86 |
|
---|
87 | /* Data and methods for pio_read_8 command */
|
---|
88 | static int cmd_pio_read_8(cmd_arg_t *argv);
|
---|
89 | static cmd_arg_t pio_read_8_argv[] = { { .type = ARG_TYPE_INT } };
|
---|
90 | static cmd_info_t pio_read_8_info = {
|
---|
91 | .name = "pio_read_8",
|
---|
92 | .description = "pio_read_8 <address> Read 1 byte from memory (or port).",
|
---|
93 | .func = cmd_pio_read_8,
|
---|
94 | .argc = 1,
|
---|
95 | .argv = pio_read_8_argv
|
---|
96 | };
|
---|
97 |
|
---|
98 | /* Data and methods for pio_read_16 command */
|
---|
99 | static int cmd_pio_read_16(cmd_arg_t *argv);
|
---|
100 | static cmd_arg_t pio_read_16_argv[] = { { .type = ARG_TYPE_INT } };
|
---|
101 | static cmd_info_t pio_read_16_info = {
|
---|
102 | .name = "pio_read_16",
|
---|
103 | .description = "pio_read_16 <address> Read 2 bytes from memory (or port).",
|
---|
104 | .func = cmd_pio_read_16,
|
---|
105 | .argc = 1,
|
---|
106 | .argv = pio_read_16_argv
|
---|
107 | };
|
---|
108 |
|
---|
109 | /* Data and methods for pio_read_32 command */
|
---|
110 | static int cmd_pio_read_32(cmd_arg_t *argv);
|
---|
111 | static cmd_arg_t pio_read_32_argv[] = { { .type = ARG_TYPE_INT } };
|
---|
112 | static cmd_info_t pio_read_32_info = {
|
---|
113 | .name = "pio_read_32",
|
---|
114 | .description = "pio_read_32 <address> Read 4 bytes from memory (or port).",
|
---|
115 | .func = cmd_pio_read_32,
|
---|
116 | .argc = 1,
|
---|
117 | .argv = pio_read_32_argv
|
---|
118 | };
|
---|
119 |
|
---|
120 | /* Data and methods for pio_write_8 command */
|
---|
121 | static int cmd_pio_write_8(cmd_arg_t *argv);
|
---|
122 | static cmd_arg_t pio_write_8_argv[] = {
|
---|
123 | { .type = ARG_TYPE_INT },
|
---|
124 | { .type = ARG_TYPE_INT }
|
---|
125 | };
|
---|
126 | static cmd_info_t pio_write_8_info = {
|
---|
127 | .name = "pio_write_8",
|
---|
128 | .description = "pio_write_8 <address> <value> Write 1 byte to memory (or port).",
|
---|
129 | .func = cmd_pio_write_8,
|
---|
130 | .argc = 2,
|
---|
131 | .argv = pio_write_8_argv
|
---|
132 | };
|
---|
133 |
|
---|
134 | /* Data and methods for pio_write_16 command */
|
---|
135 | static int cmd_pio_write_16(cmd_arg_t *argv);
|
---|
136 | static cmd_arg_t pio_write_16_argv[] = {
|
---|
137 | { .type = ARG_TYPE_INT },
|
---|
138 | { .type = ARG_TYPE_INT }
|
---|
139 | };
|
---|
140 | static cmd_info_t pio_write_16_info = {
|
---|
141 | .name = "pio_write_16",
|
---|
142 | .description = "pio_write_16 <address> <value> Write 2 bytes to memory (or port).",
|
---|
143 | .func = cmd_pio_write_16,
|
---|
144 | .argc = 2,
|
---|
145 | .argv = pio_write_16_argv
|
---|
146 | };
|
---|
147 |
|
---|
148 | /* Data and methods for pio_write_32 command */
|
---|
149 | static int cmd_pio_write_32(cmd_arg_t *argv);
|
---|
150 | static cmd_arg_t pio_write_32_argv[] = {
|
---|
151 | { .type = ARG_TYPE_INT },
|
---|
152 | { .type = ARG_TYPE_INT }
|
---|
153 | };
|
---|
154 | static cmd_info_t pio_write_32_info = {
|
---|
155 | .name = "pio_write_32",
|
---|
156 | .description = "pio_write_32 <address> <value> Write 4 bytes to memory (or port).",
|
---|
157 | .func = cmd_pio_write_32,
|
---|
158 | .argc = 2,
|
---|
159 | .argv = pio_write_32_argv
|
---|
160 | };
|
---|
161 |
|
---|
162 | /* Data and methods for 'reboot' command. */
|
---|
163 | static int cmd_reboot(cmd_arg_t *argv);
|
---|
164 | static cmd_info_t reboot_info = {
|
---|
165 | .name = "reboot",
|
---|
166 | .description = "Reboot system.",
|
---|
167 | .func = cmd_reboot,
|
---|
168 | .argc = 0
|
---|
169 | };
|
---|
170 |
|
---|
171 | /* Data and methods for 'uptime' command. */
|
---|
172 | static int cmd_uptime(cmd_arg_t *argv);
|
---|
173 | static cmd_info_t uptime_info = {
|
---|
174 | .name = "uptime",
|
---|
175 | .description = "Show system uptime.",
|
---|
176 | .func = cmd_uptime,
|
---|
177 | .argc = 0
|
---|
178 | };
|
---|
179 |
|
---|
180 | /* Data and methods for 'continue' command. */
|
---|
181 | static int cmd_continue(cmd_arg_t *argv);
|
---|
182 | static cmd_info_t continue_info = {
|
---|
183 | .name = "continue",
|
---|
184 | .description = "Return console back to userspace.",
|
---|
185 | .func = cmd_continue,
|
---|
186 | .argc = 0
|
---|
187 | };
|
---|
188 |
|
---|
189 | #ifdef CONFIG_TEST
|
---|
190 |
|
---|
191 | /* Data and methods for 'test' command. */
|
---|
192 | static char test_buf[MAX_CMDLINE + 1];
|
---|
193 | static int cmd_test(cmd_arg_t *argv);
|
---|
194 | static cmd_arg_t test_argv[] = {
|
---|
195 | {
|
---|
196 | .type = ARG_TYPE_STRING_OPTIONAL,
|
---|
197 | .buffer = test_buf,
|
---|
198 | .len = sizeof(test_buf)
|
---|
199 | }
|
---|
200 | };
|
---|
201 | static cmd_info_t test_info = {
|
---|
202 | .name = "test",
|
---|
203 | .description = "<test> List kernel tests or run a test.",
|
---|
204 | .func = cmd_test,
|
---|
205 | .argc = 1,
|
---|
206 | .argv = test_argv,
|
---|
207 | .hints_enum = tests_hints_enum
|
---|
208 | };
|
---|
209 |
|
---|
210 | /* Data and methods for 'bench' command. */
|
---|
211 | static int cmd_bench(cmd_arg_t *argv);
|
---|
212 | static cmd_arg_t bench_argv[] = {
|
---|
213 | {
|
---|
214 | .type = ARG_TYPE_STRING,
|
---|
215 | .buffer = test_buf,
|
---|
216 | .len = sizeof(test_buf)
|
---|
217 | },
|
---|
218 | {
|
---|
219 | .type = ARG_TYPE_INT,
|
---|
220 | }
|
---|
221 | };
|
---|
222 | static cmd_info_t bench_info = {
|
---|
223 | .name = "bench",
|
---|
224 | .description = "<test> <count> Run kernel test as benchmark.",
|
---|
225 | .func = cmd_bench,
|
---|
226 | .argc = 2,
|
---|
227 | .argv = bench_argv
|
---|
228 | };
|
---|
229 |
|
---|
230 | #endif /* CONFIG_TEST */
|
---|
231 |
|
---|
232 | /* Data and methods for 'description' command. */
|
---|
233 | static int cmd_desc(cmd_arg_t *argv);
|
---|
234 | static void desc_help(void);
|
---|
235 | static char desc_buf[MAX_CMDLINE + 1];
|
---|
236 | static cmd_arg_t desc_argv = {
|
---|
237 | .type = ARG_TYPE_STRING,
|
---|
238 | .buffer = desc_buf,
|
---|
239 | .len = sizeof(desc_buf)
|
---|
240 | };
|
---|
241 | static cmd_info_t desc_info = {
|
---|
242 | .name = "describe",
|
---|
243 | .description = "<command> Describe specified command.",
|
---|
244 | .help = desc_help,
|
---|
245 | .func = cmd_desc,
|
---|
246 | .argc = 1,
|
---|
247 | .argv = &desc_argv,
|
---|
248 | .hints_enum = cmdtab_enum
|
---|
249 | };
|
---|
250 |
|
---|
251 | /* Data and methods for 'symaddr' command. */
|
---|
252 | static int cmd_symaddr(cmd_arg_t *argv);
|
---|
253 | static char symaddr_buf[MAX_CMDLINE + 1];
|
---|
254 | static cmd_arg_t symaddr_argv = {
|
---|
255 | .type = ARG_TYPE_STRING,
|
---|
256 | .buffer = symaddr_buf,
|
---|
257 | .len = sizeof(symaddr_buf)
|
---|
258 | };
|
---|
259 | static cmd_info_t symaddr_info = {
|
---|
260 | .name = "symaddr",
|
---|
261 | .description = "<symbol> Return symbol address.",
|
---|
262 | .func = cmd_symaddr,
|
---|
263 | .argc = 1,
|
---|
264 | .argv = &symaddr_argv,
|
---|
265 | .hints_enum = symtab_hints_enum,
|
---|
266 | };
|
---|
267 |
|
---|
268 | /* Data and methods for 'set4' command. */
|
---|
269 | static char set_buf[MAX_CMDLINE + 1];
|
---|
270 | static int cmd_set4(cmd_arg_t *argv);
|
---|
271 | static cmd_arg_t set4_argv[] = {
|
---|
272 | {
|
---|
273 | .type = ARG_TYPE_STRING,
|
---|
274 | .buffer = set_buf,
|
---|
275 | .len = sizeof(set_buf)
|
---|
276 | },
|
---|
277 | {
|
---|
278 | .type = ARG_TYPE_INT
|
---|
279 | }
|
---|
280 | };
|
---|
281 | static cmd_info_t set4_info = {
|
---|
282 | .name = "set4",
|
---|
283 | .description = "<addr> <value> Set 4B memory location to a value.",
|
---|
284 | .func = cmd_set4,
|
---|
285 | .argc = 2,
|
---|
286 | .argv = set4_argv
|
---|
287 | };
|
---|
288 |
|
---|
289 | /* Data and methods for 'call0' and 'mcall0' command. */
|
---|
290 | static char call0_buf[MAX_CMDLINE + 1];
|
---|
291 | static char carg1_buf[MAX_CMDLINE + 1];
|
---|
292 | static char carg2_buf[MAX_CMDLINE + 1];
|
---|
293 | static char carg3_buf[MAX_CMDLINE + 1];
|
---|
294 |
|
---|
295 | static int cmd_call0(cmd_arg_t *argv);
|
---|
296 | static cmd_arg_t call0_argv = {
|
---|
297 | .type = ARG_TYPE_STRING,
|
---|
298 | .buffer = call0_buf,
|
---|
299 | .len = sizeof(call0_buf)
|
---|
300 | };
|
---|
301 | static cmd_info_t call0_info = {
|
---|
302 | .name = "call0",
|
---|
303 | .description = "<function> Call function().",
|
---|
304 | .func = cmd_call0,
|
---|
305 | .argc = 1,
|
---|
306 | .argv = &call0_argv,
|
---|
307 | .hints_enum = symtab_hints_enum
|
---|
308 | };
|
---|
309 |
|
---|
310 | /* Data and methods for 'mcall0' command. */
|
---|
311 | static int cmd_mcall0(cmd_arg_t *argv);
|
---|
312 | static cmd_arg_t mcall0_argv = {
|
---|
313 | .type = ARG_TYPE_STRING,
|
---|
314 | .buffer = call0_buf,
|
---|
315 | .len = sizeof(call0_buf)
|
---|
316 | };
|
---|
317 | static cmd_info_t mcall0_info = {
|
---|
318 | .name = "mcall0",
|
---|
319 | .description = "<function> Call function() on each CPU.",
|
---|
320 | .func = cmd_mcall0,
|
---|
321 | .argc = 1,
|
---|
322 | .argv = &mcall0_argv,
|
---|
323 | .hints_enum = symtab_hints_enum
|
---|
324 | };
|
---|
325 |
|
---|
326 | /* Data and methods for 'call1' command. */
|
---|
327 | static int cmd_call1(cmd_arg_t *argv);
|
---|
328 | static cmd_arg_t call1_argv[] = {
|
---|
329 | {
|
---|
330 | .type = ARG_TYPE_STRING,
|
---|
331 | .buffer = call0_buf,
|
---|
332 | .len = sizeof(call0_buf)
|
---|
333 | },
|
---|
334 | {
|
---|
335 | .type = ARG_TYPE_VAR,
|
---|
336 | .buffer = carg1_buf,
|
---|
337 | .len = sizeof(carg1_buf)
|
---|
338 | }
|
---|
339 | };
|
---|
340 | static cmd_info_t call1_info = {
|
---|
341 | .name = "call1",
|
---|
342 | .description = "<function> <arg1> Call function(arg1).",
|
---|
343 | .func = cmd_call1,
|
---|
344 | .argc = 2,
|
---|
345 | .argv = call1_argv,
|
---|
346 | .hints_enum = symtab_hints_enum
|
---|
347 | };
|
---|
348 |
|
---|
349 | /* Data and methods for 'call2' command. */
|
---|
350 | static int cmd_call2(cmd_arg_t *argv);
|
---|
351 | static cmd_arg_t call2_argv[] = {
|
---|
352 | {
|
---|
353 | .type = ARG_TYPE_STRING,
|
---|
354 | .buffer = call0_buf,
|
---|
355 | .len = sizeof(call0_buf)
|
---|
356 | },
|
---|
357 | {
|
---|
358 | .type = ARG_TYPE_VAR,
|
---|
359 | .buffer = carg1_buf,
|
---|
360 | .len = sizeof(carg1_buf)
|
---|
361 | },
|
---|
362 | {
|
---|
363 | .type = ARG_TYPE_VAR,
|
---|
364 | .buffer = carg2_buf,
|
---|
365 | .len = sizeof(carg2_buf)
|
---|
366 | }
|
---|
367 | };
|
---|
368 | static cmd_info_t call2_info = {
|
---|
369 | .name = "call2",
|
---|
370 | .description = "<function> <arg1> <arg2> Call function(arg1, arg2).",
|
---|
371 | .func = cmd_call2,
|
---|
372 | .argc = 3,
|
---|
373 | .argv = call2_argv,
|
---|
374 | .hints_enum = symtab_hints_enum
|
---|
375 | };
|
---|
376 |
|
---|
377 | /* Data and methods for 'call3' command. */
|
---|
378 | static int cmd_call3(cmd_arg_t *argv);
|
---|
379 | static cmd_arg_t call3_argv[] = {
|
---|
380 | {
|
---|
381 | .type = ARG_TYPE_STRING,
|
---|
382 | .buffer = call0_buf,
|
---|
383 | .len = sizeof(call0_buf)
|
---|
384 | },
|
---|
385 | {
|
---|
386 | .type = ARG_TYPE_VAR,
|
---|
387 | .buffer = carg1_buf,
|
---|
388 | .len = sizeof(carg1_buf)
|
---|
389 | },
|
---|
390 | {
|
---|
391 | .type = ARG_TYPE_VAR,
|
---|
392 | .buffer = carg2_buf,
|
---|
393 | .len = sizeof(carg2_buf)
|
---|
394 | },
|
---|
395 | {
|
---|
396 | .type = ARG_TYPE_VAR,
|
---|
397 | .buffer = carg3_buf,
|
---|
398 | .len = sizeof(carg3_buf)
|
---|
399 | }
|
---|
400 |
|
---|
401 | };
|
---|
402 | static cmd_info_t call3_info = {
|
---|
403 | .name = "call3",
|
---|
404 | .description = "<function> <arg1> <arg2> <arg3> Call function(arg1, arg2, arg3).",
|
---|
405 | .func = cmd_call3,
|
---|
406 | .argc = 4,
|
---|
407 | .argv = call3_argv,
|
---|
408 | .hints_enum = symtab_hints_enum
|
---|
409 | };
|
---|
410 |
|
---|
411 | /* Data and methods for 'halt' command. */
|
---|
412 | static int cmd_halt(cmd_arg_t *argv);
|
---|
413 | static cmd_info_t halt_info = {
|
---|
414 | .name = "halt",
|
---|
415 | .description = "Halt the kernel.",
|
---|
416 | .func = cmd_halt,
|
---|
417 | .argc = 0
|
---|
418 | };
|
---|
419 |
|
---|
420 | /* Data and methods for 'physmem' command. */
|
---|
421 | static int cmd_physmem(cmd_arg_t *argv);
|
---|
422 | cmd_info_t physmem_info = {
|
---|
423 | .name = "physmem",
|
---|
424 | .description = "Print physical memory configuration.",
|
---|
425 | .help = NULL,
|
---|
426 | .func = cmd_physmem,
|
---|
427 | .argc = 0,
|
---|
428 | .argv = NULL
|
---|
429 | };
|
---|
430 |
|
---|
431 | /* Data and methods for 'tlb' command. */
|
---|
432 | static int cmd_tlb(cmd_arg_t *argv);
|
---|
433 | cmd_info_t tlb_info = {
|
---|
434 | .name = "tlb",
|
---|
435 | .description = "Print TLB of the current CPU.",
|
---|
436 | .help = NULL,
|
---|
437 | .func = cmd_tlb,
|
---|
438 | .argc = 0,
|
---|
439 | .argv = NULL
|
---|
440 | };
|
---|
441 |
|
---|
442 | static char flag_buf[MAX_CMDLINE + 1];
|
---|
443 |
|
---|
444 | static int cmd_threads(cmd_arg_t *argv);
|
---|
445 | static cmd_arg_t threads_argv = {
|
---|
446 | .type = ARG_TYPE_STRING_OPTIONAL,
|
---|
447 | .buffer = flag_buf,
|
---|
448 | .len = sizeof(flag_buf)
|
---|
449 | };
|
---|
450 | static cmd_info_t threads_info = {
|
---|
451 | .name = "threads",
|
---|
452 | .description = "List all threads (use -a for additional information).",
|
---|
453 | .func = cmd_threads,
|
---|
454 | .argc = 1,
|
---|
455 | .argv = &threads_argv
|
---|
456 | };
|
---|
457 |
|
---|
458 | static int cmd_tasks(cmd_arg_t *argv);
|
---|
459 | static cmd_arg_t tasks_argv = {
|
---|
460 | .type = ARG_TYPE_STRING_OPTIONAL,
|
---|
461 | .buffer = flag_buf,
|
---|
462 | .len = sizeof(flag_buf)
|
---|
463 | };
|
---|
464 | static cmd_info_t tasks_info = {
|
---|
465 | .name = "tasks",
|
---|
466 | .description = "List all tasks (use -a for additional information).",
|
---|
467 | .func = cmd_tasks,
|
---|
468 | .argc = 1,
|
---|
469 | .argv = &tasks_argv
|
---|
470 | };
|
---|
471 |
|
---|
472 | #ifdef CONFIG_UDEBUG
|
---|
473 |
|
---|
474 | /* Data and methods for 'btrace' command */
|
---|
475 | static int cmd_btrace(cmd_arg_t *argv);
|
---|
476 | static cmd_arg_t btrace_argv = {
|
---|
477 | .type = ARG_TYPE_INT,
|
---|
478 | };
|
---|
479 | static cmd_info_t btrace_info = {
|
---|
480 | .name = "btrace",
|
---|
481 | .description = "<threadid> Show thread stack trace.",
|
---|
482 | .func = cmd_btrace,
|
---|
483 | .argc = 1,
|
---|
484 | .argv = &btrace_argv
|
---|
485 | };
|
---|
486 |
|
---|
487 | #endif /* CONFIG_UDEBUG */
|
---|
488 |
|
---|
489 | static int cmd_sched(cmd_arg_t *argv);
|
---|
490 | static cmd_info_t sched_info = {
|
---|
491 | .name = "scheduler",
|
---|
492 | .description = "Show scheduler information.",
|
---|
493 | .func = cmd_sched,
|
---|
494 | .argc = 0
|
---|
495 | };
|
---|
496 |
|
---|
497 | static int cmd_caches(cmd_arg_t *argv);
|
---|
498 | static cmd_info_t caches_info = {
|
---|
499 | .name = "caches",
|
---|
500 | .description = "List slab caches.",
|
---|
501 | .func = cmd_caches,
|
---|
502 | .argc = 0
|
---|
503 | };
|
---|
504 |
|
---|
505 | static int cmd_sysinfo(cmd_arg_t *argv);
|
---|
506 | static cmd_info_t sysinfo_info = {
|
---|
507 | .name = "sysinfo",
|
---|
508 | .description = "Dump sysinfo.",
|
---|
509 | .func = cmd_sysinfo,
|
---|
510 | .argc = 0
|
---|
511 | };
|
---|
512 |
|
---|
513 | /* Data and methods for 'zones' command */
|
---|
514 | static int cmd_zones(cmd_arg_t *argv);
|
---|
515 | static cmd_info_t zones_info = {
|
---|
516 | .name = "zones",
|
---|
517 | .description = "List memory zones.",
|
---|
518 | .func = cmd_zones,
|
---|
519 | .argc = 0
|
---|
520 | };
|
---|
521 |
|
---|
522 | /* Data and methods for 'zone' command */
|
---|
523 | static int cmd_zone(cmd_arg_t *argv);
|
---|
524 | static cmd_arg_t zone_argv = {
|
---|
525 | .type = ARG_TYPE_INT,
|
---|
526 | };
|
---|
527 |
|
---|
528 | static cmd_info_t zone_info = {
|
---|
529 | .name = "zone",
|
---|
530 | .description = "<zone> Show memory zone structure.",
|
---|
531 | .func = cmd_zone,
|
---|
532 | .argc = 1,
|
---|
533 | .argv = &zone_argv
|
---|
534 | };
|
---|
535 |
|
---|
536 | /* Data and methods for 'ipc' command */
|
---|
537 | static int cmd_ipc(cmd_arg_t *argv);
|
---|
538 | static cmd_arg_t ipc_argv = {
|
---|
539 | .type = ARG_TYPE_INT,
|
---|
540 | };
|
---|
541 | static cmd_info_t ipc_info = {
|
---|
542 | .name = "ipc",
|
---|
543 | .description = "<taskid> Show IPC information of a task.",
|
---|
544 | .func = cmd_ipc,
|
---|
545 | .argc = 1,
|
---|
546 | .argv = &ipc_argv
|
---|
547 | };
|
---|
548 |
|
---|
549 | /* Data and methods for 'kill' command */
|
---|
550 | static int cmd_kill(cmd_arg_t *argv);
|
---|
551 | static cmd_arg_t kill_argv = {
|
---|
552 | .type = ARG_TYPE_INT,
|
---|
553 | };
|
---|
554 | static cmd_info_t kill_info = {
|
---|
555 | .name = "kill",
|
---|
556 | .description = "<taskid> Kill a task.",
|
---|
557 | .func = cmd_kill,
|
---|
558 | .argc = 1,
|
---|
559 | .argv = &kill_argv
|
---|
560 | };
|
---|
561 |
|
---|
562 | /* Data and methods for 'cpus' command. */
|
---|
563 | static int cmd_cpus(cmd_arg_t *argv);
|
---|
564 | cmd_info_t cpus_info = {
|
---|
565 | .name = "cpus",
|
---|
566 | .description = "List all processors.",
|
---|
567 | .help = NULL,
|
---|
568 | .func = cmd_cpus,
|
---|
569 | .argc = 0,
|
---|
570 | .argv = NULL
|
---|
571 | };
|
---|
572 |
|
---|
573 | /* Data and methods for 'version' command. */
|
---|
574 | static int cmd_version(cmd_arg_t *argv);
|
---|
575 | cmd_info_t version_info = {
|
---|
576 | .name = "version",
|
---|
577 | .description = "Print version information.",
|
---|
578 | .help = NULL,
|
---|
579 | .func = cmd_version,
|
---|
580 | .argc = 0,
|
---|
581 | .argv = NULL
|
---|
582 | };
|
---|
583 |
|
---|
584 | static cmd_info_t *basic_commands[] = {
|
---|
585 | &call0_info,
|
---|
586 | &mcall0_info,
|
---|
587 | &caches_info,
|
---|
588 | &call1_info,
|
---|
589 | &call2_info,
|
---|
590 | &call3_info,
|
---|
591 | &continue_info,
|
---|
592 | &cpus_info,
|
---|
593 | &desc_info,
|
---|
594 | &halt_info,
|
---|
595 | &help_info,
|
---|
596 | &ipc_info,
|
---|
597 | &kill_info,
|
---|
598 | &physmem_info,
|
---|
599 | &reboot_info,
|
---|
600 | &sched_info,
|
---|
601 | &set4_info,
|
---|
602 | &symaddr_info,
|
---|
603 | &sysinfo_info,
|
---|
604 | &tasks_info,
|
---|
605 | &threads_info,
|
---|
606 | &tlb_info,
|
---|
607 | &uptime_info,
|
---|
608 | &version_info,
|
---|
609 | &zones_info,
|
---|
610 | &zone_info,
|
---|
611 | #ifdef CONFIG_TEST
|
---|
612 | &test_info,
|
---|
613 | &bench_info,
|
---|
614 | #endif
|
---|
615 | #ifdef CONFIG_UDEBUG
|
---|
616 | &btrace_info,
|
---|
617 | #endif
|
---|
618 | &pio_read_8_info,
|
---|
619 | &pio_read_16_info,
|
---|
620 | &pio_read_32_info,
|
---|
621 | &pio_write_8_info,
|
---|
622 | &pio_write_16_info,
|
---|
623 | &pio_write_32_info,
|
---|
624 | NULL
|
---|
625 | };
|
---|
626 |
|
---|
627 | /** Initialize command info structure.
|
---|
628 | *
|
---|
629 | * @param cmd Command info structure.
|
---|
630 | *
|
---|
631 | */
|
---|
632 | void cmd_initialize(cmd_info_t *cmd)
|
---|
633 | {
|
---|
634 | spinlock_initialize(&cmd->lock, "cmd.lock");
|
---|
635 | link_initialize(&cmd->link);
|
---|
636 | }
|
---|
637 |
|
---|
638 | /** Initialize and register commands. */
|
---|
639 | void cmd_init(void)
|
---|
640 | {
|
---|
641 | unsigned int i;
|
---|
642 |
|
---|
643 | for (i = 0; basic_commands[i]; i++) {
|
---|
644 | cmd_initialize(basic_commands[i]);
|
---|
645 | }
|
---|
646 |
|
---|
647 | for (i = 0; basic_commands[i]; i++) {
|
---|
648 | if (!cmd_register(basic_commands[i])) {
|
---|
649 | log(LF_OTHER, LVL_ERROR,
|
---|
650 | "Cannot register command %s",
|
---|
651 | basic_commands[i]->name);
|
---|
652 | }
|
---|
653 | }
|
---|
654 | }
|
---|
655 |
|
---|
656 | /** List supported commands.
|
---|
657 | *
|
---|
658 | * @param argv Argument vector.
|
---|
659 | *
|
---|
660 | * @return 0 on failure, 1 on success.
|
---|
661 | */
|
---|
662 | int cmd_help(cmd_arg_t *argv)
|
---|
663 | {
|
---|
664 | spinlock_lock(&cmd_lock);
|
---|
665 |
|
---|
666 | size_t len = 0;
|
---|
667 | list_foreach(cmd_list, link, cmd_info_t, hlp) {
|
---|
668 | spinlock_lock(&hlp->lock);
|
---|
669 | if (str_length(hlp->name) > len)
|
---|
670 | len = str_length(hlp->name);
|
---|
671 | spinlock_unlock(&hlp->lock);
|
---|
672 | }
|
---|
673 |
|
---|
674 | unsigned int _len = (unsigned int) len;
|
---|
675 | if ((_len != len) || (((int) _len) < 0)) {
|
---|
676 | log(LF_OTHER, LVL_ERROR, "Command length overflow");
|
---|
677 | return 1;
|
---|
678 | }
|
---|
679 |
|
---|
680 | list_foreach(cmd_list, link, cmd_info_t, hlp) {
|
---|
681 | spinlock_lock(&hlp->lock);
|
---|
682 | printf("%-*s %s\n", _len, hlp->name, hlp->description);
|
---|
683 | spinlock_unlock(&hlp->lock);
|
---|
684 | }
|
---|
685 |
|
---|
686 | spinlock_unlock(&cmd_lock);
|
---|
687 |
|
---|
688 | return 1;
|
---|
689 | }
|
---|
690 |
|
---|
691 | /** Read 1 byte from phys memory or io port.
|
---|
692 | *
|
---|
693 | * @param argv Argument vector.
|
---|
694 | *
|
---|
695 | * @return 0 on failure, 1 on success.
|
---|
696 | */
|
---|
697 | static int cmd_pio_read_8(cmd_arg_t *argv)
|
---|
698 | {
|
---|
699 | uint8_t *ptr = NULL;
|
---|
700 |
|
---|
701 | #ifdef IO_SPACE_BOUNDARY
|
---|
702 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
703 | ptr = (void *) argv[0].intval;
|
---|
704 | else
|
---|
705 | #endif
|
---|
706 | ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
|
---|
707 | PAGE_SIZE, PAGE_NOT_CACHEABLE);
|
---|
708 |
|
---|
709 | const uint8_t val = pio_read_8(ptr);
|
---|
710 | printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val);
|
---|
711 |
|
---|
712 | #ifdef IO_SPACE_BOUNDARY
|
---|
713 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
714 | return 1;
|
---|
715 | #endif
|
---|
716 |
|
---|
717 | km_unmap((uintptr_t) ptr, sizeof(uint8_t));
|
---|
718 | return 1;
|
---|
719 | }
|
---|
720 |
|
---|
721 | /** Read 2 bytes from phys memory or io port.
|
---|
722 | *
|
---|
723 | * @param argv Argument vector.
|
---|
724 | *
|
---|
725 | * @return 0 on failure, 1 on success.
|
---|
726 | */
|
---|
727 | static int cmd_pio_read_16(cmd_arg_t *argv)
|
---|
728 | {
|
---|
729 | uint16_t *ptr = NULL;
|
---|
730 |
|
---|
731 | #ifdef IO_SPACE_BOUNDARY
|
---|
732 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
733 | ptr = (void *) argv[0].intval;
|
---|
734 | else
|
---|
735 | #endif
|
---|
736 | ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
|
---|
737 | PAGE_SIZE, PAGE_NOT_CACHEABLE);
|
---|
738 |
|
---|
739 | const uint16_t val = pio_read_16(ptr);
|
---|
740 | printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val);
|
---|
741 |
|
---|
742 | #ifdef IO_SPACE_BOUNDARY
|
---|
743 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
744 | return 1;
|
---|
745 | #endif
|
---|
746 |
|
---|
747 | km_unmap((uintptr_t) ptr, sizeof(uint16_t));
|
---|
748 | return 1;
|
---|
749 | }
|
---|
750 |
|
---|
751 | /** Read 4 bytes from phys memory or io port.
|
---|
752 | *
|
---|
753 | * @param argv Argument vector.
|
---|
754 | *
|
---|
755 | * @return 0 on failure, 1 on success.
|
---|
756 | */
|
---|
757 | static int cmd_pio_read_32(cmd_arg_t *argv)
|
---|
758 | {
|
---|
759 | uint32_t *ptr = NULL;
|
---|
760 |
|
---|
761 | #ifdef IO_SPACE_BOUNDARY
|
---|
762 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
763 | ptr = (void *) argv[0].intval;
|
---|
764 | else
|
---|
765 | #endif
|
---|
766 | ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
|
---|
767 | PAGE_SIZE, PAGE_NOT_CACHEABLE);
|
---|
768 |
|
---|
769 | const uint32_t val = pio_read_32(ptr);
|
---|
770 | printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val);
|
---|
771 |
|
---|
772 | #ifdef IO_SPACE_BOUNDARY
|
---|
773 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
774 | return 1;
|
---|
775 | #endif
|
---|
776 |
|
---|
777 | km_unmap((uintptr_t) ptr, sizeof(uint32_t));
|
---|
778 | return 1;
|
---|
779 | }
|
---|
780 |
|
---|
781 | /** Write 1 byte to phys memory or io port.
|
---|
782 | *
|
---|
783 | * @param argv Argument vector.
|
---|
784 | *
|
---|
785 | * @return 0 on failure, 1 on success.
|
---|
786 | */
|
---|
787 | static int cmd_pio_write_8(cmd_arg_t *argv)
|
---|
788 | {
|
---|
789 | uint8_t *ptr = NULL;
|
---|
790 |
|
---|
791 | #ifdef IO_SPACE_BOUNDARY
|
---|
792 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
793 | ptr = (void *) argv[0].intval;
|
---|
794 | else
|
---|
795 | #endif
|
---|
796 | ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
|
---|
797 | PAGE_SIZE, PAGE_NOT_CACHEABLE);
|
---|
798 |
|
---|
799 | printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval,
|
---|
800 | (uint8_t) argv[1].intval);
|
---|
801 | pio_write_8(ptr, (uint8_t) argv[1].intval);
|
---|
802 |
|
---|
803 | #ifdef IO_SPACE_BOUNDARY
|
---|
804 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
805 | return 1;
|
---|
806 | #endif
|
---|
807 |
|
---|
808 | km_unmap((uintptr_t) ptr, sizeof(uint8_t));
|
---|
809 | return 1;
|
---|
810 | }
|
---|
811 |
|
---|
812 | /** Write 2 bytes to phys memory or io port.
|
---|
813 | *
|
---|
814 | * @param argv Argument vector.
|
---|
815 | *
|
---|
816 | * @return 0 on failure, 1 on success.
|
---|
817 | */
|
---|
818 | static int cmd_pio_write_16(cmd_arg_t *argv)
|
---|
819 | {
|
---|
820 | uint16_t *ptr = NULL;
|
---|
821 |
|
---|
822 | #ifdef IO_SPACE_BOUNDARY
|
---|
823 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
824 | ptr = (void *) argv[0].intval;
|
---|
825 | else
|
---|
826 | #endif
|
---|
827 | ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
|
---|
828 | PAGE_SIZE, PAGE_NOT_CACHEABLE);
|
---|
829 |
|
---|
830 | printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval,
|
---|
831 | (uint16_t) argv[1].intval);
|
---|
832 | pio_write_16(ptr, (uint16_t) argv[1].intval);
|
---|
833 |
|
---|
834 | #ifdef IO_SPACE_BOUNDARY
|
---|
835 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
836 | return 1;
|
---|
837 | #endif
|
---|
838 |
|
---|
839 | km_unmap((uintptr_t) ptr, sizeof(uint16_t));
|
---|
840 | return 1;
|
---|
841 | }
|
---|
842 |
|
---|
843 | /** Write 4 bytes to phys memory or io port.
|
---|
844 | *
|
---|
845 | * @param argv Argument vector.
|
---|
846 | *
|
---|
847 | * @return 0 on failure, 1 on success.
|
---|
848 | */
|
---|
849 | static int cmd_pio_write_32(cmd_arg_t *argv)
|
---|
850 | {
|
---|
851 | uint32_t *ptr = NULL;
|
---|
852 |
|
---|
853 | #ifdef IO_SPACE_BOUNDARY
|
---|
854 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
855 | ptr = (void *) argv[0].intval;
|
---|
856 | else
|
---|
857 | #endif
|
---|
858 | ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
|
---|
859 | PAGE_SIZE, PAGE_NOT_CACHEABLE);
|
---|
860 |
|
---|
861 | printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval,
|
---|
862 | (uint32_t) argv[1].intval);
|
---|
863 | pio_write_32(ptr, (uint32_t) argv[1].intval);
|
---|
864 |
|
---|
865 | #ifdef IO_SPACE_BOUNDARY
|
---|
866 | if ((void *) argv->intval < IO_SPACE_BOUNDARY)
|
---|
867 | return 1;
|
---|
868 | #endif
|
---|
869 |
|
---|
870 | km_unmap((uintptr_t) ptr, sizeof(uint32_t));
|
---|
871 | return 1;
|
---|
872 | }
|
---|
873 |
|
---|
874 | /** Reboot the system.
|
---|
875 | *
|
---|
876 | * @param argv Argument vector.
|
---|
877 | *
|
---|
878 | * @return 0 on failure, 1 on success.
|
---|
879 | */
|
---|
880 | int cmd_reboot(cmd_arg_t *argv)
|
---|
881 | {
|
---|
882 | reboot();
|
---|
883 |
|
---|
884 | /* Not reached */
|
---|
885 | return 1;
|
---|
886 | }
|
---|
887 |
|
---|
888 | /** Print system uptime information.
|
---|
889 | *
|
---|
890 | * @param argv Argument vector.
|
---|
891 | *
|
---|
892 | * @return 0 on failure, 1 on success.
|
---|
893 | */
|
---|
894 | int cmd_uptime(cmd_arg_t *argv)
|
---|
895 | {
|
---|
896 | assert(uptime);
|
---|
897 |
|
---|
898 | /* This doesn't have to be very accurate */
|
---|
899 | sysarg_t sec = uptime->seconds1;
|
---|
900 |
|
---|
901 | printf("Up %" PRIun " days, %" PRIun " hours, %" PRIun " minutes, %" PRIun " seconds\n",
|
---|
902 | sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60);
|
---|
903 |
|
---|
904 | return 1;
|
---|
905 | }
|
---|
906 |
|
---|
907 | /** Describe specified command.
|
---|
908 | *
|
---|
909 | * @param argv Argument vector.
|
---|
910 | *
|
---|
911 | * @return 0 on failure, 1 on success.
|
---|
912 | */
|
---|
913 | int cmd_desc(cmd_arg_t *argv)
|
---|
914 | {
|
---|
915 | spinlock_lock(&cmd_lock);
|
---|
916 |
|
---|
917 | list_foreach(cmd_list, link, cmd_info_t, hlp) {
|
---|
918 | spinlock_lock(&hlp->lock);
|
---|
919 |
|
---|
920 | if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) {
|
---|
921 | printf("%s - %s\n", hlp->name, hlp->description);
|
---|
922 | if (hlp->help)
|
---|
923 | hlp->help();
|
---|
924 | spinlock_unlock(&hlp->lock);
|
---|
925 | break;
|
---|
926 | }
|
---|
927 |
|
---|
928 | spinlock_unlock(&hlp->lock);
|
---|
929 | }
|
---|
930 |
|
---|
931 | spinlock_unlock(&cmd_lock);
|
---|
932 |
|
---|
933 | return 1;
|
---|
934 | }
|
---|
935 |
|
---|
936 | /** Search symbol table */
|
---|
937 | int cmd_symaddr(cmd_arg_t *argv)
|
---|
938 | {
|
---|
939 | symtab_print_search((char *) argv->buffer);
|
---|
940 |
|
---|
941 | return 1;
|
---|
942 | }
|
---|
943 |
|
---|
944 | /** Call function with zero parameters */
|
---|
945 | int cmd_call0(cmd_arg_t *argv)
|
---|
946 | {
|
---|
947 | uintptr_t symaddr;
|
---|
948 | char *symbol;
|
---|
949 | sysarg_t (*fnc)(void);
|
---|
950 | fncptr_t fptr;
|
---|
951 | errno_t rc;
|
---|
952 |
|
---|
953 | symbol = (char *) argv->buffer;
|
---|
954 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
955 |
|
---|
956 | if (rc == ENOENT)
|
---|
957 | printf("Symbol %s not found.\n", symbol);
|
---|
958 | else if (rc == EOVERFLOW) {
|
---|
959 | symtab_print_search(symbol);
|
---|
960 | printf("Duplicate symbol, be more specific.\n");
|
---|
961 | } else if (rc == EOK) {
|
---|
962 | ipl_t ipl;
|
---|
963 |
|
---|
964 | ipl = interrupts_disable();
|
---|
965 | fnc = (sysarg_t (*)(void)) arch_construct_function(&fptr,
|
---|
966 | (void *) symaddr, (void *) cmd_call0);
|
---|
967 | printf("Calling %s() (%p)\n", symbol, (void *) symaddr);
|
---|
968 | printf("Result: %#" PRIxn "\n", fnc());
|
---|
969 | interrupts_restore(ipl);
|
---|
970 | } else {
|
---|
971 | printf("No symbol information available.\n");
|
---|
972 | }
|
---|
973 | return 1;
|
---|
974 | }
|
---|
975 |
|
---|
976 | /** Call function with zero parameters on each CPU */
|
---|
977 | int cmd_mcall0(cmd_arg_t *argv)
|
---|
978 | {
|
---|
979 | /*
|
---|
980 | * For each CPU, create a thread which will
|
---|
981 | * call the function.
|
---|
982 | */
|
---|
983 |
|
---|
984 | unsigned int i;
|
---|
985 | for (i = 0; i < config.cpu_count; i++) {
|
---|
986 | if (!cpus[i].active)
|
---|
987 | continue;
|
---|
988 |
|
---|
989 | thread_t *thread;
|
---|
990 | if ((thread = thread_create((void (*)(void *)) cmd_call0,
|
---|
991 | (void *) argv, TASK, THREAD_FLAG_NONE, "call0"))) {
|
---|
992 | printf("cpu%u: ", i);
|
---|
993 | thread_wire(thread, &cpus[i]);
|
---|
994 | thread_ready(thread);
|
---|
995 | thread_join(thread);
|
---|
996 | thread_detach(thread);
|
---|
997 | } else
|
---|
998 | printf("Unable to create thread for cpu%u\n", i);
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | return 1;
|
---|
1002 | }
|
---|
1003 |
|
---|
1004 | /** Call function with one parameter */
|
---|
1005 | int cmd_call1(cmd_arg_t *argv)
|
---|
1006 | {
|
---|
1007 | uintptr_t symaddr;
|
---|
1008 | char *symbol;
|
---|
1009 | sysarg_t (*fnc)(sysarg_t, ...);
|
---|
1010 | sysarg_t arg1 = argv[1].intval;
|
---|
1011 | fncptr_t fptr;
|
---|
1012 | errno_t rc;
|
---|
1013 |
|
---|
1014 | symbol = (char *) argv->buffer;
|
---|
1015 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
1016 |
|
---|
1017 | if (rc == ENOENT) {
|
---|
1018 | printf("Symbol %s not found.\n", symbol);
|
---|
1019 | } else if (rc == EOVERFLOW) {
|
---|
1020 | symtab_print_search(symbol);
|
---|
1021 | printf("Duplicate symbol, be more specific.\n");
|
---|
1022 | } else if (rc == EOK) {
|
---|
1023 | ipl_t ipl;
|
---|
1024 |
|
---|
1025 | ipl = interrupts_disable();
|
---|
1026 | fnc = (sysarg_t (*)(sysarg_t, ...))
|
---|
1027 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
1028 | (void *) cmd_call1);
|
---|
1029 | printf("Calling f(%#" PRIxn "): %p: %s\n", arg1,
|
---|
1030 | (void *) symaddr, symbol);
|
---|
1031 | printf("Result: %#" PRIxn "\n", fnc(arg1));
|
---|
1032 | interrupts_restore(ipl);
|
---|
1033 | } else {
|
---|
1034 | printf("No symbol information available.\n");
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | return 1;
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | /** Call function with two parameters */
|
---|
1041 | int cmd_call2(cmd_arg_t *argv)
|
---|
1042 | {
|
---|
1043 | uintptr_t symaddr;
|
---|
1044 | char *symbol;
|
---|
1045 | sysarg_t (*fnc)(sysarg_t, sysarg_t, ...);
|
---|
1046 | sysarg_t arg1 = argv[1].intval;
|
---|
1047 | sysarg_t arg2 = argv[2].intval;
|
---|
1048 | fncptr_t fptr;
|
---|
1049 | errno_t rc;
|
---|
1050 |
|
---|
1051 | symbol = (char *) argv->buffer;
|
---|
1052 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
1053 |
|
---|
1054 | if (rc == ENOENT) {
|
---|
1055 | printf("Symbol %s not found.\n", symbol);
|
---|
1056 | } else if (rc == EOVERFLOW) {
|
---|
1057 | symtab_print_search(symbol);
|
---|
1058 | printf("Duplicate symbol, be more specific.\n");
|
---|
1059 | } else if (rc == EOK) {
|
---|
1060 | ipl_t ipl;
|
---|
1061 |
|
---|
1062 | ipl = interrupts_disable();
|
---|
1063 | fnc = (sysarg_t (*)(sysarg_t, sysarg_t, ...))
|
---|
1064 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
1065 | (void *) cmd_call2);
|
---|
1066 | printf("Calling f(%#" PRIxn ", %#" PRIxn "): %p: %s\n",
|
---|
1067 | arg1, arg2, (void *) symaddr, symbol);
|
---|
1068 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2));
|
---|
1069 | interrupts_restore(ipl);
|
---|
1070 | } else {
|
---|
1071 | printf("No symbol information available.\n");
|
---|
1072 | }
|
---|
1073 | return 1;
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | /** Call function with three parameters */
|
---|
1077 | int cmd_call3(cmd_arg_t *argv)
|
---|
1078 | {
|
---|
1079 | uintptr_t symaddr;
|
---|
1080 | char *symbol;
|
---|
1081 | sysarg_t (*fnc)(sysarg_t, sysarg_t, sysarg_t, ...);
|
---|
1082 | sysarg_t arg1 = argv[1].intval;
|
---|
1083 | sysarg_t arg2 = argv[2].intval;
|
---|
1084 | sysarg_t arg3 = argv[3].intval;
|
---|
1085 | fncptr_t fptr;
|
---|
1086 | errno_t rc;
|
---|
1087 |
|
---|
1088 | symbol = (char *) argv->buffer;
|
---|
1089 | rc = symtab_addr_lookup(symbol, &symaddr);
|
---|
1090 |
|
---|
1091 | if (rc == ENOENT) {
|
---|
1092 | printf("Symbol %s not found.\n", symbol);
|
---|
1093 | } else if (rc == EOVERFLOW) {
|
---|
1094 | symtab_print_search(symbol);
|
---|
1095 | printf("Duplicate symbol, be more specific.\n");
|
---|
1096 | } else if (rc == EOK) {
|
---|
1097 | ipl_t ipl;
|
---|
1098 |
|
---|
1099 | ipl = interrupts_disable();
|
---|
1100 | fnc = (sysarg_t (*)(sysarg_t, sysarg_t, sysarg_t, ...))
|
---|
1101 | arch_construct_function(&fptr, (void *) symaddr,
|
---|
1102 | (void *) cmd_call3);
|
---|
1103 | printf("Calling f(%#" PRIxn ",%#" PRIxn ", %#" PRIxn "): %p: %s\n",
|
---|
1104 | arg1, arg2, arg3, (void *) symaddr, symbol);
|
---|
1105 | printf("Result: %#" PRIxn "\n", fnc(arg1, arg2, arg3));
|
---|
1106 | interrupts_restore(ipl);
|
---|
1107 | } else {
|
---|
1108 | printf("No symbol information available.\n");
|
---|
1109 | }
|
---|
1110 | return 1;
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | /** Print detailed description of 'describe' command. */
|
---|
1114 | void desc_help(void)
|
---|
1115 | {
|
---|
1116 | printf("Syntax: describe command_name\n");
|
---|
1117 | }
|
---|
1118 |
|
---|
1119 | /** Halt the kernel.
|
---|
1120 | *
|
---|
1121 | * @param argv Argument vector (ignored).
|
---|
1122 | *
|
---|
1123 | * @return 0 on failure, 1 on success (never returns).
|
---|
1124 | */
|
---|
1125 | int cmd_halt(cmd_arg_t *argv)
|
---|
1126 | {
|
---|
1127 | halt();
|
---|
1128 | return 1;
|
---|
1129 | }
|
---|
1130 |
|
---|
1131 | /** Command for printing TLB contents.
|
---|
1132 | *
|
---|
1133 | * @param argv Not used.
|
---|
1134 | *
|
---|
1135 | * @return Always returns 1.
|
---|
1136 | */
|
---|
1137 | int cmd_tlb(cmd_arg_t *argv)
|
---|
1138 | {
|
---|
1139 | tlb_print();
|
---|
1140 | return 1;
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 | /** Command for printing physical memory configuration.
|
---|
1144 | *
|
---|
1145 | * @param argv Not used.
|
---|
1146 | *
|
---|
1147 | * @return Always returns 1.
|
---|
1148 | */
|
---|
1149 | int cmd_physmem(cmd_arg_t *argv)
|
---|
1150 | {
|
---|
1151 | physmem_print();
|
---|
1152 | return 1;
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 | /** Write 4 byte value to address */
|
---|
1156 | int cmd_set4(cmd_arg_t *argv)
|
---|
1157 | {
|
---|
1158 | uintptr_t addr = 0; // Prevent -Werror=maybe-uninitialized
|
---|
1159 | uint32_t arg1 = argv[1].intval;
|
---|
1160 | bool pointer = false;
|
---|
1161 | errno_t rc;
|
---|
1162 |
|
---|
1163 | if (((char *) argv->buffer)[0] == '*') {
|
---|
1164 | rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr);
|
---|
1165 | pointer = true;
|
---|
1166 | } else if (((char *) argv->buffer)[0] >= '0' &&
|
---|
1167 | ((char *) argv->buffer)[0] <= '9') {
|
---|
1168 | uint64_t value;
|
---|
1169 | rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value);
|
---|
1170 | if (rc == EOK)
|
---|
1171 | addr = (uintptr_t) value;
|
---|
1172 | } else
|
---|
1173 | rc = symtab_addr_lookup((char *) argv->buffer, &addr);
|
---|
1174 |
|
---|
1175 | if (rc == ENOENT)
|
---|
1176 | printf("Symbol %s not found.\n", (char *) argv->buffer);
|
---|
1177 | else if (rc == EINVAL)
|
---|
1178 | printf("Invalid address.\n");
|
---|
1179 | else if (rc == EOVERFLOW) {
|
---|
1180 | symtab_print_search((char *) argv->buffer);
|
---|
1181 | printf("Duplicate symbol (be more specific) or address overflow.\n");
|
---|
1182 | } else if (rc == EOK) {
|
---|
1183 | if (pointer)
|
---|
1184 | addr = *(uintptr_t *) addr;
|
---|
1185 | printf("Writing %#" PRIx32 " -> %p\n", arg1, (void *) addr);
|
---|
1186 | *(uint32_t *) addr = arg1;
|
---|
1187 | } else
|
---|
1188 | printf("No symbol information available.\n");
|
---|
1189 |
|
---|
1190 | return 1;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | /** Command for listing slab allocator caches
|
---|
1194 | *
|
---|
1195 | * @param argv Ignored
|
---|
1196 | *
|
---|
1197 | * @return Always 1
|
---|
1198 | */
|
---|
1199 | int cmd_caches(cmd_arg_t *argv)
|
---|
1200 | {
|
---|
1201 | slab_print_list();
|
---|
1202 | return 1;
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | /** Command for dumping sysinfo
|
---|
1206 | *
|
---|
1207 | * @param argv Ignores
|
---|
1208 | *
|
---|
1209 | * @return Always 1
|
---|
1210 | */
|
---|
1211 | int cmd_sysinfo(cmd_arg_t *argv)
|
---|
1212 | {
|
---|
1213 | sysinfo_dump(NULL);
|
---|
1214 | return 1;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | /** Command for listing thread information
|
---|
1218 | *
|
---|
1219 | * @param argv Ignored
|
---|
1220 | *
|
---|
1221 | * @return Always 1
|
---|
1222 | */
|
---|
1223 | int cmd_threads(cmd_arg_t *argv)
|
---|
1224 | {
|
---|
1225 | if (str_cmp(flag_buf, "-a") == 0)
|
---|
1226 | thread_print_list(true);
|
---|
1227 | else if (str_cmp(flag_buf, "") == 0)
|
---|
1228 | thread_print_list(false);
|
---|
1229 | else
|
---|
1230 | printf("Unknown argument \"%s\".\n", flag_buf);
|
---|
1231 |
|
---|
1232 | return 1;
|
---|
1233 | }
|
---|
1234 |
|
---|
1235 | /** Command for listing task information
|
---|
1236 | *
|
---|
1237 | * @param argv Ignored
|
---|
1238 | *
|
---|
1239 | * @return Always 1
|
---|
1240 | */
|
---|
1241 | int cmd_tasks(cmd_arg_t *argv)
|
---|
1242 | {
|
---|
1243 | if (str_cmp(flag_buf, "-a") == 0)
|
---|
1244 | task_print_list(true);
|
---|
1245 | else if (str_cmp(flag_buf, "") == 0)
|
---|
1246 | task_print_list(false);
|
---|
1247 | else
|
---|
1248 | printf("Unknown argument \"%s\".\n", flag_buf);
|
---|
1249 |
|
---|
1250 | return 1;
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 | #ifdef CONFIG_UDEBUG
|
---|
1254 |
|
---|
1255 | /** Command for printing thread stack trace
|
---|
1256 | *
|
---|
1257 | * @param argv Integer argument from cmdline expected
|
---|
1258 | *
|
---|
1259 | * return Always 1
|
---|
1260 | *
|
---|
1261 | */
|
---|
1262 | int cmd_btrace(cmd_arg_t *argv)
|
---|
1263 | {
|
---|
1264 | thread_stack_trace(argv[0].intval);
|
---|
1265 | return 1;
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | #endif /* CONFIG_UDEBUG */
|
---|
1269 |
|
---|
1270 | /** Command for printing scheduler information
|
---|
1271 | *
|
---|
1272 | * @param argv Ignores
|
---|
1273 | *
|
---|
1274 | * @return Always 1
|
---|
1275 | */
|
---|
1276 | int cmd_sched(cmd_arg_t *argv)
|
---|
1277 | {
|
---|
1278 | sched_print_list();
|
---|
1279 | return 1;
|
---|
1280 | }
|
---|
1281 |
|
---|
1282 | /** Command for listing memory zones
|
---|
1283 | *
|
---|
1284 | * @param argv Ignored
|
---|
1285 | *
|
---|
1286 | * return Always 1
|
---|
1287 | */
|
---|
1288 | int cmd_zones(cmd_arg_t *argv)
|
---|
1289 | {
|
---|
1290 | zones_print_list();
|
---|
1291 | return 1;
|
---|
1292 | }
|
---|
1293 |
|
---|
1294 | /** Command for memory zone details
|
---|
1295 | *
|
---|
1296 | * @param argv Integer argument from cmdline expected
|
---|
1297 | *
|
---|
1298 | * return Always 1
|
---|
1299 | */
|
---|
1300 | int cmd_zone(cmd_arg_t *argv)
|
---|
1301 | {
|
---|
1302 | zone_print_one(argv[0].intval);
|
---|
1303 | return 1;
|
---|
1304 | }
|
---|
1305 |
|
---|
1306 | /** Command for printing task IPC details
|
---|
1307 | *
|
---|
1308 | * @param argv Integer argument from cmdline expected
|
---|
1309 | *
|
---|
1310 | * return Always 1
|
---|
1311 | */
|
---|
1312 | int cmd_ipc(cmd_arg_t *argv)
|
---|
1313 | {
|
---|
1314 | ipc_print_task(argv[0].intval);
|
---|
1315 | return 1;
|
---|
1316 | }
|
---|
1317 |
|
---|
1318 | /** Command for killing a task
|
---|
1319 | *
|
---|
1320 | * @param argv Integer argument from cmdline expected
|
---|
1321 | *
|
---|
1322 | * return 0 on failure, 1 on success.
|
---|
1323 | */
|
---|
1324 | int cmd_kill(cmd_arg_t *argv)
|
---|
1325 | {
|
---|
1326 | if (task_kill(argv[0].intval) != EOK)
|
---|
1327 | return 0;
|
---|
1328 |
|
---|
1329 | return 1;
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | /** Command for listing processors.
|
---|
1333 | *
|
---|
1334 | * @param argv Ignored.
|
---|
1335 | *
|
---|
1336 | * return Always 1.
|
---|
1337 | */
|
---|
1338 | int cmd_cpus(cmd_arg_t *argv)
|
---|
1339 | {
|
---|
1340 | cpu_list();
|
---|
1341 | return 1;
|
---|
1342 | }
|
---|
1343 |
|
---|
1344 | /** Command for printing kernel version.
|
---|
1345 | *
|
---|
1346 | * @param argv Ignored.
|
---|
1347 | *
|
---|
1348 | * return Always 1.
|
---|
1349 | */
|
---|
1350 | int cmd_version(cmd_arg_t *argv)
|
---|
1351 | {
|
---|
1352 | version_print();
|
---|
1353 | return 1;
|
---|
1354 | }
|
---|
1355 |
|
---|
1356 | /** Command for returning console back to userspace.
|
---|
1357 | *
|
---|
1358 | * @param argv Ignored.
|
---|
1359 | *
|
---|
1360 | * return Always 1.
|
---|
1361 | */
|
---|
1362 | int cmd_continue(cmd_arg_t *argv)
|
---|
1363 | {
|
---|
1364 | printf("The kernel will now relinquish the console.\n");
|
---|
1365 | release_console();
|
---|
1366 | indev_pop_character(stdin);
|
---|
1367 |
|
---|
1368 | return 1;
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 | #ifdef CONFIG_TEST
|
---|
1372 | static bool run_test(const test_t *test)
|
---|
1373 | {
|
---|
1374 | printf("%s (%s)\n", test->name, test->desc);
|
---|
1375 |
|
---|
1376 | /*
|
---|
1377 | * Update and read thread accounting
|
---|
1378 | * for benchmarking
|
---|
1379 | */
|
---|
1380 | irq_spinlock_lock(&TASK->lock, true);
|
---|
1381 | uint64_t ucycles0, kcycles0;
|
---|
1382 | task_get_accounting(TASK, &ucycles0, &kcycles0);
|
---|
1383 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
1384 |
|
---|
1385 | /* Execute the test */
|
---|
1386 | test_quiet = false;
|
---|
1387 | const char *ret = test->entry();
|
---|
1388 |
|
---|
1389 | /* Update and read thread accounting */
|
---|
1390 | uint64_t ucycles1, kcycles1;
|
---|
1391 | irq_spinlock_lock(&TASK->lock, true);
|
---|
1392 | task_get_accounting(TASK, &ucycles1, &kcycles1);
|
---|
1393 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
1394 |
|
---|
1395 | uint64_t ucycles, kcycles;
|
---|
1396 | char usuffix, ksuffix;
|
---|
1397 | order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
|
---|
1398 | order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
|
---|
1399 |
|
---|
1400 | printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n",
|
---|
1401 | ucycles, usuffix, kcycles, ksuffix);
|
---|
1402 |
|
---|
1403 | if (ret == NULL) {
|
---|
1404 | printf("Test passed\n");
|
---|
1405 | return true;
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | printf("%s\n", ret);
|
---|
1409 | return false;
|
---|
1410 | }
|
---|
1411 |
|
---|
1412 | static bool run_bench(const test_t *test, const uint32_t cnt)
|
---|
1413 | {
|
---|
1414 | uint32_t i;
|
---|
1415 | bool ret = true;
|
---|
1416 | uint64_t ucycles, kcycles;
|
---|
1417 | char usuffix, ksuffix;
|
---|
1418 |
|
---|
1419 | if (cnt < 1)
|
---|
1420 | return true;
|
---|
1421 |
|
---|
1422 | uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt);
|
---|
1423 | if (data == NULL) {
|
---|
1424 | printf("Error allocating memory for statistics\n");
|
---|
1425 | return false;
|
---|
1426 | }
|
---|
1427 |
|
---|
1428 | for (i = 0; i < cnt; i++) {
|
---|
1429 | printf("%s (%u/%u) ... ", test->name, i + 1, cnt);
|
---|
1430 |
|
---|
1431 | /*
|
---|
1432 | * Update and read thread accounting
|
---|
1433 | * for benchmarking
|
---|
1434 | */
|
---|
1435 | irq_spinlock_lock(&TASK->lock, true);
|
---|
1436 | uint64_t ucycles0, kcycles0;
|
---|
1437 | task_get_accounting(TASK, &ucycles0, &kcycles0);
|
---|
1438 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
1439 |
|
---|
1440 | /* Execute the test */
|
---|
1441 | test_quiet = true;
|
---|
1442 | const char *test_ret = test->entry();
|
---|
1443 |
|
---|
1444 | /* Update and read thread accounting */
|
---|
1445 | irq_spinlock_lock(&TASK->lock, true);
|
---|
1446 | uint64_t ucycles1, kcycles1;
|
---|
1447 | task_get_accounting(TASK, &ucycles1, &kcycles1);
|
---|
1448 | irq_spinlock_unlock(&TASK->lock, true);
|
---|
1449 |
|
---|
1450 | if (test_ret != NULL) {
|
---|
1451 | printf("%s\n", test_ret);
|
---|
1452 | ret = false;
|
---|
1453 | break;
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0;
|
---|
1457 | order_suffix(ucycles1 - ucycles0, &ucycles, &usuffix);
|
---|
1458 | order_suffix(kcycles1 - kcycles0, &kcycles, &ksuffix);
|
---|
1459 | printf("OK (%" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles)\n",
|
---|
1460 | ucycles, usuffix, kcycles, ksuffix);
|
---|
1461 | }
|
---|
1462 |
|
---|
1463 | if (ret) {
|
---|
1464 | printf("\n");
|
---|
1465 |
|
---|
1466 | uint64_t sum = 0;
|
---|
1467 |
|
---|
1468 | for (i = 0; i < cnt; i++) {
|
---|
1469 | sum += data[i];
|
---|
1470 | }
|
---|
1471 |
|
---|
1472 | order_suffix(sum / (uint64_t) cnt, &ucycles, &usuffix);
|
---|
1473 | printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix);
|
---|
1474 | }
|
---|
1475 |
|
---|
1476 | free(data);
|
---|
1477 |
|
---|
1478 | return ret;
|
---|
1479 | }
|
---|
1480 |
|
---|
1481 | static void list_tests(void)
|
---|
1482 | {
|
---|
1483 | size_t len = 0;
|
---|
1484 | test_t *test;
|
---|
1485 |
|
---|
1486 | for (test = tests; test->name != NULL; test++) {
|
---|
1487 | if (str_length(test->name) > len)
|
---|
1488 | len = str_length(test->name);
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | unsigned int _len = (unsigned int) len;
|
---|
1492 | if ((_len != len) || (((int) _len) < 0)) {
|
---|
1493 | printf("Command length overflow\n");
|
---|
1494 | return;
|
---|
1495 | }
|
---|
1496 |
|
---|
1497 | for (test = tests; test->name != NULL; test++)
|
---|
1498 | printf("%-*s %s%s\n", _len, test->name, test->desc,
|
---|
1499 | (test->safe ? "" : " (unsafe)"));
|
---|
1500 |
|
---|
1501 | printf("%-*s Run all safe tests\n", _len, "*");
|
---|
1502 | }
|
---|
1503 |
|
---|
1504 | /** Command for listing and running kernel tests
|
---|
1505 | *
|
---|
1506 | * @param argv Argument vector.
|
---|
1507 | *
|
---|
1508 | * return Always 1.
|
---|
1509 | *
|
---|
1510 | */
|
---|
1511 | int cmd_test(cmd_arg_t *argv)
|
---|
1512 | {
|
---|
1513 | test_t *test;
|
---|
1514 |
|
---|
1515 | if (str_cmp((char *) argv->buffer, "*") == 0) {
|
---|
1516 | for (test = tests; test->name != NULL; test++) {
|
---|
1517 | if (test->safe) {
|
---|
1518 | printf("\n");
|
---|
1519 | if (!run_test(test))
|
---|
1520 | break;
|
---|
1521 | }
|
---|
1522 | }
|
---|
1523 | } else if (str_cmp((char *) argv->buffer, "") != 0) {
|
---|
1524 | bool fnd = false;
|
---|
1525 |
|
---|
1526 | for (test = tests; test->name != NULL; test++) {
|
---|
1527 | if (str_cmp(test->name, (char *) argv->buffer) == 0) {
|
---|
1528 | fnd = true;
|
---|
1529 | run_test(test);
|
---|
1530 | break;
|
---|
1531 | }
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | if (!fnd)
|
---|
1535 | printf("Unknown test\n");
|
---|
1536 | } else
|
---|
1537 | list_tests();
|
---|
1538 |
|
---|
1539 | return 1;
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | /** Command for returning kernel tests as benchmarks
|
---|
1543 | *
|
---|
1544 | * @param argv Argument vector.
|
---|
1545 | *
|
---|
1546 | * return Always 1.
|
---|
1547 | */
|
---|
1548 | int cmd_bench(cmd_arg_t *argv)
|
---|
1549 | {
|
---|
1550 | test_t *test;
|
---|
1551 | uint32_t cnt = argv[1].intval;
|
---|
1552 |
|
---|
1553 | if (str_cmp((char *) argv->buffer, "*") == 0) {
|
---|
1554 | for (test = tests; test->name != NULL; test++) {
|
---|
1555 | if (test->safe) {
|
---|
1556 | if (!run_bench(test, cnt))
|
---|
1557 | break;
|
---|
1558 | }
|
---|
1559 | }
|
---|
1560 | } else {
|
---|
1561 | bool fnd = false;
|
---|
1562 |
|
---|
1563 | for (test = tests; test->name != NULL; test++) {
|
---|
1564 | if (str_cmp(test->name, (char *) argv->buffer) == 0) {
|
---|
1565 | fnd = true;
|
---|
1566 |
|
---|
1567 | if (test->safe)
|
---|
1568 | run_bench(test, cnt);
|
---|
1569 | else
|
---|
1570 | printf("Unsafe test\n");
|
---|
1571 |
|
---|
1572 | break;
|
---|
1573 | }
|
---|
1574 | }
|
---|
1575 |
|
---|
1576 | if (!fnd)
|
---|
1577 | printf("Unknown test\n");
|
---|
1578 | }
|
---|
1579 |
|
---|
1580 | return 1;
|
---|
1581 | }
|
---|
1582 |
|
---|
1583 | #endif
|
---|
1584 |
|
---|
1585 | /** @}
|
---|
1586 | */
|
---|