startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #include <LPC24xx.h>
  18. /**
  19. * @addtogroup LPC2478
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  23. #ifdef __CC_ARM
  24. extern int Image$$RW_IRAM1$$ZI$$Limit;
  25. #else
  26. extern int __bss_end;
  27. #endif
  28. /**
  29. * This function will startup RT-Thread RTOS.
  30. */
  31. void rtthread_startup(void)
  32. {
  33. /* init hardware interrupt */
  34. rt_hw_interrupt_init();
  35. /* init board */
  36. rt_hw_board_init();
  37. /* init tick */
  38. rt_system_tick_init();
  39. /* init kernel object */
  40. rt_system_object_init();
  41. rt_show_version();
  42. /* init timer system */
  43. rt_system_timer_init();
  44. /* init memory system */
  45. #ifdef RT_USING_HEAP
  46. #ifdef __CC_ARM
  47. rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)0x40010000);
  48. #else
  49. rt_system_heap_init((void *)&__bss_end, (void *)0x40010000);
  50. #endif
  51. #endif
  52. /* init scheduler system */
  53. rt_system_scheduler_init();
  54. /* init application */
  55. rt_application_init();
  56. /* init soft timer thread */
  57. rt_system_timer_thread_init();
  58. /* init idle thread */
  59. rt_thread_idle_init();
  60. /* start scheduler */
  61. rt_system_scheduler_start();
  62. /* never reach here */
  63. return ;
  64. }
  65. #ifdef __CC_ARM
  66. int main(void)
  67. {
  68. /* disable interrupt first */
  69. rt_hw_interrupt_disable();
  70. /* invoke rtthread_startup */
  71. rtthread_startup();
  72. return 0;
  73. }
  74. #endif
  75. /*@}*/