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.

This commit is contained in:
ArdaFu 2014-11-24 12:21:11 +08:00
parent 143d3b8224
commit 0e4bd64089
1 changed files with 35 additions and 22 deletions

View File

@ -29,6 +29,7 @@
* RT_USING_MEMHEAP condition.
* 2012-12-30 Bernard add more control command for graphic.
* 2013-01-09 Bernard change version number.
* 2014-11-24 Arda.Fu add INIT_EXPORT_EX micro define
*/
#ifndef __RT_DEF_H__
@ -172,10 +173,11 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
/* initialization export */
#ifdef RT_USING_COMPONENTS_INIT
typedef int (*init_fn_t)(void);
#ifdef _MSC_VER /* we do not support MS VC++ compiler */
typedef int (*init_fn_t)(void);
#ifdef _MSC_VER /* we do not support MS VC++ compiler */
#define INIT_EXPORT(fn, level)
#else
#define INIT_EXPORT_EX(fn, level, sublevel)
#else
#if RT_DEBUG_INIT
struct rt_init_desc
{
@ -183,23 +185,34 @@ typedef int (*init_fn_t)(void);
const init_fn_t fn;
};
#define INIT_EXPORT(fn, level) \
const char __rti_##fn##_name[] = #fn; \
const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
{ __rti_##fn##_name, fn};
const char __rti_##fn##_name[] = "["#level"]"#fn; \
const struct rt_init_desc __rt_init_desc_##fn \
SECTION(".rti_fn."level) = { __rti_##fn##_name, fn};
#define INIT_EXPORT_EX(fn, level, index) \
const char __rti_##fn##_name[] = "["#level":"#index"]"#fn; \
const struct rt_init_desc __rt_init_desc_##fn \
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
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
#endif
#else
#define INIT_EXPORT(fn, level)
#define INIT_EXPORT(fn, level)
#define INIT_EXPORT_EX(fn, level, sublevel)
#endif
/* board init routines will be called in board_init() function */
#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 initialization */
#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, ...) */
#define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "3")
/* file system initialization (dfs-elm, dfs-rom, ...) */
@ -208,7 +221,7 @@ typedef int (*init_fn_t)(void);
#define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
/* appliation initialization (rtgui application etc ...) */
#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)
/* define these to empty, even if not include finsh.h file */
#define FINSH_FUNCTION_EXPORT(name, desc)