Rev 1582 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
596 | jermar | 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 | /** |
||
1264 | jermar | 30 | * @file cmd.c |
31 | * @brief Kernel console command wrappers. |
||
32 | * |
||
596 | jermar | 33 | * This file is meant to contain all wrapper functions for |
34 | * all kconsole commands. The point is in separating |
||
35 | * kconsole specific wrappers from kconsole-unaware functions |
||
36 | * from other subsystems. |
||
37 | */ |
||
38 | |||
39 | #include <console/cmd.h> |
||
1474 | palkovsky | 40 | #include <console/console.h> |
596 | jermar | 41 | #include <console/kconsole.h> |
42 | #include <print.h> |
||
43 | #include <panic.h> |
||
44 | #include <typedefs.h> |
||
45 | #include <arch/types.h> |
||
788 | jermar | 46 | #include <adt/list.h> |
596 | jermar | 47 | #include <arch.h> |
48 | #include <func.h> |
||
49 | #include <macros.h> |
||
50 | #include <debug.h> |
||
51 | #include <symtab.h> |
||
673 | jermar | 52 | #include <cpu.h> |
596 | jermar | 53 | #include <mm/tlb.h> |
54 | #include <arch/mm/tlb.h> |
||
668 | bondari | 55 | #include <mm/frame.h> |
673 | jermar | 56 | #include <main/version.h> |
759 | palkovsky | 57 | #include <mm/slab.h> |
775 | palkovsky | 58 | #include <proc/scheduler.h> |
777 | palkovsky | 59 | #include <proc/thread.h> |
1060 | palkovsky | 60 | #include <proc/task.h> |
1573 | palkovsky | 61 | #include <ipc/ipc.h> |
596 | jermar | 62 | |
63 | /** Data and methods for 'help' command. */ |
||
64 | static int cmd_help(cmd_arg_t *argv); |
||
65 | static cmd_info_t help_info = { |
||
66 | .name = "help", |
||
67 | .description = "List of supported commands.", |
||
68 | .func = cmd_help, |
||
69 | .argc = 0 |
||
70 | }; |
||
71 | |||
609 | palkovsky | 72 | static cmd_info_t exit_info = { |
73 | .name = "exit", |
||
74 | .description ="Exit kconsole", |
||
75 | .argc = 0 |
||
76 | }; |
||
77 | |||
1474 | palkovsky | 78 | static int cmd_continue(cmd_arg_t *argv); |
79 | static cmd_info_t continue_info = { |
||
80 | .name = "continue", |
||
81 | .description ="Return console back to userspace", |
||
82 | .func = cmd_continue, |
||
83 | .argc = 0 |
||
84 | }; |
||
85 | |||
596 | jermar | 86 | /** Data and methods for 'description' command. */ |
87 | static int cmd_desc(cmd_arg_t *argv); |
||
88 | static void desc_help(void); |
||
89 | static char desc_buf[MAX_CMDLINE+1]; |
||
90 | static cmd_arg_t desc_argv = { |
||
91 | .type = ARG_TYPE_STRING, |
||
92 | .buffer = desc_buf, |
||
93 | .len = sizeof(desc_buf) |
||
94 | }; |
||
95 | static cmd_info_t desc_info = { |
||
96 | .name = "describe", |
||
97 | .description = "Describe specified command.", |
||
98 | .help = desc_help, |
||
99 | .func = cmd_desc, |
||
100 | .argc = 1, |
||
101 | .argv = &desc_argv |
||
102 | }; |
||
103 | |||
104 | /** Data and methods for 'symaddr' command. */ |
||
105 | static int cmd_symaddr(cmd_arg_t *argv); |
||
106 | static char symaddr_buf[MAX_CMDLINE+1]; |
||
107 | static cmd_arg_t symaddr_argv = { |
||
108 | .type = ARG_TYPE_STRING, |
||
109 | .buffer = symaddr_buf, |
||
110 | .len = sizeof(symaddr_buf) |
||
111 | }; |
||
112 | static cmd_info_t symaddr_info = { |
||
113 | .name = "symaddr", |
||
114 | .description = "Return symbol address.", |
||
115 | .func = cmd_symaddr, |
||
116 | .argc = 1, |
||
117 | .argv = &symaddr_argv |
||
118 | }; |
||
119 | |||
603 | palkovsky | 120 | static char set_buf[MAX_CMDLINE+1]; |
121 | static int cmd_set4(cmd_arg_t *argv); |
||
122 | static cmd_arg_t set4_argv[] = { |
||
123 | { |
||
124 | .type = ARG_TYPE_STRING, |
||
125 | .buffer = set_buf, |
||
126 | .len = sizeof(set_buf) |
||
127 | }, |
||
128 | { |
||
129 | .type = ARG_TYPE_INT |
||
130 | } |
||
131 | }; |
||
132 | static cmd_info_t set4_info = { |
||
133 | .name = "set4", |
||
134 | .description = "set <dest_addr> <value> - 4byte version", |
||
135 | .func = cmd_set4, |
||
136 | .argc = 2, |
||
137 | .argv = set4_argv |
||
138 | }; |
||
139 | |||
596 | jermar | 140 | /** Data and methods for 'call0' command. */ |
141 | static char call0_buf[MAX_CMDLINE+1]; |
||
142 | static char carg1_buf[MAX_CMDLINE+1]; |
||
143 | static char carg2_buf[MAX_CMDLINE+1]; |
||
144 | static char carg3_buf[MAX_CMDLINE+1]; |
||
145 | |||
146 | static int cmd_call0(cmd_arg_t *argv); |
||
147 | static cmd_arg_t call0_argv = { |
||
148 | .type = ARG_TYPE_STRING, |
||
149 | .buffer = call0_buf, |
||
150 | .len = sizeof(call0_buf) |
||
151 | }; |
||
152 | static cmd_info_t call0_info = { |
||
153 | .name = "call0", |
||
154 | .description = "call0 <function> -> call function().", |
||
155 | .func = cmd_call0, |
||
156 | .argc = 1, |
||
157 | .argv = &call0_argv |
||
158 | }; |
||
159 | |||
160 | /** Data and methods for 'call1' command. */ |
||
161 | static int cmd_call1(cmd_arg_t *argv); |
||
162 | static cmd_arg_t call1_argv[] = { |
||
163 | { |
||
164 | .type = ARG_TYPE_STRING, |
||
165 | .buffer = call0_buf, |
||
166 | .len = sizeof(call0_buf) |
||
167 | }, |
||
168 | { |
||
169 | .type = ARG_TYPE_VAR, |
||
170 | .buffer = carg1_buf, |
||
171 | .len = sizeof(carg1_buf) |
||
172 | } |
||
173 | }; |
||
174 | static cmd_info_t call1_info = { |
||
175 | .name = "call1", |
||
176 | .description = "call1 <function> <arg1> -> call function(arg1).", |
||
177 | .func = cmd_call1, |
||
178 | .argc = 2, |
||
179 | .argv = call1_argv |
||
180 | }; |
||
181 | |||
182 | /** Data and methods for 'call2' command. */ |
||
183 | static int cmd_call2(cmd_arg_t *argv); |
||
184 | static cmd_arg_t call2_argv[] = { |
||
185 | { |
||
186 | .type = ARG_TYPE_STRING, |
||
187 | .buffer = call0_buf, |
||
188 | .len = sizeof(call0_buf) |
||
189 | }, |
||
190 | { |
||
191 | .type = ARG_TYPE_VAR, |
||
192 | .buffer = carg1_buf, |
||
193 | .len = sizeof(carg1_buf) |
||
194 | }, |
||
195 | { |
||
196 | .type = ARG_TYPE_VAR, |
||
197 | .buffer = carg2_buf, |
||
198 | .len = sizeof(carg2_buf) |
||
199 | } |
||
200 | }; |
||
201 | static cmd_info_t call2_info = { |
||
202 | .name = "call2", |
||
203 | .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).", |
||
204 | .func = cmd_call2, |
||
205 | .argc = 3, |
||
206 | .argv = call2_argv |
||
207 | }; |
||
208 | |||
209 | /** Data and methods for 'call3' command. */ |
||
210 | static int cmd_call3(cmd_arg_t *argv); |
||
211 | static cmd_arg_t call3_argv[] = { |
||
212 | { |
||
213 | .type = ARG_TYPE_STRING, |
||
214 | .buffer = call0_buf, |
||
215 | .len = sizeof(call0_buf) |
||
216 | }, |
||
217 | { |
||
218 | .type = ARG_TYPE_VAR, |
||
219 | .buffer = carg1_buf, |
||
220 | .len = sizeof(carg1_buf) |
||
221 | }, |
||
222 | { |
||
223 | .type = ARG_TYPE_VAR, |
||
224 | .buffer = carg2_buf, |
||
225 | .len = sizeof(carg2_buf) |
||
226 | }, |
||
227 | { |
||
228 | .type = ARG_TYPE_VAR, |
||
229 | .buffer = carg3_buf, |
||
230 | .len = sizeof(carg3_buf) |
||
231 | } |
||
232 | |||
233 | }; |
||
234 | static cmd_info_t call3_info = { |
||
235 | .name = "call3", |
||
236 | .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).", |
||
237 | .func = cmd_call3, |
||
238 | .argc = 4, |
||
239 | .argv = call3_argv |
||
240 | }; |
||
241 | |||
242 | /** Data and methods for 'halt' command. */ |
||
243 | static int cmd_halt(cmd_arg_t *argv); |
||
244 | static cmd_info_t halt_info = { |
||
245 | .name = "halt", |
||
246 | .description = "Halt the kernel.", |
||
247 | .func = cmd_halt, |
||
248 | .argc = 0 |
||
249 | }; |
||
250 | |||
673 | jermar | 251 | /** Data and methods for 'tlb' command. */ |
252 | static int cmd_tlb(cmd_arg_t *argv); |
||
253 | cmd_info_t tlb_info = { |
||
254 | .name = "tlb", |
||
596 | jermar | 255 | .description = "Print TLB of current processor.", |
256 | .help = NULL, |
||
673 | jermar | 257 | .func = cmd_tlb, |
596 | jermar | 258 | .argc = 0, |
259 | .argv = NULL |
||
260 | }; |
||
261 | |||
777 | palkovsky | 262 | static int cmd_threads(cmd_arg_t *argv); |
263 | static cmd_info_t threads_info = { |
||
264 | .name = "threads", |
||
265 | .description = "List all threads", |
||
266 | .func = cmd_threads, |
||
267 | .argc = 0 |
||
268 | }; |
||
668 | bondari | 269 | |
1060 | palkovsky | 270 | static int cmd_tasks(cmd_arg_t *argv); |
271 | static cmd_info_t tasks_info = { |
||
272 | .name = "tasks", |
||
273 | .description = "List all tasks", |
||
274 | .func = cmd_tasks, |
||
275 | .argc = 0 |
||
276 | }; |
||
777 | palkovsky | 277 | |
1060 | palkovsky | 278 | |
775 | palkovsky | 279 | static int cmd_sched(cmd_arg_t *argv); |
280 | static cmd_info_t sched_info = { |
||
281 | .name = "scheduler", |
||
282 | .description = "List all scheduler information", |
||
283 | .func = cmd_sched, |
||
284 | .argc = 0 |
||
285 | }; |
||
286 | |||
759 | palkovsky | 287 | static int cmd_slabs(cmd_arg_t *argv); |
288 | static cmd_info_t slabs_info = { |
||
289 | .name = "slabs", |
||
290 | .description = "List SLAB caches.", |
||
291 | .func = cmd_slabs, |
||
292 | .argc = 0 |
||
293 | }; |
||
294 | |||
668 | bondari | 295 | /** Data and methods for 'zones' command */ |
296 | static int cmd_zones(cmd_arg_t *argv); |
||
297 | static cmd_info_t zones_info = { |
||
298 | .name = "zones", |
||
299 | .description = "List of memory zones.", |
||
300 | .func = cmd_zones, |
||
301 | .argc = 0 |
||
302 | }; |
||
303 | |||
1573 | palkovsky | 304 | /** Data and methods for 'ipc_task' command */ |
305 | static int cmd_ipc_task(cmd_arg_t *argv); |
||
306 | static cmd_arg_t ipc_task_argv = { |
||
307 | .type = ARG_TYPE_INT, |
||
308 | }; |
||
309 | static cmd_info_t ipc_task_info = { |
||
310 | .name = "ipc_task", |
||
1582 | palkovsky | 311 | .description = "ipc_task <taskid> Show IPC information of given task", |
1573 | palkovsky | 312 | .func = cmd_ipc_task, |
313 | .argc = 1, |
||
314 | .argv = &ipc_task_argv |
||
315 | }; |
||
316 | |||
668 | bondari | 317 | /** Data and methods for 'zone' command */ |
318 | static int cmd_zone(cmd_arg_t *argv); |
||
319 | static cmd_arg_t zone_argv = { |
||
320 | .type = ARG_TYPE_INT, |
||
321 | }; |
||
322 | |||
323 | static cmd_info_t zone_info = { |
||
324 | .name = "zone", |
||
325 | .description = "Show memory zone structure.", |
||
326 | .func = cmd_zone, |
||
327 | .argc = 1, |
||
328 | .argv = &zone_argv |
||
329 | }; |
||
330 | |||
673 | jermar | 331 | /** Data and methods for 'cpus' command. */ |
332 | static int cmd_cpus(cmd_arg_t *argv); |
||
333 | cmd_info_t cpus_info = { |
||
334 | .name = "cpus", |
||
335 | .description = "List all processors.", |
||
336 | .help = NULL, |
||
337 | .func = cmd_cpus, |
||
338 | .argc = 0, |
||
339 | .argv = NULL |
||
340 | }; |
||
668 | bondari | 341 | |
673 | jermar | 342 | /** Data and methods for 'version' command. */ |
343 | static int cmd_version(cmd_arg_t *argv); |
||
344 | cmd_info_t version_info = { |
||
345 | .name = "version", |
||
346 | .description = "Print version information.", |
||
347 | .help = NULL, |
||
348 | .func = cmd_version, |
||
349 | .argc = 0, |
||
350 | .argv = NULL |
||
351 | }; |
||
668 | bondari | 352 | |
775 | palkovsky | 353 | static cmd_info_t *basic_commands[] = { |
354 | &call0_info, |
||
355 | &call1_info, |
||
356 | &call2_info, |
||
357 | &call3_info, |
||
1474 | palkovsky | 358 | &continue_info, |
775 | palkovsky | 359 | &cpus_info, |
360 | &desc_info, |
||
361 | &exit_info, |
||
362 | &halt_info, |
||
363 | &help_info, |
||
1573 | palkovsky | 364 | &ipc_task_info, |
775 | palkovsky | 365 | &set4_info, |
366 | &slabs_info, |
||
367 | &symaddr_info, |
||
368 | &sched_info, |
||
777 | palkovsky | 369 | &threads_info, |
1060 | palkovsky | 370 | &tasks_info, |
775 | palkovsky | 371 | &tlb_info, |
372 | &version_info, |
||
373 | &zones_info, |
||
374 | &zone_info, |
||
375 | NULL |
||
376 | }; |
||
673 | jermar | 377 | |
378 | |||
596 | jermar | 379 | /** Initialize command info structure. |
380 | * |
||
381 | * @param cmd Command info structure. |
||
382 | * |
||
383 | */ |
||
384 | void cmd_initialize(cmd_info_t *cmd) |
||
385 | { |
||
386 | spinlock_initialize(&cmd->lock, "cmd"); |
||
387 | link_initialize(&cmd->link); |
||
388 | } |
||
389 | |||
390 | /** Initialize and register commands. */ |
||
391 | void cmd_init(void) |
||
392 | { |
||
775 | palkovsky | 393 | int i; |
596 | jermar | 394 | |
775 | palkovsky | 395 | for (i=0;basic_commands[i]; i++) { |
396 | cmd_initialize(basic_commands[i]); |
||
397 | if (!cmd_register(basic_commands[i])) |
||
398 | panic("could not register command %s\n", |
||
399 | basic_commands[i]->name); |
||
400 | } |
||
596 | jermar | 401 | } |
402 | |||
403 | |||
404 | /** List supported commands. |
||
405 | * |
||
406 | * @param argv Argument vector. |
||
407 | * |
||
408 | * @return 0 on failure, 1 on success. |
||
409 | */ |
||
410 | int cmd_help(cmd_arg_t *argv) |
||
411 | { |
||
412 | link_t *cur; |
||
413 | |||
414 | spinlock_lock(&cmd_lock); |
||
415 | |||
416 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
||
417 | cmd_info_t *hlp; |
||
418 | |||
419 | hlp = list_get_instance(cur, cmd_info_t, link); |
||
420 | spinlock_lock(&hlp->lock); |
||
421 | |||
422 | printf("%s - %s\n", hlp->name, hlp->description); |
||
423 | |||
424 | spinlock_unlock(&hlp->lock); |
||
425 | } |
||
426 | |||
427 | spinlock_unlock(&cmd_lock); |
||
428 | |||
429 | return 1; |
||
430 | } |
||
431 | |||
432 | /** Describe specified command. |
||
433 | * |
||
434 | * @param argv Argument vector. |
||
435 | * |
||
436 | * @return 0 on failure, 1 on success. |
||
437 | */ |
||
438 | int cmd_desc(cmd_arg_t *argv) |
||
439 | { |
||
440 | link_t *cur; |
||
441 | |||
442 | spinlock_lock(&cmd_lock); |
||
443 | |||
444 | for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) { |
||
445 | cmd_info_t *hlp; |
||
446 | |||
447 | hlp = list_get_instance(cur, cmd_info_t, link); |
||
448 | spinlock_lock(&hlp->lock); |
||
449 | |||
450 | if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) { |
||
451 | printf("%s - %s\n", hlp->name, hlp->description); |
||
452 | if (hlp->help) |
||
453 | hlp->help(); |
||
454 | spinlock_unlock(&hlp->lock); |
||
455 | break; |
||
456 | } |
||
457 | |||
458 | spinlock_unlock(&hlp->lock); |
||
459 | } |
||
460 | |||
461 | spinlock_unlock(&cmd_lock); |
||
462 | |||
463 | return 1; |
||
464 | } |
||
465 | |||
466 | /** Search symbol table */ |
||
467 | int cmd_symaddr(cmd_arg_t *argv) |
||
468 | { |
||
469 | symtab_print_search(argv->buffer); |
||
470 | |||
471 | return 1; |
||
472 | } |
||
473 | |||
474 | /** Call function with zero parameters */ |
||
475 | int cmd_call0(cmd_arg_t *argv) |
||
476 | { |
||
477 | __address symaddr; |
||
478 | char *symbol; |
||
479 | __native (*f)(void); |
||
480 | |||
481 | symaddr = get_symbol_addr(argv->buffer); |
||
482 | if (!symaddr) |
||
483 | printf("Symbol %s not found.\n", argv->buffer); |
||
484 | else if (symaddr == (__address) -1) { |
||
485 | symtab_print_search(argv->buffer); |
||
486 | printf("Duplicate symbol, be more specific.\n"); |
||
487 | } else { |
||
488 | symbol = get_symtab_entry(symaddr); |
||
1224 | cejka | 489 | printf("Calling f(): %.*p: %s\n", sizeof(__address) * 2, symaddr, symbol); |
596 | jermar | 490 | f = (__native (*)(void)) symaddr; |
1224 | cejka | 491 | printf("Result: %#zx\n", f()); |
596 | jermar | 492 | } |
493 | |||
494 | return 1; |
||
495 | } |
||
496 | |||
497 | /** Call function with one parameter */ |
||
498 | int cmd_call1(cmd_arg_t *argv) |
||
499 | { |
||
500 | __address symaddr; |
||
501 | char *symbol; |
||
775 | palkovsky | 502 | __native (*f)(__native,...); |
596 | jermar | 503 | __native arg1 = argv[1].intval; |
504 | |||
505 | symaddr = get_symbol_addr(argv->buffer); |
||
506 | if (!symaddr) |
||
507 | printf("Symbol %s not found.\n", argv->buffer); |
||
508 | else if (symaddr == (__address) -1) { |
||
509 | symtab_print_search(argv->buffer); |
||
510 | printf("Duplicate symbol, be more specific.\n"); |
||
511 | } else { |
||
512 | symbol = get_symtab_entry(symaddr); |
||
1224 | cejka | 513 | printf("Calling f(0x%zX): %.*p: %s\n", arg1, sizeof(__address) * 2, symaddr, symbol); |
775 | palkovsky | 514 | f = (__native (*)(__native,...)) symaddr; |
1224 | cejka | 515 | printf("Result: %#zx\n", f(arg1)); |
596 | jermar | 516 | } |
517 | |||
518 | return 1; |
||
519 | } |
||
520 | |||
521 | /** Call function with two parameters */ |
||
522 | int cmd_call2(cmd_arg_t *argv) |
||
523 | { |
||
524 | __address symaddr; |
||
525 | char *symbol; |
||
775 | palkovsky | 526 | __native (*f)(__native,__native,...); |
596 | jermar | 527 | __native arg1 = argv[1].intval; |
528 | __native arg2 = argv[2].intval; |
||
529 | |||
530 | symaddr = get_symbol_addr(argv->buffer); |
||
531 | if (!symaddr) |
||
532 | printf("Symbol %s not found.\n", argv->buffer); |
||
533 | else if (symaddr == (__address) -1) { |
||
534 | symtab_print_search(argv->buffer); |
||
535 | printf("Duplicate symbol, be more specific.\n"); |
||
536 | } else { |
||
537 | symbol = get_symtab_entry(symaddr); |
||
1224 | cejka | 538 | printf("Calling f(0x%zx,0x%zx): %.*p: %s\n", |
539 | arg1, arg2, sizeof(__address) * 2, symaddr, symbol); |
||
775 | palkovsky | 540 | f = (__native (*)(__native,__native,...)) symaddr; |
1224 | cejka | 541 | printf("Result: %#zx\n", f(arg1, arg2)); |
596 | jermar | 542 | } |
543 | |||
544 | return 1; |
||
545 | } |
||
546 | |||
547 | /** Call function with three parameters */ |
||
548 | int cmd_call3(cmd_arg_t *argv) |
||
549 | { |
||
550 | __address symaddr; |
||
551 | char *symbol; |
||
775 | palkovsky | 552 | __native (*f)(__native,__native,__native,...); |
596 | jermar | 553 | __native arg1 = argv[1].intval; |
554 | __native arg2 = argv[2].intval; |
||
555 | __native arg3 = argv[3].intval; |
||
556 | |||
557 | symaddr = get_symbol_addr(argv->buffer); |
||
558 | if (!symaddr) |
||
559 | printf("Symbol %s not found.\n", argv->buffer); |
||
560 | else if (symaddr == (__address) -1) { |
||
561 | symtab_print_search(argv->buffer); |
||
562 | printf("Duplicate symbol, be more specific.\n"); |
||
563 | } else { |
||
564 | symbol = get_symtab_entry(symaddr); |
||
1224 | cejka | 565 | printf("Calling f(0x%zx,0x%zx, 0x%zx): %.*p: %s\n", |
566 | arg1, arg2, arg3, sizeof(__address) * 2, symaddr, symbol); |
||
775 | palkovsky | 567 | f = (__native (*)(__native,__native,__native,...)) symaddr; |
1224 | cejka | 568 | printf("Result: %#zx\n", f(arg1, arg2, arg3)); |
596 | jermar | 569 | } |
570 | |||
571 | return 1; |
||
572 | } |
||
573 | |||
574 | |||
575 | /** Print detailed description of 'describe' command. */ |
||
576 | void desc_help(void) |
||
577 | { |
||
578 | printf("Syntax: describe command_name\n"); |
||
579 | } |
||
580 | |||
581 | /** Halt the kernel. |
||
582 | * |
||
583 | * @param argv Argument vector (ignored). |
||
584 | * |
||
585 | * @return 0 on failure, 1 on success (never returns). |
||
586 | */ |
||
587 | int cmd_halt(cmd_arg_t *argv) |
||
588 | { |
||
589 | halt(); |
||
590 | return 1; |
||
591 | } |
||
592 | |||
593 | /** Command for printing TLB contents. |
||
594 | * |
||
595 | * @param argv Not used. |
||
596 | * |
||
597 | * @return Always returns 1. |
||
598 | */ |
||
673 | jermar | 599 | int cmd_tlb(cmd_arg_t *argv) |
596 | jermar | 600 | { |
601 | tlb_print(); |
||
602 | return 1; |
||
603 | } |
||
603 | palkovsky | 604 | |
605 | /** Write 4 byte value to address */ |
||
606 | int cmd_set4(cmd_arg_t *argv) |
||
607 | { |
||
608 | __u32 *addr ; |
||
609 | __u32 arg1 = argv[1].intval; |
||
610 | bool pointer = false; |
||
611 | |||
612 | if (((char *)argv->buffer)[0] == '*') { |
||
613 | addr = (__u32 *) get_symbol_addr(argv->buffer+1); |
||
614 | pointer = true; |
||
615 | } else if (((char *)argv->buffer)[0] >= '0' && |
||
616 | ((char *)argv->buffer)[0] <= '9') |
||
617 | addr = (__u32 *)atoi((char *)argv->buffer); |
||
618 | else |
||
619 | addr = (__u32 *)get_symbol_addr(argv->buffer); |
||
620 | |||
621 | if (!addr) |
||
622 | printf("Symbol %s not found.\n", argv->buffer); |
||
623 | else if (addr == (__u32 *) -1) { |
||
624 | symtab_print_search(argv->buffer); |
||
625 | printf("Duplicate symbol, be more specific.\n"); |
||
626 | } else { |
||
627 | if (pointer) |
||
608 | palkovsky | 628 | addr = (__u32 *)(*(__native *)addr); |
1224 | cejka | 629 | printf("Writing 0x%x -> %.*p\n", arg1, sizeof(__address) * 2, addr); |
603 | palkovsky | 630 | *addr = arg1; |
631 | |||
632 | } |
||
633 | |||
634 | return 1; |
||
635 | } |
||
668 | bondari | 636 | |
759 | palkovsky | 637 | /** Command for listings SLAB caches |
638 | * |
||
639 | * @param argv Ignores |
||
640 | * |
||
641 | * @return Always 1 |
||
642 | */ |
||
643 | int cmd_slabs(cmd_arg_t * argv) { |
||
644 | slab_print_list(); |
||
645 | return 1; |
||
646 | } |
||
647 | |||
777 | palkovsky | 648 | |
775 | palkovsky | 649 | /** Command for listings Thread information |
650 | * |
||
651 | * @param argv Ignores |
||
652 | * |
||
653 | * @return Always 1 |
||
654 | */ |
||
777 | palkovsky | 655 | int cmd_threads(cmd_arg_t * argv) { |
656 | thread_print_list(); |
||
657 | return 1; |
||
658 | } |
||
659 | |||
1060 | palkovsky | 660 | /** Command for listings Task information |
661 | * |
||
662 | * @param argv Ignores |
||
663 | * |
||
664 | * @return Always 1 |
||
665 | */ |
||
666 | int cmd_tasks(cmd_arg_t * argv) { |
||
667 | task_print_list(); |
||
668 | return 1; |
||
669 | } |
||
670 | |||
777 | palkovsky | 671 | /** Command for listings Thread information |
672 | * |
||
673 | * @param argv Ignores |
||
674 | * |
||
675 | * @return Always 1 |
||
676 | */ |
||
775 | palkovsky | 677 | int cmd_sched(cmd_arg_t * argv) { |
678 | sched_print_list(); |
||
679 | return 1; |
||
680 | } |
||
681 | |||
677 | bondari | 682 | /** Command for listing memory zones |
683 | * |
||
684 | * @param argv Ignored |
||
685 | * |
||
686 | * return Always 1 |
||
687 | */ |
||
668 | bondari | 688 | int cmd_zones(cmd_arg_t * argv) { |
676 | bondari | 689 | zone_print_list(); |
668 | bondari | 690 | return 1; |
691 | } |
||
673 | jermar | 692 | |
677 | bondari | 693 | /** Command for memory zone details |
694 | * |
||
695 | * @param argv Integer argument from cmdline expected |
||
696 | * |
||
697 | * return Always 1 |
||
698 | */ |
||
668 | bondari | 699 | int cmd_zone(cmd_arg_t * argv) { |
676 | bondari | 700 | zone_print_one(argv[0].intval); |
668 | bondari | 701 | return 1; |
702 | } |
||
703 | |||
1573 | palkovsky | 704 | /** Command for printing task ipc details |
705 | * |
||
706 | * @param argv Integer argument from cmdline expected |
||
707 | * |
||
708 | * return Always 1 |
||
709 | */ |
||
710 | int cmd_ipc_task(cmd_arg_t * argv) { |
||
711 | ipc_print_task(argv[0].intval); |
||
712 | return 1; |
||
713 | } |
||
714 | |||
715 | |||
673 | jermar | 716 | /** Command for listing processors. |
717 | * |
||
718 | * @param argv Ignored. |
||
719 | * |
||
720 | * return Always 1. |
||
721 | */ |
||
722 | int cmd_cpus(cmd_arg_t *argv) |
||
723 | { |
||
724 | cpu_list(); |
||
725 | return 1; |
||
726 | } |
||
727 | |||
728 | /** Command for printing kernel version. |
||
729 | * |
||
730 | * @param argv Ignored. |
||
731 | * |
||
732 | * return Always 1. |
||
733 | */ |
||
734 | int cmd_version(cmd_arg_t *argv) |
||
735 | { |
||
736 | version_print(); |
||
737 | return 1; |
||
738 | } |
||
1474 | palkovsky | 739 | |
740 | /** Command for returning console back to userspace. |
||
741 | * |
||
742 | * @param argv Ignored. |
||
743 | * |
||
744 | * return Always 1. |
||
745 | */ |
||
746 | int cmd_continue(cmd_arg_t *argv) |
||
747 | { |
||
748 | arch_release_console(); |
||
749 | return 1; |
||
750 | } |