startup.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. /*// RM48 does not have cache implemented
  45. *rt_hw_cpu_icache_enable();
  46. *rt_hw_cpu_dcache_enable();
  47. */
  48. /* init hardware interrupt */
  49. rt_hw_interrupt_init();
  50. /* init board */
  51. rt_hw_board_init();
  52. /* init tick */
  53. rt_system_tick_init();
  54. /* init kernel object */
  55. rt_system_object_init();
  56. rt_show_version();
  57. /* init timer system */
  58. rt_system_timer_init();
  59. /* init memory system */
  60. #ifdef RT_USING_HEAP
  61. #ifdef __CC_ARM
  62. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)MEMEND);
  63. #elif defined(__GNUC__)
  64. rt_system_heap_init((void*)&__bss_end, (void*)MEMEND);
  65. #elif defined(__TI_COMPILER_VERSION__)
  66. rt_system_heap_init((void*)&system_data_end, (void*)MEMEND);
  67. #else
  68. #error Unkown compiler
  69. #endif
  70. #endif
  71. /* init scheduler system */
  72. rt_system_scheduler_init();
  73. /* init application */
  74. rt_application_init();
  75. #ifdef RT_USING_FINSH
  76. /* init finsh */
  77. finsh_system_init();
  78. finsh_set_device("sci2");
  79. #endif
  80. /* init soft timer thread */
  81. rt_system_timer_thread_init();
  82. /* init idle thread */
  83. rt_thread_idle_init();
  84. /* start scheduler */
  85. rt_system_scheduler_start();
  86. /* never reach here */
  87. return ;
  88. }
  89. int main(void)
  90. {
  91. /* disable interrupt first */
  92. rt_hw_interrupt_disable();
  93. /* invoke rtthread_startup */
  94. rtthread_startup();
  95. return 0;
  96. }
  97. /*@}*/