startup.c 2.0 KB

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