application.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard the first version
  13. */
  14. #include <rtthread.h>
  15. #include <stdio.h>
  16. #include <board.h>
  17. #include <components.h>
  18. void rt_init_thread_entry(void *parameter)
  19. {
  20. #ifdef RT_USING_LWIP
  21. #ifdef RT_USING_TAPNETIF
  22. tap_netif_hw_init();
  23. #else
  24. pcap_netif_hw_init();
  25. #endif
  26. #endif
  27. rt_platform_init();
  28. /* initialization RT-Thread Components */
  29. rt_components_init();
  30. #ifdef RT_USING_RTGUI
  31. /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be
  32. * called after rt_components_init. */
  33. rt_hw_sdl_start();
  34. #endif /* RT_USING_RTGUI */
  35. /* File system Initialization */
  36. #ifdef RT_USING_DFS
  37. {
  38. #ifdef RT_USING_DFS_WINSHAREDIR
  39. {
  40. extern rt_err_t rt_win_sharedir_init(const char *name);
  41. extern int dfs_win32_init(void);
  42. rt_win_sharedir_init("wdd");
  43. dfs_win32_init();
  44. if (dfs_mount("wdd", "/", "wdir", 0, 0) == 0)
  45. rt_kprintf("win32 share directory initialized!\n");
  46. else
  47. rt_kprintf("win32 share directory initialized failed!\n");
  48. }
  49. #endif
  50. #ifdef RT_USING_DFS_ELMFAT
  51. /* mount sd card fatfs as root directory */
  52. #ifdef _WIN32
  53. if (dfs_mount("sd0", "/disk/sd", "elm", 0, 0) == 0)
  54. #else
  55. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  56. #endif
  57. rt_kprintf("fatfs initialized!\n");
  58. else
  59. rt_kprintf("fatfs initialization failed!\n");
  60. #endif
  61. #ifdef RT_USING_DFS_UFFS
  62. /* mount uffs as the nand flash file system */
  63. if (dfs_mount("nand0", "/disk/nand", "uffs", 0, 0) == 0)
  64. rt_kprintf("uffs initialized!\n");
  65. else
  66. rt_kprintf("uffs initialization failed!\n");
  67. #endif
  68. #ifdef RT_USING_DFS_JFFS2
  69. /* mount jffs2 as the nor flash file system */
  70. if (dfs_mount("nor", "/disk/nor", "jffs2", 0, 0) == 0)
  71. rt_kprintf("jffs2 initialized!\n");
  72. else
  73. rt_kprintf("jffs2 initialization failed!\n");
  74. #endif
  75. }
  76. #endif
  77. }
  78. int rt_application_init()
  79. {
  80. rt_thread_t tid;
  81. tid = rt_thread_create("init",
  82. rt_init_thread_entry, RT_NULL,
  83. 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
  84. if (tid != RT_NULL)
  85. rt_thread_startup(tid);
  86. return 0;
  87. }
  88. /*@}*/