startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2012, 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. /* initialize board */
  35. rt_hw_board_init();
  36. /* show version */
  37. rt_show_version();
  38. #ifdef RT_USING_HEAP
  39. #ifdef __CC_ARM
  40. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  41. #elif __ICCARM__
  42. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  43. #else
  44. /* init memory system */
  45. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  46. #endif
  47. #endif
  48. /* init scheduler system */
  49. rt_system_scheduler_init();
  50. #ifdef RT_USING_DEVICE
  51. #if defined(RT_USING_DFS) && defined(RT_USING_DFS_UFFS)
  52. rt_hw_nand_init();
  53. #endif
  54. #endif
  55. /* initialize application */
  56. rt_application_init();
  57. /* initialize timer */
  58. rt_system_timer_init();
  59. /* initialize timer thread */
  60. rt_system_timer_thread_init();
  61. /* initialize idle thread */
  62. rt_thread_idle_init();
  63. /* start scheduler */
  64. rt_system_scheduler_start();
  65. /* never reach here */
  66. return ;
  67. }
  68. int main(void)
  69. {
  70. /* disable interrupt first */
  71. rt_hw_interrupt_disable();
  72. /* startup RT-Thread RTOS */
  73. rtthread_startup();
  74. return 0;
  75. }
  76. /*@}*/