init.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * File : init.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2015-09-30 Bernard the first version
  23. */
  24. #include <rtthread.h>
  25. #include "init.h"
  26. #ifdef RT_USING_FINSH
  27. #include <finsh.h>
  28. #include <shell.h>
  29. #endif
  30. #ifdef RT_USING_LWIP
  31. #include <lwip/sys.h>
  32. #include <netif/ethernetif.h>
  33. extern void lwip_system_init(void);
  34. #endif
  35. #ifdef RT_USING_DFS
  36. #include <dfs.h>
  37. #include <dfs_fs.h>
  38. #ifdef RT_USING_DFS_ELMFAT
  39. #include <dfs_elm.h>
  40. #endif
  41. #if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
  42. #include <dfs_nfs.h>
  43. #endif
  44. #ifdef RT_USING_DFS_ROMFS
  45. #include <dfs_romfs.h>
  46. #endif
  47. #ifdef RT_USING_DFS_DEVFS
  48. #include <devfs.h>
  49. #endif
  50. #ifdef RT_USING_DFS_UFFS
  51. #include <dfs_uffs.h>
  52. #endif
  53. #ifdef RT_USING_DFS_JFFS2
  54. #include <dfs_jffs2.h>
  55. #endif
  56. #ifdef RT_USING_DFS_YAFFS2
  57. #include <dfs_yaffs2.h>
  58. #endif
  59. #ifdef RT_USING_DFS_ROMFS
  60. #include <dfs_romfs.h>
  61. #endif
  62. #endif
  63. #ifdef RT_USING_NEWLIB
  64. #include <libc.h>
  65. #endif
  66. #ifdef RT_USING_PTHREADS
  67. #include <pthread.h>
  68. #endif
  69. #ifdef RT_USING_MODULE
  70. #include <rtm.h>
  71. #endif
  72. #ifdef RT_USING_RTGUI
  73. #include <rtgui/rtgui_system.h>
  74. #endif
  75. /* components initialization for simulator */
  76. void components_init(void)
  77. {
  78. platform_init();
  79. #ifdef RT_USING_MODULE
  80. rt_system_module_init();
  81. #endif
  82. #ifdef RT_USING_FINSH
  83. /* initialize finsh */
  84. finsh_system_init();
  85. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  86. #endif
  87. #ifdef RT_USING_LWIP
  88. /* initialize lwip stack */
  89. /* register ethernetif device */
  90. eth_system_device_init();
  91. /* initialize lwip system */
  92. lwip_system_init();
  93. rt_kprintf("TCP/IP initialized!\n");
  94. #endif
  95. #ifdef RT_USING_DFS
  96. /* initialize the device file system */
  97. dfs_init();
  98. #ifdef RT_USING_DFS_ELMFAT
  99. /* initialize the elm chan FatFS file system*/
  100. elm_init();
  101. #endif
  102. #if defined(RT_USING_DFS_NFS) && defined(RT_USING_LWIP)
  103. /* initialize NFSv3 client file system */
  104. nfs_init();
  105. #endif
  106. #ifdef RT_USING_DFS_YAFFS2
  107. dfs_yaffs2_init();
  108. #endif
  109. #ifdef RT_USING_DFS_UFFS
  110. dfs_uffs_init();
  111. #endif
  112. #ifdef RT_USING_DFS_JFFS2
  113. dfs_jffs2_init();
  114. #endif
  115. #ifdef RT_USING_DFS_ROMFS
  116. dfs_romfs_init();
  117. #endif
  118. #ifdef RT_USING_DFS_RAMFS
  119. dfs_ramfs_init();
  120. #endif
  121. #ifdef RT_USING_DFS_DEVFS
  122. devfs_init();
  123. #endif
  124. #endif /* end of RT_USING_DFS */
  125. #ifdef RT_USING_NEWLIB
  126. libc_system_init(RT_CONSOLE_DEVICE_NAME);
  127. #else
  128. /* the pthread system initialization will be initiallized in libc */
  129. #ifdef RT_USING_PTHREADS
  130. pthread_system_init();
  131. #endif
  132. #endif
  133. #ifdef RT_USING_RTGUI
  134. rtgui_system_server_init();
  135. #endif
  136. #ifdef RT_USING_USB_HOST
  137. rt_usb_host_init();
  138. #endif
  139. #ifdef RT_USING_RTGUI
  140. /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be
  141. * called after rt_components_init. */
  142. rt_hw_sdl_start();
  143. #endif /* RT_USING_RTGUI */
  144. }