File indexing completed on 2025-05-11 08:24:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #ifdef HAVE_CONFIG_H
0039 #include "config.h"
0040 #endif
0041
0042 #include <stdbool.h>
0043 #include <stdio.h>
0044 #include <stdlib.h>
0045 #include <string.h>
0046
0047 #include <rtems/rtl/rap.h>
0048 #include <rtems/rtl/rap-shell.h>
0049
0050 static void
0051 shell_rap_command_help (void)
0052 {
0053 printf ("usage: rap [cmd] [arg]\n" \
0054 "Commands and options:\n" \
0055 "ls: List the loaded applications (also list)\n" \
0056 "ld: Load an application (also load)\n" \
0057 "un: Unload an application (also unload)\n");
0058 }
0059
0060 static void
0061 shell_rap_get_error (const char* what)
0062 {
0063 char message[64];
0064 int error;
0065 error = rtems_rap_get_error (message, sizeof (message));
0066 printf ("error: %s: (%d) %s\n", what, error, message);
0067 }
0068
0069 static bool
0070 shell_rap_list_handler (void* handle)
0071 {
0072 printf (" %-10p %-10p %-s\n",
0073 handle, rtems_rap_dl_handle (handle), rtems_rap_name (handle));
0074 return true;
0075 }
0076
0077 static int
0078 shell_rap_list (int argc, char* argv[])
0079 {
0080 printf (" App DL Handle Name\n");
0081 return rtems_rap_iterate (shell_rap_list_handler) ? 0 : 1;
0082 }
0083
0084 static int
0085 shell_rap_load (int argc, char* argv[])
0086 {
0087 int r = 0;
0088 if (argc == 0)
0089 {
0090 printf ("error: no application name\n");
0091 return 0;
0092 }
0093 if (rtems_rap_load (argv[0], 0, argc - 1, (const char**) (argv + 1)))
0094 printf ("%s loaded\n", argv[0]);
0095 else
0096 {
0097 r = 1;
0098 shell_rap_get_error ("loading");
0099 }
0100 return r;
0101 }
0102
0103 int
0104 shell_rap (int argc, char* argv[])
0105 {
0106 if (argc == 1)
0107 {
0108 shell_rap_command_help ();
0109 return 0;
0110 }
0111
0112 if ((strcmp (argv[1], "ls") == 0) ||
0113 (strcmp (argv[1], "list") == 0))
0114 {
0115 return shell_rap_list (argc - 2, argv + 2);
0116 }
0117 else if ((strcmp (argv[1], "ld") == 0) ||
0118 (strcmp (argv[1], "load") == 0))
0119 {
0120 return shell_rap_load (argc - 2, argv + 2);
0121 }
0122
0123 printf ("error: invalid command: %s\n", argv[1]);
0124 return 0;
0125 }
0126