提交 0e4bd640 编写于 作者: A ArdaFu

1. [Core] Add INIT_EXPORT_EX micro define. this micro will help the user to...

1. [Core] Add INIT_EXPORT_EX micro define. this micro will help the user to organize the start sequence of board/device/application initialization functions.
上级 143d3b82
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
* RT_USING_MEMHEAP condition. * RT_USING_MEMHEAP condition.
* 2012-12-30 Bernard add more control command for graphic. * 2012-12-30 Bernard add more control command for graphic.
* 2013-01-09 Bernard change version number. * 2013-01-09 Bernard change version number.
* 2014-11-24 Arda.Fu add INIT_EXPORT_EX micro define
*/ */
#ifndef __RT_DEF_H__ #ifndef __RT_DEF_H__
...@@ -172,43 +173,55 @@ typedef rt_base_t rt_off_t; /**< Type for offset */ ...@@ -172,43 +173,55 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
/* initialization export */ /* initialization export */
#ifdef RT_USING_COMPONENTS_INIT #ifdef RT_USING_COMPONENTS_INIT
typedef int (*init_fn_t)(void); typedef int (*init_fn_t)(void);
#ifdef _MSC_VER /* we do not support MS VC++ compiler */ #ifdef _MSC_VER /* we do not support MS VC++ compiler */
#define INIT_EXPORT(fn, level) #define INIT_EXPORT(fn, level)
#else #define INIT_EXPORT_EX(fn, level, sublevel)
#if RT_DEBUG_INIT #else
struct rt_init_desc #if RT_DEBUG_INIT
{ struct rt_init_desc
const char* fn_name; {
const init_fn_t fn; const char* fn_name;
}; const init_fn_t fn;
#define INIT_EXPORT(fn, level) \ };
const char __rti_##fn##_name[] = #fn; \ #define INIT_EXPORT(fn, level) \
const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \ const char __rti_##fn##_name[] = "["#level"]"#fn; \
{ __rti_##fn##_name, fn}; const struct rt_init_desc __rt_init_desc_##fn \
#else SECTION(".rti_fn."level) = { __rti_##fn##_name, fn};
#define INIT_EXPORT(fn, level) \ #define INIT_EXPORT_EX(fn, level, index) \
const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn const char __rti_##fn##_name[] = "["#level":"#index"]"#fn; \
#endif const struct rt_init_desc __rt_init_desc_##fn \
#endif SECTION(".rti_fn."level#index) = { __rti_##fn##_name, fn};
#else
#define INIT_EXPORT(fn, level) \
const init_fn_t __rt_init_##fn \
SECTION(".rti_fn."level) = fn
#define INIT_EXPORT_EX(fn, level, index) \
const init_fn_t __rt_init_##fn \
SECTION(".rti_fn."level#index) = fn
#endif
#endif
#else #else
#define INIT_EXPORT(fn, level) #define INIT_EXPORT(fn, level)
#define INIT_EXPORT_EX(fn, level, sublevel)
#endif #endif
/* board init routines will be called in board_init() function */ /* board init routines will be called in board_init() function */
#define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1") #define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1")
#define INIT_BOARD_EXPORT_EX(fn, index) INIT_EXPORT_EX(fn, "1", index)
/* device/component/fs/app init routines will be called in init_thread */ /* device/component/fs/app init routines will be called in init_thread */
/* device initialization */ /* device initialization */
#define INIT_DEVICE_EXPORT(fn) INIT_EXPORT(fn, "2") #define INIT_DEVICE_EXPORT(fn) INIT_EXPORT(fn, "2")
#define INIT_DEVICE_EXPORT_EX(fn, index) INIT_EXPORT_EX(fn, "2", index)
/* components initialization (dfs, lwip, ...) */ /* components initialization (dfs, lwip, ...) */
#define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "3") #define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "3")
/* file system initialization (dfs-elm, dfs-rom, ...) */ /* file system initialization (dfs-elm, dfs-rom, ...) */
#define INIT_FS_EXPORT(fn) INIT_EXPORT(fn, "4") #define INIT_FS_EXPORT(fn) INIT_EXPORT(fn, "4")
/* environment initialization (mount disk, ...) */ /* environment initialization (mount disk, ...) */
#define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5") #define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
/* appliation initialization (rtgui application etc ...) */ /* appliation initialization (rtgui application etc ...) */
#define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6") #define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6")
#define INIT_APP_EXPORT_EX(fn, index) INIT_EXPORT_EX(fn, "6", index)
#if !defined(RT_USING_FINSH) #if !defined(RT_USING_FINSH)
/* define these to empty, even if not include finsh.h file */ /* define these to empty, even if not include finsh.h file */
#define FINSH_FUNCTION_EXPORT(name, desc) #define FINSH_FUNCTION_EXPORT(name, desc)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册