Rev 2275 | Rev 3065 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
596 | jermar | 1 | /* |
2071 | jermar | 2 | * Copyright (c) 2005 Jakub Jermar |
596 | 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 | |||
1888 | jermar | 29 | /** @addtogroup genericconsole |
1702 | cejka | 30 | * @{ |
31 | */ |
||
32 | |||
596 | jermar | 33 | /** |
1264 | jermar | 34 | * @file cmd.c |
35 | * @brief Kernel console command wrappers. |
||
36 | * |
||
596 | jermar | 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> |
||
1474 | palkovsky | 44 | #include <console/console.h> |
596 | jermar | 45 | #include <console/kconsole.h> |
46 | #include <print.h> |
||
47 | #include <panic.h> |
||
48 | #include <arch/types.h> |
||
788 | jermar | 49 | #include <adt/list.h> |
596 | jermar | 50 | #include <arch.h> |
2227 | decky | 51 | #include <config.h> |
596 | jermar | 52 | #include <func.h> |
53 | #include <macros.h> |
||
54 | #include <debug.h> |
||
55 | #include <symtab.h> |
||
673 | jermar | 56 | #include <cpu.h> |
596 | jermar | 57 | #include <mm/tlb.h> |
58 | #include <arch/mm/tlb.h> |
||
668 | bondari | 59 | #include <mm/frame.h> |
673 | jermar | 60 | #include <main/version.h> |
759 | palkovsky | 61 | #include <mm/slab.h> |
775 | palkovsky | 62 | #include <proc/scheduler.h> |
777 | palkovsky | 63 | #include <proc/thread.h> |
1060 | palkovsky | 64 | #include <proc/task.h> |
1573 | palkovsky | 65 | #include <ipc/ipc.h> |
1712 | palkovsky | 66 | #include <ipc/irq.h> |
596 | jermar | 67 | |
2019 | decky | 68 | #ifdef CONFIG_TEST |
69 | #include <test.h> |
||
70 | #endif |
||
71 | |||
1702 | cejka | 72 | /* Data and methods for 'help' command. */ |
596 | jermar | 73 | static int cmd_help(cmd_arg_t *argv); |
74 | static cmd_info_t help_info = { |
||
75 | .name = "help", |
||
76 | .description = "List of supported commands.", |
||
77 | .func = cmd_help, |
||
78 | .argc = 0 |
||
79 | }; |
||
80 | |||
609 | palkovsky | 81 | static cmd_info_t exit_info = { |
82 | .name = "exit", |
||
2227 | decky | 83 | .description = "Exit kconsole.", |
609 | palkovsky | 84 | .argc = 0 |
85 | }; |
||
86 | |||
2227 | decky | 87 | static int cmd_reboot(cmd_arg_t *argv); |
88 | static cmd_info_t reboot_info = { |
||
89 | .name = "reboot", |
||
90 | .description = "Reboot.", |
||
91 | .func = cmd_reboot, |
||
92 | .argc = 0 |
||
93 | }; |
||
94 | |||
2275 | decky | 95 | static int cmd_uptime(cmd_arg_t *argv); |
96 | static cmd_info_t uptime_info = { |
||
97 | .name = "uptime", |
||
98 | .description = "Print uptime information.", |
||
99 | .func = cmd_uptime, |
||
100 | .argc = 0 |
||
101 | }; |
||
102 | |||
1474 | palkovsky | 103 | static int cmd_continue(cmd_arg_t *argv); |
104 | static cmd_info_t continue_info = { |
||
105 | .name = "continue", |
||
2019 | decky | 106 | .description = "Return console back to userspace.", |
1474 | palkovsky | 107 | .func = cmd_continue, |
108 | .argc = 0 |
||
109 | }; |
||
110 | |||
2019 | decky | 111 | #ifdef CONFIG_TEST |
112 | static int cmd_tests(cmd_arg_t *argv); |
||
113 | static cmd_info_t tests_info = { |
||
114 | .name = "tests", |
||
115 | .description = "Print available kernel tests.", |
||
116 | .func = cmd_tests, |
||
117 | .argc = 0 |
||
118 | }; |
||
119 | |||
120 | static char test_buf[MAX_CMDLINE + 1]; |
||
121 | static int cmd_test(cmd_arg_t *argv); |
||
122 | static cmd_arg_t test_argv[] = { |
||
123 | { |
||
124 | .type = ARG_TYPE_STRING, |
||
125 | .buffer = test_buf, |
||
126 | .len = sizeof(test_buf) |
||
127 | } |
||
128 | }; |
||
129 | static cmd_info_t test_info = { |
||
130 | .name = "test", |
||
131 | .description = "Run kernel test.", |
||
132 | .func = cmd_test, |
||
133 | .argc = 1, |
||
134 | .argv = test_argv |
||
135 | }; |
||
2050 | decky | 136 | |
137 | static int cmd_bench(cmd_arg_t *argv); |
||
138 | static cmd_arg_t bench_argv[] = { |
||
139 | { |
||
140 | .type = ARG_TYPE_STRING, |
||
141 | .buffer = test_buf, |
||
142 | .len = sizeof(test_buf) |
||
143 | }, |
||
144 | { |
||
145 | .type = ARG_TYPE_INT, |
||
146 | } |
||
147 | }; |
||
148 | static cmd_info_t bench_info = { |
||
149 | .name = "bench", |
||
150 | .description = "Run kernel test as benchmark.", |
||
151 | .func = cmd_bench, |
||
152 | .argc = 2, |
||
153 | .argv = bench_argv |
||
154 | }; |
||
2019 | decky | 155 | #endif |
156 | |||
1702 | cejka | 157 | /* Data and methods for 'description' command. */ |
596 | jermar | 158 | static int cmd_desc(cmd_arg_t *argv); |
159 | static void desc_help(void); |
||
160 | static char desc_buf[MAX_CMDLINE+1]; |
||
161 | static cmd_arg_t desc_argv = { |
||
162 | .type = ARG_TYPE_STRING, |
||
163 | .buffer = desc_buf, |
||
164 | .len = sizeof(desc_buf) |
||
165 | }; |
||
166 | static cmd_info_t desc_info = { |
||
167 | .name = "describe", |
||
168 | .description = "Describe specified command.", |
||
169 | .help = desc_help, |
||
170 | .func = cmd_desc, |
||
171 | .argc = 1, |
||
172 | .argv = &desc_argv |
||
173 | }; |
||
174 | |||
1702 | cejka | 175 | /* Data and methods for 'symaddr' command. */ |
596 | jermar | 176 | static int cmd_symaddr(cmd_arg_t *argv); |
177 | static char symaddr_buf[MAX_CMDLINE+1]; |
||
178 | static cmd_arg_t symaddr_argv = { |
||
179 | .type = ARG_TYPE_STRING, |
||
180 | .buffer = symaddr_buf, |
||
181 | .len = sizeof(symaddr_buf) |
||
182 | }; |
||
183 | static cmd_info_t symaddr_info = { |
||
184 | .name = "symaddr", |
||
185 | .description = "Return symbol address.", |
||
186 | .func = cmd_symaddr, |
||
187 | .argc = 1, |
||
188 | .argv = &symaddr_argv |
||
189 | }; |
||
190 | |||
603 | palkovsky | 191 | static char set_buf[MAX_CMDLINE+1]; |
192 | static int cmd_set4(cmd_arg_t *argv); |
||
193 | static cmd_arg_t set4_argv[] = { |
||
194 | { |
||
195 | .type = ARG_TYPE_STRING, |
||
196 | .buffer = set_buf, |
||
197 | .len = sizeof(set_buf) |
||
198 | }, |
||
199 | { |
||
200 | .type = ARG_TYPE_INT |
||
201 | } |
||
202 | }; |
||
203 | static cmd_info_t set4_info = { |
||
204 | .name = "set4", |
||
205 | .description = "set <dest_addr> <value> - 4byte version", |
||
206 | .func = cmd_set4, |
||
207 | .argc = 2, |
||
208 | .argv = set4_argv |
||
209 | }; |
||
210 | |||
1702 | cejka | 211 | /* Data and methods for 'call0' command. */ |
2223 | decky | 212 | static char call0_buf[MAX_CMDLINE + 1]; |
213 | static char carg1_buf[MAX_CMDLINE + 1]; |
||
214 | static char carg2_buf[MAX_CMDLINE + 1]; |
||
215 | static char carg3_buf[MAX_CMDLINE + 1]; |
||
596 | jermar | 216 | |
217 | static int cmd_call0(cmd_arg_t *argv); |
||
218 | static cmd_arg_t call0_argv = { |
||
219 | .type = ARG_TYPE_STRING, |
||
220 | .buffer = call0_buf, |
||
221 | .len = sizeof(call0_buf) |
||
222 | }; |
||
223 | static cmd_info_t call0_info = { |
||
224 | .name = "call0", |
||
225 | .description = "call0 <function> -> call function().", |
||
226 | .func = cmd_call0, |
||
227 | .argc = 1, |
||
228 | .argv = &call0_argv |
||
229 | }; |
||
230 | |||
2223 | decky | 231 | /* Data and methods for 'mcall0' command. */ |
232 | static int cmd_mcall0(cmd_arg_t *argv); |
||
233 | static cmd_arg_t mcall0_argv = { |
||
234 | .type = ARG_TYPE_STRING, |
||
235 | .buffer = call0_buf, |
||
236 | .len = sizeof(call0_buf) |
||
237 | }; |
||
238 | static cmd_info_t mcall0_info = { |
||
239 | .name = "mcall0", |
||
240 | .description = "mcall0 <function> -> call function() on each CPU.", |
||
241 | .func = cmd_mcall0, |
||
242 | .argc = 1, |
||
243 | .argv = &mcall0_argv |
||
244 | }; |
||
245 | |||
1702 | cejka | 246 | /* Data and methods for 'call1' command. */ |
596 | jermar | 247 | static int cmd_call1(cmd_arg_t *argv); |
248 | static cmd_arg_t call1_argv[] = { |
||
249 | { |
||
250 | .type = ARG_TYPE_STRING, |
||
251 | .buffer = call0_buf, |
||
252 | .len = sizeof(call0_buf) |
||
253 | }, |
||
254 | { |
||
255 | .type = ARG_TYPE_VAR, |
||
256 | .buffer = carg1_buf, |
||
257 | .len = sizeof(carg1_buf) |
||
258 | } |
||
259 | }; |
||
260 | static cmd_info_t call1_info = { |
||
261 | .name = "call1", |
||
262 | .description = "call1 <function> <arg1> -> call function(arg1).", |
||
263 | .func = cmd_call1, |
||
264 | .argc = 2, |
||
265 | .argv = call1_argv |
||
266 | }; |
||
267 | |||
1702 | cejka | 268 | /* Data and methods for 'call2' command. */ |
596 | jermar | 269 | static int cmd_call2(cmd_arg_t *argv); |
270 | static cmd_arg_t call2_argv[] = { |
||
271 | { |
||
272 | .type = ARG_TYPE_STRING, |
||
273 | .buffer = call0_buf, |
||
274 | .len = sizeof(call0_buf) |
||
275 | }, |
||
276 | { |
||
277 | .type = ARG_TYPE_VAR, |
||
278 | .buffer = carg1_buf, |
||
279 | .len = sizeof(carg1_buf) |
||
280 | }, |
||
281 | { |
||
282 | .type = ARG_TYPE_VAR, |
||
283 | .buffer = carg2_buf, |
||
284 | .len = sizeof(carg2_buf) |
||
285 | } |
||
286 | }; |
||
287 | static cmd_info_t call2_info = { |
||
288 | .name = "call2", |
||
289 | .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).", |
||
290 | .func = cmd_call2, |
||
291 | .argc = 3, |
||
292 | .argv = call2_argv |
||
293 | }; |
||
294 | |||
1702 | cejka | 295 | /* Data and methods for 'call3' command. */ |
596 | jermar | 296 | static int cmd_call3(cmd_arg_t *argv); |
297 | static cmd_arg_t call3_argv[] = { |
||
298 | { |
||
299 | .type = ARG_TYPE_STRING, |
||
300 | .buffer = call0_buf, |
||
301 | .len = sizeof(call0_buf) |
||
302 | }, |
||
303 | { |
||
304 | .type = ARG_TYPE_VAR, |
||
305 | .buffer = carg1_buf, |
||
306 | .len = sizeof(carg1_buf) |
||
307 | }, |
||
308 | { |
||
309 | .type = ARG_TYPE_VAR, |
||
310 | .buffer = carg2_buf, |
||
311 | .len = sizeof(carg2_buf) |
||
312 | }, |
||
313 | { |
||
314 | .type = ARG_TYPE_VAR, |
||
315 | .buffer = carg3_buf, |
||
316 | .len = sizeof(carg3_buf) |
||
317 | } |
||
318 | |||
319 | }; |
||
320 | static cmd_info_t call3_info = { |
||
321 | .name = "call3", |
||
322 | .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).", |
||
323 | .func = cmd_call3, |
||
324 | .argc = 4, |
||
325 | .argv = call3_argv |
||
326 | }; |
||
327 | |||
1702 | cejka | 328 | /* Data and methods for 'halt' command. */ |
596 | jermar | 329 | static int cmd_halt(cmd_arg_t *argv); |
330 | static cmd_info_t halt_info = { |
||
331 | .name = "halt", |
||
332 | .description = "Halt the kernel.", |
||
333 | .func = cmd_halt, |
||
334 | .argc = 0 |
||
335 | }; |
||
336 | |||
1702 | cejka | 337 | /* Data and methods for 'tlb' command. */ |
673 | jermar | 338 | static int cmd_tlb(cmd_arg_t *argv); |
339 | cmd_info_t tlb_info = { |
||
340 | .name = "tlb", |
||
596 | jermar | 341 | .description = "Print TLB of current processor.", |
342 | .help = NULL, |
||
673 | jermar | 343 | .func = cmd_tlb, |
596 | jermar | 344 | .argc = 0, |
345 | .argv = NULL |
||
346 | }; |
||
347 | |||
777 | palkovsky | 348 | static int cmd_threads(cmd_arg_t *argv); |
349 | static cmd_info_t threads_info = { |
||
350 | .name = "threads", |
||
1695 | jermar | 351 | .description = "List all threads.", |
777 | palkovsky | 352 | .func = cmd_threads, |
353 | .argc = 0 |
||
354 | }; |
||
668 | bondari | 355 | |
1060 | palkovsky | 356 | static int cmd_tasks(cmd_arg_t *argv); |
357 | static cmd_info_t tasks_info = { |
||
358 | .name = "tasks", |
||
1695 | jermar | 359 | .description = "List all tasks.", |
1060 | palkovsky | 360 | .func = cmd_tasks, |
361 | .argc = 0 |
||
362 | }; |
||
777 | palkovsky | 363 | |
1060 | palkovsky | 364 | |
775 | palkovsky | 365 | static int cmd_sched(cmd_arg_t *argv); |
366 | static cmd_info_t sched_info = { |
||
367 | .name = "scheduler", |
||
1695 | jermar | 368 | .description = "List all scheduler information.", |
775 | palkovsky | 369 | .func = cmd_sched, |
370 | .argc = 0 |
||
371 | }; |
||
372 | |||
759 | palkovsky | 373 | static int cmd_slabs(cmd_arg_t *argv); |
374 | static cmd_info_t slabs_info = { |
||
375 | .name = "slabs", |
||
1695 | jermar | 376 | .description = "List slab caches.", |
759 | palkovsky | 377 | .func = cmd_slabs, |
378 | .argc = 0 |
||
379 | }; |
||
380 | |||
1702 | cejka | 381 | /* Data and methods for 'zones' command */ |
668 | bondari | 382 | static int cmd_zones(cmd_arg_t *argv); |
383 | static cmd_info_t zones_info = { |
||
384 | .name = "zones", |
||
385 | .description = "List of memory zones.", |
||
386 | .func = cmd_zones, |
||
387 | .argc = 0 |
||
388 | }; |
||
389 | |||
1702 | cejka | 390 | /* Data and methods for 'ipc_task' command */ |
1573 | palkovsky | 391 | static int cmd_ipc_task(cmd_arg_t *argv); |
392 | static cmd_arg_t ipc_task_argv = { |
||
393 | .type = ARG_TYPE_INT, |
||
394 | }; |
||
395 | static cmd_info_t ipc_task_info = { |
||
396 | .name = "ipc_task", |
||
1695 | jermar | 397 | .description = "ipc_task <taskid> Show IPC information of given task.", |
1573 | palkovsky | 398 | .func = cmd_ipc_task, |
399 | .argc = 1, |
||
400 | .argv = &ipc_task_argv |
||
401 | }; |
||
402 | |||
1702 | cejka | 403 | /* Data and methods for 'zone' command */ |
668 | bondari | 404 | static int cmd_zone(cmd_arg_t *argv); |
405 | static cmd_arg_t zone_argv = { |
||
406 | .type = ARG_TYPE_INT, |
||
407 | }; |
||
408 | |||
409 | static cmd_info_t zone_info = { |
||
410 | .name = "zone", |
||
411 | .description = "Show memory zone structure.", |
||
412 | .func = cmd_zone, |
||
413 | .argc = 1, |
||
414 | .argv = &zone_argv |
||
415 | }; |
||
416 | |||
1702 | cejka | 417 | /* Data and methods for 'cpus' command. */ |
673 | jermar | 418 | static int cmd_cpus(cmd_arg_t *argv); |
419 | cmd_info_t cpus_info = { |
||
420 | .name = "cpus", |
||
421 | .description = "List all processors.", |
||
422 | .help = NULL, |
||
423 | .func = cmd_cpus, |
||
424 | .argc = 0, |
||
425 | .argv = NULL |
||
426 | }; |
||
668 | bondari | 427 | |
1702 | cejka | 428 | /* Data and methods for 'version' command. */ |
673 | jermar | 429 | static int cmd_version(cmd_arg_t *argv); |
430 | cmd_info_t version_info = { |
||
431 | .name = "version", |
||
432 | .description = "Print version information.", |
||
433 | .help = NULL, |
||
434 | .func = cmd_version, |
||
435 | .argc = 0, |
||
436 | .argv = NULL |
||
437 | }; |
||
668 | bondari | 438 | |
775 | palkovsky | 439 | static cmd_info_t *basic_commands[] = { |
440 | &call0_info, |
||
2223 | decky | 441 | &mcall0_info, |
775 | palkovsky | 442 | &call1_info, |
443 | &call2_info, |
||
444 | &call3_info, |
||
1474 | palkovsky | 445 | &continue_info, |
775 | palkovsky | 446 | &cpus_info, |
447 | &desc_info, |
||
448 | &exit_info, |
||
2227 | decky | 449 | &reboot_info, |
2275 | decky | 450 | &uptime_info, |
775 | palkovsky | 451 | &halt_info, |
452 | &help_info, |
||
1573 | palkovsky | 453 | &ipc_task_info, |
775 | palkovsky | 454 | &set4_info, |
455 | &slabs_info, |
||
456 | &symaddr_info, |
||
457 | &sched_info, |
||
777 | palkovsky | 458 | &threads_info, |
1060 | palkovsky | 459 | &tasks_info, |
775 | palkovsky | 460 | &tlb_info, |
461 | &version_info, |
||
462 | &zones_info, |
||
463 | &zone_info, |
||
2019 | decky | 464 | #ifdef CONFIG_TEST |
465 | &tests_info, |
||
466 | &test_info, |
||
2050 | decky | 467 | &bench_info, |
2019 | decky | 468 | #endif |
775 | palkovsky | 469 | NULL |
470 | }; |
||
673 | jermar | 471 | |
472 | |||
596 | jermar | 473 | /** Initialize command info structure. |
474 | * |
||
475 | * @param cmd Command info structure. |
||
476 | * |
||
477 | */ |
||
478 | void cmd_initialize(cmd_info_t *cmd) |
||
479 | { |
||
480 | spinlock_initialize(&cmd->lock, "cmd"); |
||
481 | link_initialize(&cmd->link); |
||
482 | } |
||
483 | |||
484 | /** Initialize and register commands. */ |
||
485 | void cmd_init(void) |
||
486 | { |
||
775 | palkovsky | 487 | int i; |
596 | jermar | 488 | |
775 | palkovsky | 489 | for (i=0;basic_commands[i]; i++) { |
490 | cmd_initialize(basic_commands[i]); |
||
491 | if (!cmd_register(basic_commands[i])) |
||
492 | panic("could not register command %s\n", |
||
493 | basic_commands[i]->name); |
||
494 | } |
||
596 | jermar | 495 | } |
496 | |||
497 | |||
498 | /** List supported commands. |
||
499 | * |
||
500 | * @param argv Argument vector. |
||
501 | * |
||
502 | * @return 0 on failure, 1 on success. |
||
503 | */ |
||
504 | int cmd_help(cmd_arg_t *argv) |
||
505 | { |
||
506 | link_t *cur; |
||
507 | |||
508 | spinlock_lock(&cmd_lock); |
||
509 | |||
510 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
||
511 | cmd_info_t *hlp; |
||
512 | |||
513 | hlp = list_get_instance(cur, cmd_info_t, link); |
||
514 | spinlock_lock(&hlp->lock); |
||
515 | |||
516 | printf("%s - %s\n", hlp->name, hlp->description); |
||
517 | |||
518 | spinlock_unlock(&hlp->lock); |
||
519 | } |
||
520 | |||
521 | spinlock_unlock(&cmd_lock); |
||
522 | |||
523 | return 1; |
||
524 | } |
||
525 | |||
2227 | decky | 526 | |
527 | /** Reboot the system. |
||
528 | * |
||
529 | * @param argv Argument vector. |
||
530 | * |
||
531 | * @return 0 on failure, 1 on success. |
||
532 | */ |
||
533 | int cmd_reboot(cmd_arg_t *argv) |
||
534 | { |
||
535 | reboot(); |
||
536 | |||
537 | /* Not reached */ |
||
538 | return 1; |
||
539 | } |
||
540 | |||
2275 | decky | 541 | |
542 | /** Print system uptime information. |
||
543 | * |
||
544 | * @param argv Argument vector. |
||
545 | * |
||
546 | * @return 0 on failure, 1 on success. |
||
547 | */ |
||
548 | int cmd_uptime(cmd_arg_t *argv) |
||
549 | { |
||
550 | ASSERT(uptime); |
||
551 | |||
552 | /* This doesn't have to be very accurate */ |
||
553 | unative_t sec = uptime->seconds1; |
||
554 | |||
555 | printf("Up %u days, %u hours, %u minutes, %u seconds\n", |
||
556 | sec / 86400, (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); |
||
557 | |||
558 | return 1; |
||
559 | } |
||
560 | |||
596 | jermar | 561 | /** Describe specified command. |
562 | * |
||
563 | * @param argv Argument vector. |
||
564 | * |
||
565 | * @return 0 on failure, 1 on success. |
||
566 | */ |
||
567 | int cmd_desc(cmd_arg_t *argv) |
||
568 | { |
||
569 | link_t *cur; |
||
570 | |||
571 | spinlock_lock(&cmd_lock); |
||
572 | |||
573 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
||
574 | cmd_info_t *hlp; |
||
575 | |||
576 | hlp = list_get_instance(cur, cmd_info_t, link); |
||
577 | spinlock_lock(&hlp->lock); |
||
578 | |||
579 | if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) { |
||
580 | printf("%s - %s\n", hlp->name, hlp->description); |
||
581 | if (hlp->help) |
||
582 | hlp->help(); |
||
583 | spinlock_unlock(&hlp->lock); |
||
584 | break; |
||
585 | } |
||
586 | |||
587 | spinlock_unlock(&hlp->lock); |
||
588 | } |
||
589 | |||
590 | spinlock_unlock(&cmd_lock); |
||
591 | |||
592 | return 1; |
||
593 | } |
||
594 | |||
595 | /** Search symbol table */ |
||
596 | int cmd_symaddr(cmd_arg_t *argv) |
||
597 | { |
||
2114 | decky | 598 | symtab_print_search((char *) argv->buffer); |
596 | jermar | 599 | |
600 | return 1; |
||
601 | } |
||
602 | |||
603 | /** Call function with zero parameters */ |
||
604 | int cmd_call0(cmd_arg_t *argv) |
||
605 | { |
||
1780 | jermar | 606 | uintptr_t symaddr; |
596 | jermar | 607 | char *symbol; |
1780 | jermar | 608 | unative_t (*f)(void); |
1666 | palkovsky | 609 | #ifdef ia64 |
610 | struct { |
||
1780 | jermar | 611 | unative_t f; |
612 | unative_t gp; |
||
2223 | decky | 613 | } fptr; |
1666 | palkovsky | 614 | #endif |
596 | jermar | 615 | |
2114 | decky | 616 | symaddr = get_symbol_addr((char *) argv->buffer); |
596 | jermar | 617 | if (!symaddr) |
618 | printf("Symbol %s not found.\n", argv->buffer); |
||
1780 | jermar | 619 | else if (symaddr == (uintptr_t) -1) { |
2114 | decky | 620 | symtab_print_search((char *) argv->buffer); |
596 | jermar | 621 | printf("Duplicate symbol, be more specific.\n"); |
622 | } else { |
||
623 | symbol = get_symtab_entry(symaddr); |
||
2223 | decky | 624 | printf("Calling %s() (%.*p)\n", symbol, sizeof(uintptr_t) * 2, symaddr); |
1666 | palkovsky | 625 | #ifdef ia64 |
626 | fptr.f = symaddr; |
||
1780 | jermar | 627 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
628 | f = (unative_t (*)(void)) &fptr; |
||
1666 | palkovsky | 629 | #else |
1780 | jermar | 630 | f = (unative_t (*)(void)) symaddr; |
1666 | palkovsky | 631 | #endif |
1224 | cejka | 632 | printf("Result: %#zx\n", f()); |
596 | jermar | 633 | } |
634 | |||
635 | return 1; |
||
636 | } |
||
637 | |||
2223 | decky | 638 | /** Call function with zero parameters on each CPU */ |
639 | int cmd_mcall0(cmd_arg_t *argv) |
||
640 | { |
||
641 | /* |
||
642 | * For each CPU, create a thread which will |
||
643 | * call the function. |
||
644 | */ |
||
645 | |||
646 | count_t i; |
||
647 | for (i = 0; i < config.cpu_count; i++) { |
||
2319 | decky | 648 | if (!cpus[i].active) |
649 | continue; |
||
650 | |||
2223 | decky | 651 | thread_t *t; |
652 | if ((t = thread_create((void (*)(void *)) cmd_call0, (void *) argv, TASK, THREAD_FLAG_WIRED, "call0", false))) { |
||
653 | spinlock_lock(&t->lock); |
||
654 | t->cpu = &cpus[i]; |
||
655 | spinlock_unlock(&t->lock); |
||
656 | printf("cpu%u: ", i); |
||
657 | thread_ready(t); |
||
658 | thread_join(t); |
||
2224 | decky | 659 | thread_detach(t); |
2223 | decky | 660 | } else |
661 | printf("Unable to create thread for cpu%u\n", i); |
||
662 | } |
||
663 | |||
664 | return 1; |
||
665 | } |
||
666 | |||
596 | jermar | 667 | /** Call function with one parameter */ |
668 | int cmd_call1(cmd_arg_t *argv) |
||
669 | { |
||
1780 | jermar | 670 | uintptr_t symaddr; |
596 | jermar | 671 | char *symbol; |
1780 | jermar | 672 | unative_t (*f)(unative_t,...); |
673 | unative_t arg1 = argv[1].intval; |
||
1666 | palkovsky | 674 | #ifdef ia64 |
675 | struct { |
||
1780 | jermar | 676 | unative_t f; |
677 | unative_t gp; |
||
1666 | palkovsky | 678 | }fptr; |
679 | #endif |
||
596 | jermar | 680 | |
2114 | decky | 681 | symaddr = get_symbol_addr((char *) argv->buffer); |
596 | jermar | 682 | if (!symaddr) |
683 | printf("Symbol %s not found.\n", argv->buffer); |
||
1780 | jermar | 684 | else if (symaddr == (uintptr_t) -1) { |
2114 | decky | 685 | symtab_print_search((char *) argv->buffer); |
596 | jermar | 686 | printf("Duplicate symbol, be more specific.\n"); |
687 | } else { |
||
688 | symbol = get_symtab_entry(symaddr); |
||
1666 | palkovsky | 689 | |
1780 | jermar | 690 | printf("Calling f(%#zx): %.*p: %s\n", arg1, sizeof(uintptr_t) * 2, symaddr, symbol); |
1666 | palkovsky | 691 | #ifdef ia64 |
692 | fptr.f = symaddr; |
||
1780 | jermar | 693 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
694 | f = (unative_t (*)(unative_t,...)) &fptr; |
||
1666 | palkovsky | 695 | #else |
1780 | jermar | 696 | f = (unative_t (*)(unative_t,...)) symaddr; |
1666 | palkovsky | 697 | #endif |
1224 | cejka | 698 | printf("Result: %#zx\n", f(arg1)); |
596 | jermar | 699 | } |
700 | |||
701 | return 1; |
||
702 | } |
||
703 | |||
704 | /** Call function with two parameters */ |
||
705 | int cmd_call2(cmd_arg_t *argv) |
||
706 | { |
||
1780 | jermar | 707 | uintptr_t symaddr; |
596 | jermar | 708 | char *symbol; |
1780 | jermar | 709 | unative_t (*f)(unative_t,unative_t,...); |
710 | unative_t arg1 = argv[1].intval; |
||
711 | unative_t arg2 = argv[2].intval; |
||
1666 | palkovsky | 712 | #ifdef ia64 |
713 | struct { |
||
1780 | jermar | 714 | unative_t f; |
715 | unative_t gp; |
||
1666 | palkovsky | 716 | }fptr; |
717 | #endif |
||
596 | jermar | 718 | |
2114 | decky | 719 | symaddr = get_symbol_addr((char *) argv->buffer); |
596 | jermar | 720 | if (!symaddr) |
721 | printf("Symbol %s not found.\n", argv->buffer); |
||
1780 | jermar | 722 | else if (symaddr == (uintptr_t) -1) { |
2114 | decky | 723 | symtab_print_search((char *) argv->buffer); |
596 | jermar | 724 | printf("Duplicate symbol, be more specific.\n"); |
725 | } else { |
||
726 | symbol = get_symtab_entry(symaddr); |
||
1224 | cejka | 727 | printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", |
1780 | jermar | 728 | arg1, arg2, sizeof(uintptr_t) * 2, symaddr, symbol); |
1666 | palkovsky | 729 | #ifdef ia64 |
730 | fptr.f = symaddr; |
||
1780 | jermar | 731 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
732 | f = (unative_t (*)(unative_t,unative_t,...)) &fptr; |
||
1666 | palkovsky | 733 | #else |
1780 | jermar | 734 | f = (unative_t (*)(unative_t,unative_t,...)) symaddr; |
1666 | palkovsky | 735 | #endif |
1224 | cejka | 736 | printf("Result: %#zx\n", f(arg1, arg2)); |
596 | jermar | 737 | } |
738 | |||
739 | return 1; |
||
740 | } |
||
741 | |||
742 | /** Call function with three parameters */ |
||
743 | int cmd_call3(cmd_arg_t *argv) |
||
744 | { |
||
1780 | jermar | 745 | uintptr_t symaddr; |
596 | jermar | 746 | char *symbol; |
1780 | jermar | 747 | unative_t (*f)(unative_t,unative_t,unative_t,...); |
748 | unative_t arg1 = argv[1].intval; |
||
749 | unative_t arg2 = argv[2].intval; |
||
750 | unative_t arg3 = argv[3].intval; |
||
1666 | palkovsky | 751 | #ifdef ia64 |
752 | struct { |
||
1780 | jermar | 753 | unative_t f; |
754 | unative_t gp; |
||
1666 | palkovsky | 755 | }fptr; |
756 | #endif |
||
596 | jermar | 757 | |
2114 | decky | 758 | symaddr = get_symbol_addr((char *) argv->buffer); |
596 | jermar | 759 | if (!symaddr) |
760 | printf("Symbol %s not found.\n", argv->buffer); |
||
1780 | jermar | 761 | else if (symaddr == (uintptr_t) -1) { |
2114 | decky | 762 | symtab_print_search((char *) argv->buffer); |
596 | jermar | 763 | printf("Duplicate symbol, be more specific.\n"); |
764 | } else { |
||
765 | symbol = get_symtab_entry(symaddr); |
||
1224 | cejka | 766 | printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", |
1780 | jermar | 767 | arg1, arg2, arg3, sizeof(uintptr_t) * 2, symaddr, symbol); |
1666 | palkovsky | 768 | #ifdef ia64 |
769 | fptr.f = symaddr; |
||
1780 | jermar | 770 | fptr.gp = ((unative_t *)cmd_call2)[1]; |
771 | f = (unative_t (*)(unative_t,unative_t,unative_t,...)) &fptr; |
||
1666 | palkovsky | 772 | #else |
1780 | jermar | 773 | f = (unative_t (*)(unative_t,unative_t,unative_t,...)) symaddr; |
1666 | palkovsky | 774 | #endif |
1224 | cejka | 775 | printf("Result: %#zx\n", f(arg1, arg2, arg3)); |
596 | jermar | 776 | } |
777 | |||
778 | return 1; |
||
779 | } |
||
780 | |||
781 | |||
782 | /** Print detailed description of 'describe' command. */ |
||
783 | void desc_help(void) |
||
784 | { |
||
785 | printf("Syntax: describe command_name\n"); |
||
786 | } |
||
787 | |||
788 | /** Halt the kernel. |
||
789 | * |
||
790 | * @param argv Argument vector (ignored). |
||
791 | * |
||
792 | * @return 0 on failure, 1 on success (never returns). |
||
793 | */ |
||
794 | int cmd_halt(cmd_arg_t *argv) |
||
795 | { |
||
796 | halt(); |
||
797 | return 1; |
||
798 | } |
||
799 | |||
800 | /** Command for printing TLB contents. |
||
801 | * |
||
802 | * @param argv Not used. |
||
803 | * |
||
804 | * @return Always returns 1. |
||
805 | */ |
||
673 | jermar | 806 | int cmd_tlb(cmd_arg_t *argv) |
596 | jermar | 807 | { |
808 | tlb_print(); |
||
809 | return 1; |
||
810 | } |
||
603 | palkovsky | 811 | |
812 | /** Write 4 byte value to address */ |
||
813 | int cmd_set4(cmd_arg_t *argv) |
||
814 | { |
||
2216 | decky | 815 | uint32_t *addr; |
1780 | jermar | 816 | uint32_t arg1 = argv[1].intval; |
603 | palkovsky | 817 | bool pointer = false; |
818 | |||
819 | if (((char *)argv->buffer)[0] == '*') { |
||
2114 | decky | 820 | addr = (uint32_t *) get_symbol_addr((char *) argv->buffer + 1); |
603 | palkovsky | 821 | pointer = true; |
2114 | decky | 822 | } else if (((char *) argv->buffer)[0] >= '0' && |
603 | palkovsky | 823 | ((char *)argv->buffer)[0] <= '9') |
1780 | jermar | 824 | addr = (uint32_t *)atoi((char *)argv->buffer); |
603 | palkovsky | 825 | else |
2114 | decky | 826 | addr = (uint32_t *)get_symbol_addr((char *) argv->buffer); |
603 | palkovsky | 827 | |
828 | if (!addr) |
||
829 | printf("Symbol %s not found.\n", argv->buffer); |
||
1780 | jermar | 830 | else if (addr == (uint32_t *) -1) { |
2114 | decky | 831 | symtab_print_search((char *) argv->buffer); |
603 | palkovsky | 832 | printf("Duplicate symbol, be more specific.\n"); |
833 | } else { |
||
834 | if (pointer) |
||
1780 | jermar | 835 | addr = (uint32_t *)(*(unative_t *)addr); |
836 | printf("Writing 0x%x -> %.*p\n", arg1, sizeof(uintptr_t) * 2, addr); |
||
603 | palkovsky | 837 | *addr = arg1; |
838 | |||
839 | } |
||
840 | |||
841 | return 1; |
||
842 | } |
||
668 | bondari | 843 | |
759 | palkovsky | 844 | /** Command for listings SLAB caches |
845 | * |
||
846 | * @param argv Ignores |
||
847 | * |
||
848 | * @return Always 1 |
||
849 | */ |
||
850 | int cmd_slabs(cmd_arg_t * argv) { |
||
851 | slab_print_list(); |
||
852 | return 1; |
||
853 | } |
||
854 | |||
777 | palkovsky | 855 | |
775 | palkovsky | 856 | /** Command for listings Thread information |
857 | * |
||
858 | * @param argv Ignores |
||
859 | * |
||
860 | * @return Always 1 |
||
861 | */ |
||
777 | palkovsky | 862 | int cmd_threads(cmd_arg_t * argv) { |
863 | thread_print_list(); |
||
864 | return 1; |
||
865 | } |
||
866 | |||
1060 | palkovsky | 867 | /** Command for listings Task information |
868 | * |
||
869 | * @param argv Ignores |
||
870 | * |
||
871 | * @return Always 1 |
||
872 | */ |
||
873 | int cmd_tasks(cmd_arg_t * argv) { |
||
874 | task_print_list(); |
||
875 | return 1; |
||
876 | } |
||
877 | |||
777 | palkovsky | 878 | /** Command for listings Thread information |
879 | * |
||
880 | * @param argv Ignores |
||
881 | * |
||
882 | * @return Always 1 |
||
883 | */ |
||
775 | palkovsky | 884 | int cmd_sched(cmd_arg_t * argv) { |
885 | sched_print_list(); |
||
886 | return 1; |
||
887 | } |
||
888 | |||
677 | bondari | 889 | /** Command for listing memory zones |
890 | * |
||
891 | * @param argv Ignored |
||
892 | * |
||
893 | * return Always 1 |
||
894 | */ |
||
668 | bondari | 895 | int cmd_zones(cmd_arg_t * argv) { |
676 | bondari | 896 | zone_print_list(); |
668 | bondari | 897 | return 1; |
898 | } |
||
673 | jermar | 899 | |
677 | bondari | 900 | /** Command for memory zone details |
901 | * |
||
902 | * @param argv Integer argument from cmdline expected |
||
903 | * |
||
904 | * return Always 1 |
||
905 | */ |
||
668 | bondari | 906 | int cmd_zone(cmd_arg_t * argv) { |
676 | bondari | 907 | zone_print_one(argv[0].intval); |
668 | bondari | 908 | return 1; |
909 | } |
||
910 | |||
1573 | palkovsky | 911 | /** Command for printing task ipc details |
912 | * |
||
913 | * @param argv Integer argument from cmdline expected |
||
914 | * |
||
915 | * return Always 1 |
||
916 | */ |
||
917 | int cmd_ipc_task(cmd_arg_t * argv) { |
||
918 | ipc_print_task(argv[0].intval); |
||
919 | return 1; |
||
920 | } |
||
921 | |||
922 | |||
673 | jermar | 923 | /** Command for listing processors. |
924 | * |
||
925 | * @param argv Ignored. |
||
926 | * |
||
927 | * return Always 1. |
||
928 | */ |
||
929 | int cmd_cpus(cmd_arg_t *argv) |
||
930 | { |
||
931 | cpu_list(); |
||
932 | return 1; |
||
933 | } |
||
934 | |||
935 | /** Command for printing kernel version. |
||
936 | * |
||
937 | * @param argv Ignored. |
||
938 | * |
||
939 | * return Always 1. |
||
940 | */ |
||
941 | int cmd_version(cmd_arg_t *argv) |
||
942 | { |
||
943 | version_print(); |
||
944 | return 1; |
||
945 | } |
||
1474 | palkovsky | 946 | |
947 | /** Command for returning console back to userspace. |
||
948 | * |
||
949 | * @param argv Ignored. |
||
950 | * |
||
951 | * return Always 1. |
||
952 | */ |
||
953 | int cmd_continue(cmd_arg_t *argv) |
||
954 | { |
||
1695 | jermar | 955 | printf("The kernel will now relinquish the console.\n"); |
956 | printf("Use userspace controls to redraw the screen.\n"); |
||
1474 | palkovsky | 957 | arch_release_console(); |
958 | return 1; |
||
959 | } |
||
1702 | cejka | 960 | |
2020 | decky | 961 | #ifdef CONFIG_TEST |
2019 | decky | 962 | /** Command for printing kernel tests list. |
963 | * |
||
964 | * @param argv Ignored. |
||
965 | * |
||
966 | * return Always 1. |
||
967 | */ |
||
968 | int cmd_tests(cmd_arg_t *argv) |
||
969 | { |
||
970 | test_t *test; |
||
971 | |||
972 | for (test = tests; test->name != NULL; test++) |
||
2020 | decky | 973 | printf("%s\t\t%s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)")); |
2019 | decky | 974 | |
2020 | decky | 975 | printf("*\t\tRun all safe tests\n"); |
2019 | decky | 976 | return 1; |
977 | } |
||
978 | |||
2042 | decky | 979 | static bool run_test(const test_t *test) |
2027 | decky | 980 | { |
2042 | decky | 981 | printf("%s\t\t%s\n", test->name, test->desc); |
2030 | decky | 982 | |
983 | /* Update and read thread accounting |
||
984 | for benchmarking */ |
||
985 | ipl_t ipl = interrupts_disable(); |
||
2039 | decky | 986 | spinlock_lock(&TASK->lock); |
987 | uint64_t t0 = task_get_accounting(TASK); |
||
988 | spinlock_unlock(&TASK->lock); |
||
2030 | decky | 989 | interrupts_restore(ipl); |
990 | |||
991 | /* Execute the test */ |
||
2050 | decky | 992 | char * ret = test->entry(false); |
2030 | decky | 993 | |
994 | /* Update and read thread accounting */ |
||
995 | ipl = interrupts_disable(); |
||
2039 | decky | 996 | spinlock_lock(&TASK->lock); |
997 | uint64_t dt = task_get_accounting(TASK) - t0; |
||
998 | spinlock_unlock(&TASK->lock); |
||
2030 | decky | 999 | interrupts_restore(ipl); |
1000 | |||
2050 | decky | 1001 | uint64_t cycles; |
1002 | char suffix; |
||
1003 | order(dt, &cycles, &suffix); |
||
1004 | |||
1005 | printf("Time: %llu%c cycles\n", cycles, suffix); |
||
2027 | decky | 1006 | |
1007 | if (ret == NULL) { |
||
1008 | printf("Test passed\n"); |
||
2042 | decky | 1009 | return true; |
2027 | decky | 1010 | } |
1011 | |||
1012 | printf("%s\n", ret); |
||
2042 | decky | 1013 | return false; |
2027 | decky | 1014 | } |
1015 | |||
2050 | decky | 1016 | static bool run_bench(const test_t *test, const uint32_t cnt) |
1017 | { |
||
1018 | uint32_t i; |
||
1019 | bool ret = true; |
||
1020 | uint64_t cycles; |
||
1021 | char suffix; |
||
1022 | |||
1023 | if (cnt < 1) |
||
1024 | return true; |
||
1025 | |||
2114 | decky | 1026 | uint64_t *data = (uint64_t *) malloc(sizeof(uint64_t) * cnt, 0); |
2050 | decky | 1027 | if (data == NULL) { |
1028 | printf("Error allocating memory for statistics\n"); |
||
1029 | return false; |
||
1030 | } |
||
1031 | |||
1032 | for (i = 0; i < cnt; i++) { |
||
1033 | printf("%s (%d/%d) ... ", test->name, i + 1, cnt); |
||
1034 | |||
1035 | /* Update and read thread accounting |
||
1036 | for benchmarking */ |
||
1037 | ipl_t ipl = interrupts_disable(); |
||
1038 | spinlock_lock(&TASK->lock); |
||
1039 | uint64_t t0 = task_get_accounting(TASK); |
||
1040 | spinlock_unlock(&TASK->lock); |
||
1041 | interrupts_restore(ipl); |
||
1042 | |||
1043 | /* Execute the test */ |
||
1044 | char * ret = test->entry(true); |
||
1045 | |||
1046 | /* Update and read thread accounting */ |
||
1047 | ipl = interrupts_disable(); |
||
1048 | spinlock_lock(&TASK->lock); |
||
1049 | uint64_t dt = task_get_accounting(TASK) - t0; |
||
1050 | spinlock_unlock(&TASK->lock); |
||
1051 | interrupts_restore(ipl); |
||
1052 | |||
1053 | if (ret != NULL) { |
||
1054 | printf("%s\n", ret); |
||
1055 | ret = false; |
||
1056 | break; |
||
1057 | } |
||
1058 | |||
1059 | data[i] = dt; |
||
1060 | order(dt, &cycles, &suffix); |
||
1061 | printf("OK (%llu%c cycles)\n", cycles, suffix); |
||
1062 | } |
||
1063 | |||
1064 | if (ret) { |
||
1065 | printf("\n"); |
||
1066 | |||
1067 | uint64_t sum = 0; |
||
1068 | |||
1069 | for (i = 0; i < cnt; i++) { |
||
1070 | sum += data[i]; |
||
1071 | } |
||
1072 | |||
1073 | order(sum / (uint64_t) cnt, &cycles, &suffix); |
||
1074 | printf("Average\t\t%llu%c\n", cycles, suffix); |
||
1075 | } |
||
1076 | |||
1077 | free(data); |
||
1078 | |||
1079 | return ret; |
||
1080 | } |
||
1081 | |||
2019 | decky | 1082 | /** Command for returning kernel tests |
1083 | * |
||
1084 | * @param argv Argument vector. |
||
1085 | * |
||
1086 | * return Always 1. |
||
1087 | */ |
||
1088 | int cmd_test(cmd_arg_t *argv) |
||
1089 | { |
||
1090 | test_t *test; |
||
1091 | |||
2114 | decky | 1092 | if (strcmp((char *) argv->buffer, "*") == 0) { |
2020 | decky | 1093 | for (test = tests; test->name != NULL; test++) { |
1094 | if (test->safe) { |
||
2027 | decky | 1095 | printf("\n"); |
1096 | if (!run_test(test)) |
||
1097 | break; |
||
2020 | decky | 1098 | } |
2019 | decky | 1099 | } |
2020 | decky | 1100 | } else { |
1101 | bool fnd = false; |
||
1102 | |||
1103 | for (test = tests; test->name != NULL; test++) { |
||
2114 | decky | 1104 | if (strcmp(test->name, (char *) argv->buffer) == 0) { |
2020 | decky | 1105 | fnd = true; |
2027 | decky | 1106 | run_test(test); |
2020 | decky | 1107 | break; |
1108 | } |
||
1109 | } |
||
1110 | |||
1111 | if (!fnd) |
||
2027 | decky | 1112 | printf("Unknown test\n"); |
2019 | decky | 1113 | } |
1114 | |||
1115 | return 1; |
||
1116 | } |
||
2050 | decky | 1117 | |
1118 | /** Command for returning kernel tests as benchmarks |
||
1119 | * |
||
1120 | * @param argv Argument vector. |
||
1121 | * |
||
1122 | * return Always 1. |
||
1123 | */ |
||
1124 | int cmd_bench(cmd_arg_t *argv) |
||
1125 | { |
||
1126 | test_t *test; |
||
1127 | uint32_t cnt = argv[1].intval; |
||
1128 | |||
1129 | bool fnd = false; |
||
1130 | |||
1131 | for (test = tests; test->name != NULL; test++) { |
||
2114 | decky | 1132 | if (strcmp(test->name, (char *) argv->buffer) == 0) { |
2050 | decky | 1133 | fnd = true; |
2051 | decky | 1134 | |
1135 | if (test->safe) |
||
1136 | run_bench(test, cnt); |
||
1137 | else |
||
1138 | printf("Unsafe test\n"); |
||
1139 | |||
2050 | decky | 1140 | break; |
1141 | } |
||
1142 | } |
||
1143 | |||
1144 | if (!fnd) |
||
1145 | printf("Unknown test\n"); |
||
1146 | |||
1147 | return 1; |
||
1148 | } |
||
1149 | |||
2020 | decky | 1150 | #endif |
2019 | decky | 1151 | |
1888 | jermar | 1152 | /** @} |
1702 | cejka | 1153 | */ |