components.c 3.3 KB
Newer Older
1 2 3
/*
 * File      : components.c
 * This file is part of RT-Thread RTOS
4
 * COPYRIGHT (C) 2012 - 2013, RT-Thread Development Team
5
 *
6 7 8 9 10 11 12 13 14 15 16 17 18
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 20 21 22 23
 *
 * Change Logs:
 * Date           Author       Notes
 * 2012-09-20     Bernard      Change the name to components.c
 *                             And all components related header files.
24
 * 2012-12-23     Bernard      fix the pthread initialization issue.
B
Bernard Xiong 已提交
25
 * 2013-06-23     Bernard      Add the init_call for components initialization.
26
 * 2013-07-05     Bernard      Remove initialization feature for MS VC++ compiler 
27
 */
28

29 30
#include "components.h"

B
Bernard Xiong 已提交
31
static int rti_start(void)
32
{
33
    return 0;
B
Bernard Xiong 已提交
34 35
}
INIT_EXPORT(rti_start, "0");
36

B
Bernard Xiong 已提交
37 38
static int rti_board_end(void)
{
39
    return 0;
B
Bernard Xiong 已提交
40 41
}
INIT_EXPORT(rti_board_end, "1.post");
42

B
Bernard Xiong 已提交
43 44
static int rti_end(void)
{
45
    return 0;
B
Bernard Xiong 已提交
46 47
}
INIT_EXPORT(rti_end,"7");
48

B
Bernard Xiong 已提交
49 50 51 52 53
/**
 * RT-Thread Components Initialization for board
 */
void rt_components_board_init(void)
{
54
#ifndef _MSC_VER
55
    const init_fn_t *fn_ptr;
56

57
    for (fn_ptr = &__rt_init_rti_start; fn_ptr < &__rt_init_rti_board_end; fn_ptr++)
58 59 60
    {
        (*fn_ptr)();
    }
61
#endif
B
Bernard Xiong 已提交
62 63 64 65 66 67 68
}

/**
 * RT-Thread Components Initialization
 */
void rt_components_init(void)
{
69
#ifndef _MSC_VER
70
    const init_fn_t *fn_ptr;
71

72
    for (fn_ptr = &__rt_init_rti_board_end; fn_ptr < &__rt_init_rti_end; fn_ptr ++)
73 74 75
    {
        (*fn_ptr)();
    }
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
#else
#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

#ifdef RT_USING_DFS_UFFS
	dfs_uffs_init();
#endif

#ifdef RT_USING_DFS_JFFS2
	dfs_jffs2_init();
#endif

#ifdef RT_USING_DFS_ROMFS
	dfs_romfs_init();
#endif

#ifdef RT_USING_DFS_DEVFS
	devfs_init();
#endif
#endif /* end of RT_USING_DFS */

#ifdef RT_USING_NEWLIB
	libc_system_init(RT_CONSOLE_DEVICE_NAME);
#else
	/* the pthread system initialization will be initiallized in libc */
#ifdef RT_USING_PTHREADS 
	pthread_system_init();
#endif
#endif
B
Bernard Xiong 已提交
140

141 142 143 144 145 146 147 148 149
#ifdef RT_USING_RTGUI
	rtgui_system_server_init();
#endif

#ifdef RT_USING_USB_HOST
	rt_usb_host_init();
#endif
#endif
}