startup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2013, 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. * 2008-12-11 xuxinming first version
  13. * 2010-4-3 LiJin add init soft timer thread
  14. * 2013-05-24 Grissiom port to RM48x50
  15. */
  16. #include <rthw.h>
  17. #include <rtthread.h>
  18. #ifdef RT_USING_FINSH
  19. #include <finsh.h>
  20. extern void finsh_system_init(void);
  21. #endif
  22. #include <board.h>
  23. /**
  24. * @addtogroup LPC2478
  25. */
  26. /*@{*/
  27. extern int rt_application_init(void);
  28. #ifdef RT_USING_DEVICE
  29. extern rt_err_t rt_hw_serial_init(void);
  30. #endif
  31. #ifdef __CC_ARM
  32. extern int Image$$RW_IRAM1$$ZI$$Limit;
  33. #elif defined(__GNUC__)
  34. extern int __bss_end;
  35. #elif defined(__TI_COMPILER_VERSION__)
  36. extern unsigned char * const system_data_end;
  37. #endif
  38. #define MEMEND 0x08040000
  39. /**
  40. * This function will startup RT-Thread RTOS.
  41. */
  42. void rtthread_startup(void)
  43. {
  44. /* init hardware interrupt */
  45. rt_hw_interrupt_init();
  46. /* init board */
  47. rt_hw_board_init();
  48. /* init tick */
  49. rt_system_tick_init();
  50. /* init kernel object */
  51. rt_system_object_init();
  52. rt_show_version();
  53. /* init timer system */
  54. rt_system_timer_init();
  55. /* init memory system */
  56. #ifdef RT_USING_HEAP
  57. #ifdef __CC_ARM
  58. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)MEMEND);
  59. #elif defined(__GNUC__)
  60. rt_system_heap_init((void*)&__bss_end, (void*)MEMEND);
  61. #elif defined(__TI_COMPILER_VERSION__)
  62. rt_system_heap_init((void*)&system_data_end, (void*)MEMEND);
  63. #else
  64. #error Unkown compiler
  65. #endif
  66. #endif
  67. /* init scheduler system */
  68. rt_system_scheduler_init();
  69. /* init application */
  70. rt_application_init();
  71. #ifdef RT_USING_FINSH
  72. /* init finsh */
  73. finsh_system_init();
  74. finsh_set_device("sci2");
  75. #endif
  76. /* init soft timer thread */
  77. rt_system_timer_thread_init();
  78. /* init idle thread */
  79. rt_thread_idle_init();
  80. /* start scheduler */
  81. rt_system_scheduler_start();
  82. /* never reach here */
  83. return ;
  84. }
  85. int main(void)
  86. {
  87. /* disable interrupt first */
  88. rt_hw_interrupt_disable();
  89. /* invoke rtthread_startup */
  90. rtthread_startup();
  91. return 0;
  92. }
  93. /*@}*/