File indexing completed on 2025-05-11 08:24:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifdef HAVE_CONFIG_H
0016 #include "config.h"
0017 #endif
0018
0019 #include <stdio.h>
0020 #include <string.h>
0021 #include <stdlib.h>
0022
0023 #include <rtems.h>
0024 #include <rtems/monitor.h>
0025 #include <rtems/shell.h>
0026 #include "internal.h"
0027
0028
0029
0030
0031
0032 int rtems_shell_main_monitor(int argc, char **argv) {
0033 const rtems_monitor_command_entry_t *command = NULL;
0034
0035 if (argc < 1) {
0036 return 1;
0037 }
0038
0039 command = rtems_monitor_command_lookup(argv [0]);
0040
0041 if (command == NULL) {
0042 return 1;
0043 }
0044
0045 command->command_function(argc, argv, &command->command_arg, 0);
0046
0047 return 0;
0048 }
0049
0050 static bool rtems_shell_register_command(const rtems_monitor_command_entry_t *e, void *arg RTEMS_UNUSED)
0051 {
0052
0053 if (strcmp("exit", e->command) != 0) {
0054 rtems_shell_cmd_t *shell_cmd =
0055 (rtems_shell_cmd_t *) calloc(1, sizeof(*shell_cmd));
0056
0057 if (shell_cmd != NULL) {
0058 shell_cmd->name = e->command;
0059 shell_cmd->topic = "monitor";
0060 shell_cmd->usage = e->usage;
0061 shell_cmd->command = rtems_shell_main_monitor;
0062
0063 if (rtems_shell_add_cmd_struct(shell_cmd) == NULL) {
0064 free(shell_cmd);
0065 }
0066 }
0067 }
0068
0069 return true;
0070 }
0071
0072 void rtems_shell_register_monitor_commands(void)
0073 {
0074 rtems_monitor_command_iterate(rtems_shell_register_command, NULL);
0075 }