summaryrefslogtreecommitdiff
path: root/components/init/components.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-06-23 07:48:42 +0800
committerBernard Xiong <[email protected]>2013-06-23 07:48:42 +0800
commit98c8a23e9456b6a03f285245fbe9432b825e4f45 (patch)
treeacd0c83ac2d1015713a4fbc3ccb55955cdb8a868 /components/init/components.c
parentc5927f51b3dcba72aea4aca26fdb3bffb1d6f763 (diff)
Add component initialization.
Diffstat (limited to 'components/init/components.c')
-rw-r--r--components/init/components.c119
1 files changed, 52 insertions, 67 deletions
diff --git a/components/init/components.c b/components/init/components.c
index b8dae7ce1a..8fe774708e 100644
--- a/components/init/components.c
+++ b/components/init/components.c
@@ -12,86 +12,71 @@
* 2012-09-20 Bernard Change the name to components.c
* And all components related header files.
* 2012-12-23 Bernard fix the pthread initialization issue.
+ * 2013-06-23 Bernard Add the init_call for components initialization.
*/
#include "components.h"
-/**
- * RT-Thread Components Initialization
- */
-void rt_components_init(void)
+static int rti_start(void)
{
-#ifdef RT_USING_MODULE
- rt_system_module_init();
-#endif
-
-#ifdef RT_USING_FINSH
- /* initialize finsh */
- finsh_system_init();
- finsh_set_device(RT_CONSOLE_DEVICE_NAME);
-#endif
-
-#ifdef RT_USING_LWIP
- /* initialize lwip stack */
- /* register ethernetif device */
- eth_system_device_init();
-
- /* initialize lwip system */
- lwip_system_init();
- rt_kprintf("TCP/IP initialized!\n");
-#endif
-
-#ifdef RT_USING_DFS
- /* initialize the device file system */
- dfs_init();
-
- #ifdef RT_USING_DFS_ELMFAT
- /* initialize the elm chan FatFS file system*/
- elm_init();
- #endif
-
- #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP)
- /* initialize NFSv3 client file system */
- nfs_init();
- #endif
-
- #ifdef RT_USING_DFS_YAFFS2
- dfs_yaffs2_init();
- #endif
+ return 0;
+}
+INIT_EXPORT(rti_start, "0");
- #ifdef RT_USING_DFS_UFFS
- dfs_uffs_init();
- #endif
+static int rti_board_end(void)
+{
+ return 0;
+}
+INIT_EXPORT(rti_board_end, "1.post");
- #ifdef RT_USING_DFS_JFFS2
- dfs_jffs2_init();
- #endif
+static int rti_end(void)
+{
+ return 0;
+}
+INIT_EXPORT(rti_end,"7");
- #ifdef RT_USING_DFS_ROMFS
- dfs_romfs_init();
- #endif
+#if defined(_MSC_VER) || (defined(__GNUC__) && defined(__x86_64__))
+/* fixed for MSC_VC and x86_64 in GNU GCC */
+#define NEXT_COMPONENT_FN(fn_ptr, end) fn_ptr = _next_component_fn(fn_ptr, end)
- #ifdef RT_USING_DFS_DEVFS
- devfs_init();
- #endif
-#endif /* end of RT_USING_DFS */
+const init_fn_t* _next_component_fn(const init_fn_t* fn, const init_fn_t* end)
+{
+ unsigned int *ptr;
+ ptr = (unsigned int*) (fn + 1);
+ while ((*ptr == 0) && ((unsigned int*)ptr < (unsigned int*)end))
+ ptr ++;
-#ifdef RT_USING_NEWLIB
- libc_system_init(RT_CONSOLE_DEVICE_NAME);
+ return (const init_fn_t*)ptr;
+}
#else
- /* the pthread system initialization will be initiallized in libc */
- #ifdef RT_USING_PTHREADS
- pthread_system_init();
- #endif
+#define NEXT_COMPONENT_FN(fn_ptr, end) fn_ptr++
#endif
-#ifdef RT_USING_RTGUI
- rtgui_system_server_init();
-#endif
+/**
+ * RT-Thread Components Initialization for board
+ */
+void rt_components_board_init(void)
+{
+ const init_fn_t* fn_ptr;
-#ifdef RT_USING_USB_HOST
- rt_usb_host_init();
-#endif
+ for (fn_ptr = &__rt_init_rti_start; fn_ptr < &__rt_init_rti_board_end; )
+ {
+ (*fn_ptr)();
+ NEXT_COMPONENT_FN(fn_ptr, __rt_init_rti_board_end);
+ }
+}
+
+/**
+ * RT-Thread Components Initialization
+ */
+void rt_components_init(void)
+{
+ const init_fn_t* fn_ptr;
- return;
+ for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; )
+ {
+ (*fn_ptr)();
+ NEXT_COMPONENT_FN(fn_ptr, __rt_init_rti_end);
+ }
}
+