startup.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2011, RT-Thread Development 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. * 2011-02-24 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. /**
  18. * @addtogroup FM3
  19. */
  20. /*@{*/
  21. extern int rt_application_init(void);
  22. #ifdef __CC_ARM
  23. extern int Image$$RW_IRAM1$$ZI$$Limit;
  24. #elif __ICCARM__
  25. #pragma section="HEAP"
  26. #else
  27. extern int __bss_end;
  28. #endif
  29. /**
  30. * This function will startup RT-Thread RTOS.
  31. */
  32. void rtthread_startup(void)
  33. {
  34. /* init board */
  35. rt_hw_board_init();
  36. /* show version */
  37. rt_show_version();
  38. /* init tick */
  39. rt_system_tick_init();
  40. /* init kernel object */
  41. rt_system_object_init();
  42. /* init timer system */
  43. rt_system_timer_init();
  44. #ifdef RT_USING_HEAP
  45. #ifdef __CC_ARM
  46. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x10008000);
  47. #elif __ICCARM__
  48. rt_system_heap_init(__segment_end("HEAP"), (void*)0x10008000);
  49. #else
  50. /* init memory system */
  51. rt_system_heap_init((void*)&__bss_end, (void*)0x10008000);
  52. #endif
  53. #endif
  54. /* init scheduler system */
  55. rt_system_scheduler_init();
  56. #ifdef RT_USING_DEVICE
  57. /* init all device */
  58. rt_device_init_all();
  59. #endif
  60. /* init application */
  61. rt_application_init();
  62. /* init timer thread */
  63. rt_system_timer_thread_init();
  64. /* init idle thread */
  65. rt_thread_idle_init();
  66. /* start scheduler */
  67. rt_system_scheduler_start();
  68. /* never reach here */
  69. return ;
  70. }
  71. int main(void)
  72. {
  73. rt_uint32_t UNUSED level;
  74. /* disable interrupt first */
  75. level = rt_hw_interrupt_disable();
  76. /* startup RT-Thread RTOS */
  77. rtthread_startup();
  78. return 0;
  79. }
  80. /*@}*/