[dd74e612] | 1 | /* |
---|
[814d9588] | 2 | * XXX -- Just monitor commands until those can be integrated better |
---|
| 3 | * |
---|
[4e5299f] | 4 | * Author: Fernando RUIZ CASAS |
---|
[dd74e612] | 5 | * Work: fernando.ruiz@ctv.es |
---|
| 6 | * Home: correo@fernando-ruiz.com |
---|
| 7 | * |
---|
[4e5299f] | 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 10 | * http://www.rtems.org/license/LICENSE. |
---|
[dd74e612] | 11 | */ |
---|
| 12 | |
---|
[550c3df7] | 13 | #ifdef HAVE_CONFIG_H |
---|
| 14 | #include "config.h" |
---|
| 15 | #endif |
---|
| 16 | |
---|
[dd74e612] | 17 | #include <stdio.h> |
---|
| 18 | #include <string.h> |
---|
[9d773936] | 19 | #include <stdlib.h> |
---|
[dd74e612] | 20 | |
---|
| 21 | #include <rtems.h> |
---|
| 22 | #include <rtems/monitor.h> |
---|
| 23 | #include <rtems/shell.h> |
---|
[4e5299f] | 24 | #include "internal.h" |
---|
[dd74e612] | 25 | |
---|
[aed742c] | 26 | /*-----------------------------------------------------------* |
---|
[4e5299f] | 27 | * with this you can call at all the rtems monitor commands. |
---|
| 28 | * Not all work fine but you can show the rtems status and more. |
---|
[dd74e612] | 29 | *-----------------------------------------------------------*/ |
---|
[32f5014b] | 30 | int rtems_shell_main_monitor(int argc, char **argv) { |
---|
[e41eaa88] | 31 | const rtems_monitor_command_entry_t *command = NULL; |
---|
[dd74e612] | 32 | |
---|
[e41eaa88] | 33 | if (argc < 1) { |
---|
| 34 | return 1; |
---|
| 35 | } |
---|
| 36 | |
---|
[eb961961] | 37 | command = rtems_monitor_command_lookup(argv [0]); |
---|
[e41eaa88] | 38 | |
---|
| 39 | if (command == NULL) { |
---|
| 40 | return 1; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | command->command_function(argc, argv, &command->command_arg, 0); |
---|
[dd74e612] | 44 | |
---|
[b2712e3] | 45 | return 0; |
---|
| 46 | } |
---|
[4e5299f] | 47 | |
---|
[031deada] | 48 | static bool rtems_shell_register_command(const rtems_monitor_command_entry_t *e, void *arg __attribute__((unused))) |
---|
[814d9588] | 49 | { |
---|
[eb961961] | 50 | /* Exclude EXIT (alias quit)*/ |
---|
| 51 | if (strcmp("exit", e->command) != 0) { |
---|
| 52 | rtems_shell_cmd_t *shell_cmd = |
---|
[7eada71] | 53 | (rtems_shell_cmd_t *) calloc(1, sizeof(*shell_cmd)); |
---|
[0893220] | 54 | |
---|
[eb961961] | 55 | if (shell_cmd != NULL) { |
---|
| 56 | shell_cmd->name = e->command; |
---|
| 57 | shell_cmd->topic = "monitor"; |
---|
| 58 | shell_cmd->usage = e->usage; |
---|
| 59 | shell_cmd->command = rtems_shell_main_monitor; |
---|
[0893220] | 60 | |
---|
[eb961961] | 61 | if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) { |
---|
| 62 | free(shell_cmd); |
---|
[e41eaa88] | 63 | } |
---|
| 64 | } |
---|
[4e5299f] | 65 | } |
---|
[eb961961] | 66 | |
---|
| 67 | return true; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | void rtems_shell_register_monitor_commands(void) |
---|
| 71 | { |
---|
| 72 | rtems_monitor_command_iterate(rtems_shell_register_command, NULL); |
---|
[dd74e612] | 73 | } |
---|