startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. * 2008-12-11 xuxinming first version
  13. * 2010-4-3 LiJin add init soft timer thread
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #ifdef RT_USING_FINSH
  18. #include <finsh.h>
  19. extern void finsh_system_init(void);
  20. #endif
  21. #include <LPC24xx.h>
  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. #else
  34. extern int __bss_end;
  35. #endif
  36. /**
  37. * This function will startup RT-Thread RTOS.
  38. */
  39. void rtthread_startup(void)
  40. {
  41. /* init hardware interrupt */
  42. rt_hw_interrupt_init();
  43. /* init board */
  44. rt_hw_board_init();
  45. /* init tick */
  46. rt_system_tick_init();
  47. /* init kernel object */
  48. rt_system_object_init();
  49. rt_show_version();
  50. /* init timer system */
  51. rt_system_timer_init();
  52. /* init memory system */
  53. #ifdef RT_USING_HEAP
  54. #ifdef __CC_ARM
  55. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x40010000);
  56. #else
  57. rt_system_heap_init((void*)&__bss_end, (void*)0x40010000);
  58. #endif
  59. #endif
  60. /* init scheduler system */
  61. rt_system_scheduler_init();
  62. #ifdef RT_USING_DEVICE
  63. /* init hardware serial device */
  64. rt_hw_serial_init();
  65. /*init all registed devices*/
  66. rt_device_init_all();
  67. #endif
  68. /* init application */
  69. rt_application_init();
  70. #ifdef RT_USING_FINSH
  71. /* init finsh */
  72. finsh_system_init();
  73. finsh_set_device("uart1");
  74. #endif
  75. /* init soft timer thread */
  76. rt_system_timer_thread_init();
  77. /* init idle thread */
  78. rt_thread_idle_init();
  79. /* start scheduler */
  80. rt_system_scheduler_start();
  81. /* never reach here */
  82. return ;
  83. }
  84. #ifdef __CC_ARM
  85. int main(void)
  86. {
  87. /* invoke rtthread_startup */
  88. rtthread_startup();
  89. return 0;
  90. }
  91. #endif
  92. /*@}*/