16#pragma section("FSymTab$f",read)
19#ifdef FINSH_USING_OPTION_COMPLETION
20#define FINSH_COND(opt) opt,
22#define FINSH_COND(opt)
25#ifdef FINSH_USING_DESCRIPTION
26#define FINSH_DESC(cmd, desc) __fsym_##cmd##_desc,
28#define FINSH_DESC(cmd, desc)
32#ifdef FINSH_USING_SYMTAB
34#ifdef __TI_COMPILER_VERSION__
35#define __TI_FINSH_EXPORT_FUNCTION(f) PRAGMA(DATA_SECTION(f,"FSymTab"))
46#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc, opt) \
47 const char __fsym_##cmd##_name[] = #cmd; \
48 const char __fsym_##cmd##_desc[] = #desc; \
49 __declspec(allocate("FSymTab$f")) \
50 const struct finsh_syscall __fsym_##cmd = \
52 __fsym_##cmd##_name, \
53 FINSH_DESC(cmd, desc) \
57#pragma comment(linker, "/merge:FSymTab=mytext")
59#elif defined(__TI_COMPILER_VERSION__)
61#define RT_NOBLOCKED __attribute__((noblocked))
65#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc, opt) \
66 __TI_FINSH_EXPORT_FUNCTION(__fsym_##cmd); \
67 const char __fsym_##cmd##_name[] = #cmd; \
68 const char __fsym_##cmd##_desc[] = #desc; \
69 rt_used RT_NOBLOCKED const struct finsh_syscall __fsym_##cmd = \
71 __fsym_##cmd##_name, \
72 FINSH_DESC(cmd, desc) \
78#define MSH_FUNCTION_EXPORT_CMD(name, cmd, desc, opt) \
79 const char __fsym_##cmd##_name[] rt_section(".rodata.name") = #cmd; \
80 const char __fsym_##cmd##_desc[] rt_section(".rodata.name") = #desc; \
81 rt_used const struct finsh_syscall __fsym_##cmd rt_section("FSymTab")= \
83 __fsym_##cmd##_name, \
84 FINSH_DESC(cmd, desc) \
95#define __MSH_GET_MACRO(_1, _2, _3, _FUN, ...) _FUN
96#define __MSH_GET_EXPORT_MACRO(_1, _2, _3, _4, _FUN, ...) _FUN
98#define _MSH_FUNCTION_CMD2(a0, a1) \
99 MSH_FUNCTION_EXPORT_CMD(a0, a0, a1, 0)
101#define _MSH_FUNCTION_CMD2_OPT(a0, a1, a2) \
102 MSH_FUNCTION_EXPORT_CMD(a0, a0, a1, a0##_msh_options)
104#define _MSH_FUNCTION_EXPORT_CMD3(a0, a1, a2) \
105 MSH_FUNCTION_EXPORT_CMD(a0, a1, a2, 0)
107#define _MSH_FUNCTION_EXPORT_CMD3_OPT(a0, a1, a2, a3) \
108 MSH_FUNCTION_EXPORT_CMD(a0, a1, a2, a0##_msh_options)
119#define FINSH_FUNCTION_EXPORT(name, desc)
130#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)
142#define MSH_CMD_EXPORT(...) \
143 __MSH_GET_MACRO(__VA_ARGS__, _MSH_FUNCTION_CMD2_OPT, \
144 _MSH_FUNCTION_CMD2)(__VA_ARGS__)
160#define MSH_CMD_EXPORT_ALIAS(...) \
161 __MSH_GET_EXPORT_MACRO(__VA_ARGS__, _MSH_FUNCTION_EXPORT_CMD3_OPT, \
162 _MSH_FUNCTION_EXPORT_CMD3)(__VA_ARGS__)
168#if defined(FINSH_USING_DESCRIPTION) && defined(FINSH_USING_SYMTAB)
172#ifdef FINSH_USING_OPTION_COMPLETION
173 struct msh_cmd_opt *opt;
185#ifdef FINSH_USING_OPTION_COMPLETION
186typedef struct msh_cmd_opt
199#define CMD_OPTIONS_STATEMENT(command) static struct msh_cmd_opt command##_msh_options[];
205#define CMD_OPTIONS_NODE_START(command) static struct msh_cmd_opt command##_msh_options[] = {
213#define CMD_OPTIONS_NODE(_id, _name, _des) {.id = _id, .name = #_name, .des = #_des},
218#define CMD_OPTIONS_NODE_END {0},};
220void msh_opt_list_dump(
void *options);
221int msh_cmd_opt_id_get(
int argc,
char *argv[],
void *options);
222#define MSH_OPT_ID_GET(fun) msh_cmd_opt_id_get(argc, argv, (void*) fun##_msh_options)
223#define MSH_OPT_DUMP(fun) msh_opt_list_dump((void*) fun##_msh_options)
226#define CMD_OPTIONS_STATEMENT(command)
227#define CMD_OPTIONS_NODE_START(command)
228#define CMD_OPTIONS_NODE(_id, _name, _des)
229#define CMD_OPTIONS_NODE_END
230#define MSH_OPT_ID_GET(fun) ((int)(-1UL))
231#define MSH_OPT_DUMP(fun) do{}while(0)
237#if defined(_MSC_VER) || (defined(__GNUC__) && defined(__x86_64__))
239 #define FINSH_NEXT_SYSCALL(index) index=finsh_syscall_next(index)
241 #define FINSH_NEXT_SYSCALL(index) index++
244#if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
long(* syscall_func)(void)
struct finsh_syscall * _syscall_table_end
struct finsh_syscall_item * global_syscall_list
struct finsh_syscall * _syscall_table_begin
void finsh_set_device(const char *device_name)
struct finsh_syscall_item * next
struct finsh_syscall syscall