|
RTEMS CPU Kit with SuperCore
4.10.99.0
|
00001 00007 /* 00008 * Author: 00009 * 00010 * WORK: fernando.ruiz@ctv.es 00011 * HOME: correo@fernando-ruiz.com 00012 * 00013 * Thanks at: 00014 * Chris Johns 00015 */ 00016 00017 #ifndef __RTEMS_SHELL_H__ 00018 #define __RTEMS_SHELL_H__ 00019 00020 #include <rtems.h> 00021 #include <stdio.h> 00022 #include <termios.h> 00023 #include <rtems/fs.h> 00024 #include <rtems/libio.h> 00025 #include <rtems/chain.h> 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 /* 00032 * Some key labels to define special keys. 00033 */ 00034 00035 #define RTEMS_SHELL_KEYS_EXTENDED (0x8000) 00036 #define RTEMS_SHELL_KEYS_NORMAL_MASK (0x00ff) 00037 #define RTEMS_SHELL_KEYS_INS (0) 00038 #define RTEMS_SHELL_KEYS_DEL (1) 00039 #define RTEMS_SHELL_KEYS_UARROW (2) 00040 #define RTEMS_SHELL_KEYS_DARROW (3) 00041 #define RTEMS_SHELL_KEYS_LARROW (4) 00042 #define RTEMS_SHELL_KEYS_RARROW (5) 00043 #define RTEMS_SHELL_KEYS_HOME (6) 00044 #define RTEMS_SHELL_KEYS_END (7) 00045 #define RTEMS_SHELL_KEYS_F1 (8) 00046 #define RTEMS_SHELL_KEYS_F2 (9) 00047 #define RTEMS_SHELL_KEYS_F3 (10) 00048 #define RTEMS_SHELL_KEYS_F4 (11) 00049 #define RTEMS_SHELL_KEYS_F5 (12) 00050 #define RTEMS_SHELL_KEYS_F6 (13) 00051 #define RTEMS_SHELL_KEYS_F7 (14) 00052 #define RTEMS_SHELL_KEYS_F8 (15) 00053 #define RTEMS_SHELL_KEYS_F9 (16) 00054 #define RTEMS_SHELL_KEYS_F10 (17) 00055 00056 typedef bool (*rtems_shell_login_check_t)( 00057 const char * /* user */, 00058 const char * /* passphrase */ 00059 ); 00060 00061 extern bool rtems_shell_login_prompt( 00062 FILE *in, 00063 FILE *out, 00064 const char *device, 00065 rtems_shell_login_check_t check 00066 ); 00067 00068 extern bool rtems_shell_login_check( 00069 const char *user, 00070 const char *passphrase 00071 ); 00072 00073 typedef int (*rtems_shell_command_t)(int argc, char **argv); 00074 00075 struct rtems_shell_cmd_tt; 00076 typedef struct rtems_shell_cmd_tt rtems_shell_cmd_t; 00077 00078 struct rtems_shell_cmd_tt { 00079 const char *name; 00080 const char *usage; 00081 const char *topic; 00082 rtems_shell_command_t command; 00083 rtems_shell_cmd_t *alias; 00084 rtems_shell_cmd_t *next; 00085 }; 00086 00087 typedef struct { 00088 const char *name; 00089 const char *alias; 00090 } rtems_shell_alias_t; 00091 00092 /* 00093 * The return value has RTEMS_SHELL_KEYS_EXTENDED set if the key 00094 * is extended, ie a special key. 00095 */ 00096 extern unsigned int rtems_shell_getchar(FILE *in); 00097 00098 extern rtems_shell_cmd_t * rtems_shell_lookup_cmd(const char *cmd); 00099 00100 extern rtems_shell_cmd_t *rtems_shell_add_cmd_struct( 00101 rtems_shell_cmd_t *shell_cmd 00102 ); 00103 00104 rtems_shell_cmd_t * rtems_shell_add_cmd( 00105 const char *cmd, 00106 const char *topic, 00107 const char *usage, 00108 rtems_shell_command_t command 00109 ); 00110 00111 extern rtems_shell_cmd_t * rtems_shell_alias_cmd( 00112 const char *cmd, 00113 const char *alias 00114 ); 00115 00116 extern int rtems_shell_make_args( 00117 char *commandLine, 00118 int *argc_p, 00119 char **argv_p, 00120 int max_args 00121 ); 00122 00123 extern int rtems_shell_cat_file( 00124 FILE *out, 00125 const char *name 00126 ); 00127 00128 extern void rtems_shell_write_file( 00129 const char *name, 00130 const char *content 00131 ); 00132 00133 extern int rtems_shell_script_file( 00134 int argc, 00135 char **argv 00136 ); 00137 00150 extern rtems_status_code rtems_shell_init( 00151 const char *task_name, 00152 size_t task_stacksize, 00153 rtems_task_priority task_priority, 00154 const char *devname, 00155 bool forever, 00156 bool wait, 00157 rtems_shell_login_check_t login_check 00158 ); 00159 00173 extern rtems_status_code rtems_shell_script( 00174 const char *task_name, 00175 size_t task_stacksize, /* 0 default*/ 00176 rtems_task_priority task_priority, 00177 const char *input, 00178 const char *output, 00179 bool output_append, 00180 bool wait, 00181 bool echo 00182 ); 00183 00187 typedef struct { 00189 rtems_name magic; 00190 const char *devname; 00191 const char *taskname; 00192 bool exit_shell; /* logout */ 00193 bool forever; /* repeat login */ 00194 int errorlevel; 00195 bool echo; 00196 char cwd[256]; 00197 const char *input; 00198 const char *output; 00199 bool output_append; 00200 rtems_id wake_on_end; 00201 rtems_shell_login_check_t login_check; 00202 } rtems_shell_env_t; 00203 00204 bool rtems_shell_main_loop( 00205 rtems_shell_env_t *rtems_shell_env 00206 ); 00207 00208 extern rtems_shell_env_t rtems_global_shell_env; 00209 extern rtems_shell_env_t *rtems_current_shell_env; 00210 00211 /* 00212 * The types of file systems we can mount. We have them broken out 00213 * out like this so they can be configured by shellconfig.h. The 00214 * mount command needs special treatment due to some file systems 00215 * being dependent on the network stack and some not. If we had 00216 * all possible file systems being included it would force the 00217 * networking stack into the applcation and this may not be 00218 * required. 00219 */ 00220 struct rtems_shell_filesystems_tt; 00221 typedef struct rtems_shell_filesystems_tt rtems_shell_filesystems_t; 00222 00223 typedef int (*rtems_shell_filesystems_mounter_t)( 00224 const char* driver, 00225 const char* path, 00226 rtems_shell_filesystems_t* fs, 00227 rtems_filesystem_options_t options 00228 ); 00229 00230 struct rtems_shell_filesystems_tt { 00231 rtems_chain_node link; 00232 const char *name; 00233 int driver_needed; 00234 const rtems_filesystem_operations_table *fs_ops; 00235 rtems_shell_filesystems_mounter_t mounter; 00236 }; 00237 00251 extern void rtems_shell_get_prompt( 00252 rtems_shell_env_t *shell_env, 00253 char *prompt, 00254 size_t size 00255 ); 00256 00265 extern int rtems_shell_libc_mounter( 00266 const char* driver, 00267 const char* path, 00268 rtems_shell_filesystems_t* fs, 00269 rtems_filesystem_options_t options 00270 ); 00271 00277 extern void rtems_shell_mount_add_fsys(rtems_shell_filesystems_t* fs); 00278 00284 extern void rtems_shell_mount_del_fsys(rtems_shell_filesystems_t* fs); 00285 00286 typedef void (*rtems_shell_wait_for_input_notification)( 00287 int fd, 00288 int seconds_remaining, 00289 void *arg 00290 ); 00291 00299 extern rtems_status_code rtems_shell_wait_for_input( 00300 int fd, 00301 int timeout_in_seconds, 00302 rtems_shell_wait_for_input_notification notification, 00303 void *notification_arg 00304 ); 00305 00306 extern int rtems_shell_main_monitor(int argc, char **argv); 00307 00308 00309 #ifdef __cplusplus 00310 } 00311 #endif 00312 00313 #endif
1.7.5