4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-18 16:43:32 +08:00

finsh: add CCS support

This commit is contained in:
Grissiom 2013-05-29 23:37:43 +08:00
parent 810311b624
commit 27ee5b627b
2 changed files with 164 additions and 91 deletions

View File

@ -176,6 +176,13 @@ extern struct finsh_sysvar_item* global_sysvar_list;
struct finsh_sysvar* finsh_sysvar_lookup(const char* name); struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
#ifdef FINSH_USING_SYMTAB #ifdef FINSH_USING_SYMTAB
#ifdef __TI_COMPILER_VERSION__
#define _EMIT_PRAGMA(x) _Pragma(#x)
#define __TI_FINSH_EXPORT_FUNCTION(f) _EMIT_PRAGMA(DATA_SECTION(f,"FSymTab"))
#define __TI_FINSH_EXPORT_VAR(v) _EMIT_PRAGMA(DATA_SECTION(v,"VSymTab"))
#endif
#ifdef FINSH_USING_DESCRIPTION #ifdef FINSH_USING_DESCRIPTION
/** /**
* @ingroup finsh * @ingroup finsh
@ -185,28 +192,39 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
* @param name the name of function. * @param name the name of function.
* @param desc the description of function, which will show in help. * @param desc the description of function, which will show in help.
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
#define FINSH_FUNCTION_EXPORT(name, desc) \ #define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \ const char __fsym_##name##_name[] = #name; \
const char __fsym_##name##_desc[] = #desc; \ const char __fsym_##name##_desc[] = #desc; \
__declspec(allocate("FSymTab$f")) const struct finsh_syscall __fsym_##name = \ __declspec(allocate("FSymTab$f")) const struct finsh_syscall __fsym_##name = \
{ \ { \
__fsym_##name##_name, \ __fsym_##name##_name, \
__fsym_##name##_desc, \ __fsym_##name##_desc, \
(syscall_func)&name \ (syscall_func)&name \
}; };
#pragma comment(linker, "/merge:FSymTab=mytext") #pragma comment(linker, "/merge:FSymTab=mytext")
#else #elif defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT(name, desc) \ #define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \ __TI_FINSH_EXPORT_FUNCTION(__fsym_##name); \
const char __fsym_##name##_desc[] = #desc; \ const char __fsym_##name##_name[] = #name; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \ const char __fsym_##name##_desc[] = #desc; \
{ \ const struct finsh_syscall __fsym_##name = \
__fsym_##name##_name, \ { \
__fsym_##name##_desc, \ __fsym_##name##_name, \
(syscall_func)&name \ __fsym_##name##_desc, \
}; (syscall_func)&name \
#endif };
#else
#define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \
const char __fsym_##name##_desc[] = #desc; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
{ \
__fsym_##name##_name, \
__fsym_##name##_desc, \
(syscall_func)&name \
};
#endif /* FINSH_FUNCTION_EXPORT defines */
/** /**
* @ingroup finsh * @ingroup finsh
@ -217,27 +235,38 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
* @param alias the alias name of function. * @param alias the alias name of function.
* @param desc the description of function, which will show in help. * @param desc the description of function, which will show in help.
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \ #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##name##_name[] = #alias; \ const char __fsym_##name##_name[] = #alias; \
const char __fsym_##name##_desc[] = #desc; \ const char __fsym_##name##_desc[] = #desc; \
__declspec(allocate("FSymTab$f")) const struct finsh_syscall __fsym_##name = \ __declspec(allocate("FSymTab$f")) const struct finsh_syscall __fsym_##name = \
{ \ { \
__fsym_##name##_name, \ __fsym_##name##_name, \
__fsym_##name##_desc, \ __fsym_##name##_desc, \
(syscall_func)&name \ (syscall_func)&name \
}; };
#else #elif defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \ #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##name##_name[] = #alias; \ __TI_FINSH_EXPORT_FUNCTION(__fsym_##name); \
const char __fsym_##name##_desc[] = #desc; \ const char __fsym_##name##_name[] = #alias; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \ const char __fsym_##name##_desc[] = #desc; \
{ \ const struct finsh_syscall __fsym_##name = \
__fsym_##name##_name, \ { \
__fsym_##name##_desc, \ __fsym_##name##_name, \
(syscall_func)&name \ __fsym_##name##_desc, \
}; (syscall_func)&name \
#endif };
#else
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##name##_name[] = #alias; \
const char __fsym_##name##_desc[] = #desc; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
{ \
__fsym_##name##_name, \
__fsym_##name##_desc, \
(syscall_func)&name \
};
#endif /* FINSH_FUNCTION_EXPORT_ALIAS defines */
/** /**
* @ingroup finsh * @ingroup finsh
* *
@ -247,55 +276,98 @@ struct finsh_sysvar* finsh_sysvar_lookup(const char* name);
* @param type the type of variable. * @param type the type of variable.
* @param desc the description of function, which will show in help. * @param desc the description of function, which will show in help.
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER
#define FINSH_VAR_EXPORT(name, type, desc) \ #define FINSH_VAR_EXPORT(name, type, desc) \
const char __vsym_##name##_name[] = #name; \ const char __vsym_##name##_name[] = #name; \
const char __vsym_##name##_desc[] = #desc; \ const char __vsym_##name##_desc[] = #desc; \
__declspec(allocate("VSymTab")) const struct finsh_sysvar __vsym_##name = \ __declspec(allocate("VSymTab")) const struct finsh_sysvar __vsym_##name = \
{ \ { \
__vsym_##name##_name, \ __vsym_##name##_name, \
__vsym_##name##_desc, \ __vsym_##name##_desc, \
type, \ type, \
(void*)&name \ (void*)&name \
}; };
#else #elif defined(__TI_COMPILER_VERSION__)
#define FINSH_VAR_EXPORT(name, type, desc) \ #define FINSH_VAR_EXPORT(name, type, desc) \
const char __vsym_##name##_name[] = #name; \ __TI_FINSH_EXPORT_VAR(__vsym_##name); \
const char __vsym_##name##_desc[] = #desc; \ const char __vsym_##name##_name[] = #name; \
const struct finsh_sysvar __vsym_##name SECTION("VSymTab")= \ const char __vsym_##name##_desc[] = #desc; \
{ \ const struct finsh_sysvar __vsym_##name = \
__vsym_##name##_name, \ { \
__vsym_##name##_desc, \ __vsym_##name##_name, \
type, \ __vsym_##name##_desc, \
(void*)&name \ type, \
}; (void*)&name \
#endif };
#else #else
#define FINSH_FUNCTION_EXPORT(name, desc) \ #define FINSH_VAR_EXPORT(name, type, desc) \
const char __fsym_##name##_name[] = #name; \ const char __vsym_##name##_name[] = #name; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \ const char __vsym_##name##_desc[] = #desc; \
{ \ const struct finsh_sysvar __vsym_##name SECTION("VSymTab")= \
__fsym_##name##_name, \ { \
(syscall_func)&name \ __vsym_##name##_name, \
}; __vsym_##name##_desc, \
type, \
(void*)&name \
};
#endif /* FINSH_VAR_EXPORT defines */
#else /* FINSH_USING_DESCRIPTION */
#if defined(__TI_COMPILER_VERSION__)
#define FINSH_FUNCTION_EXPORT(name, desc) \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##name); \
const char __fsym_##name##_name[] = #name; \
const char __fsym_##name##_desc[] = #desc; \
const struct finsh_syscall __fsym_##name = \
{ \
__fsym_##name##_name, \
__fsym_##name##_desc, \
(syscall_func)&name \
};
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __fsym_##name##_name[] = #alias; \
__TI_FINSH_EXPORT_FUNCTION(__fsym_##name); \
const struct finsh_syscall __fsym_##name = \
{ \
__fsym_##name##_name, \
(syscall_func)&name \
};
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \ #define FINSH_VAR_EXPORT(name, type, desc) \
const char __fsym_##name##_name[] = #alias; \ __TI_FINSH_EXPORT_VAR(__vsym_##name); \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \ const char __vsym_##name##_name[] = #name; \
{ \ const struct finsh_sysvar __vsym_##name = \
__fsym_##name##_name, \ { \
(syscall_func)&name \ __vsym_##name##_name, \
}; type, \
(void*)&name \
};
#else
#define FINSH_FUNCTION_EXPORT(name, desc) \
const char __fsym_##name##_name[] = #name; \
const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
{ \
__fsym_##name##_name, \
(syscall_func)&name \
};
#define FINSH_VAR_EXPORT(name, type, desc) \ #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) \
const char __vsym_##name##_name[] = #name; \ const char __fsym_##name##_name[] = #alias; \
const struct finsh_sysvar __vsym_##name SECTION("VSymTab")= \ const struct finsh_syscall __fsym_##name SECTION("FSymTab")= \
{ \ { \
__vsym_##name##_name, \ __fsym_##name##_name, \
type, \ (syscall_func)&name \
(void*)&name \ };
};
#endif #define FINSH_VAR_EXPORT(name, type, desc) \
const char __vsym_##name##_name[] = #name; \
const struct finsh_sysvar __vsym_##name SECTION("VSymTab")= \
{ \
__vsym_##name##_name, \
type, \
(void*)&name \
};
#endif /* __TI_COMPILER_VERSION__ */
#endif /* FINSH_USING_DESCRIPTION */
#else #else
#define FINSH_FUNCTION_EXPORT(name, desc) #define FINSH_FUNCTION_EXPORT(name, desc)
#define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc) #define FINSH_FUNCTION_EXPORT_ALIAS(name, alias, desc)

View File

@ -528,7 +528,8 @@ void finsh_system_init(void)
__section_end("FSymTab")); __section_end("FSymTab"));
finsh_system_var_init(__section_begin("VSymTab"), finsh_system_var_init(__section_begin("VSymTab"),
__section_end("VSymTab")); __section_end("VSymTab"));
#elif defined (__GNUC__) /* GNU GCC Compiler */ #elif defined (__GNUC__) || defined(__TI_COMPILER_VERSION__)
/* GNU GCC Compiler and TI CCS */
extern const int __fsymtab_start; extern const int __fsymtab_start;
extern const int __fsymtab_end; extern const int __fsymtab_end;
extern const int __vsymtab_start; extern const int __vsymtab_start;