startup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop 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-02-16 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #ifdef RT_USING_FINSH
  17. #include <finsh.h>
  18. #endif
  19. #include "board.h"
  20. #ifdef RT_USING_LWIP
  21. #include <netif/ethernetif.h>
  22. #include "dm9000.h"
  23. #endif
  24. #ifdef RT_USING_DFS
  25. #include "sd.h"
  26. #endif
  27. /**
  28. * @addtogroup lpc2148
  29. */
  30. /*@{*/
  31. #ifdef RT_USING_FINSH
  32. extern void finsh_system_init(void);
  33. #endif
  34. extern int rt_application_init(void);
  35. extern void rt_show_version(void);
  36. #ifdef RT_USING_DEVICE
  37. extern rt_err_t rt_hw_serial_init(void);
  38. #endif
  39. #ifdef RT_USING_FINSH
  40. extern void finsh_system_init(void);
  41. #endif
  42. #ifdef __CC_ARM
  43. extern int Image$$RW_IRAM1$$ZI$$Limit;
  44. #else
  45. extern int __bss_end;
  46. #endif
  47. /**
  48. * This function will startup RT-Thread RTOS.
  49. */
  50. void rtthread_startup(void)
  51. {
  52. /* init hardware interrupt */
  53. rt_hw_interrupt_init();
  54. /* init board */
  55. rt_hw_board_init();
  56. /* init tick */
  57. rt_system_tick_init();
  58. /* init kernel object */
  59. rt_system_object_init();
  60. rt_show_version();
  61. /* init timer system */
  62. rt_system_timer_init();
  63. #ifdef RT_USING_HEAP
  64. #ifdef __CC_ARM
  65. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x40008000);
  66. #else
  67. /* init memory system */
  68. rt_system_heap_init((void*)&__bss_end, (void*)0x40008000);
  69. #endif
  70. #endif
  71. /* init scheduler system */
  72. rt_system_scheduler_init();
  73. #ifdef RT_USING_HOOK /* if the hook is used */
  74. /* set idle thread hook */
  75. rt_thread_idle_sethook(0);
  76. #endif
  77. #ifdef RT_USING_DEVICE
  78. #ifdef RT_USING_DFS
  79. /* init sd card */
  80. rt_hw_sdcard_init();
  81. #endif
  82. #ifdef RT_USING_LWIP
  83. eth_system_device_init();
  84. /* init ethernetif device */
  85. rt_hw_dm9000_init();
  86. #endif
  87. /* init hardware serial device */
  88. rt_hw_serial_init();
  89. /*init all registed devices*/
  90. rt_device_init_all();
  91. #endif
  92. /* init application */
  93. rt_application_init();
  94. #ifdef RT_USING_FINSH
  95. /* init finsh */
  96. finsh_system_init();
  97. finsh_set_device("uart1");
  98. #endif
  99. /* init idle thread */
  100. rt_thread_idle_init();
  101. /* start scheduler */
  102. rt_system_scheduler_start();
  103. /* never reach here */
  104. return ;
  105. }
  106. int main (void)
  107. {
  108. /* invoke rtthread_startup */
  109. rtthread_startup();
  110. return 0;
  111. }
  112. /*@}*/