startup.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #include "mb9bf506r.h"
  18. #ifdef RT_USING_FINSH
  19. #include <finsh.h>
  20. #endif
  21. /**
  22. * @addtogroup FM3
  23. */
  24. extern struct serial_device uart0;
  25. extern struct rt_device uart0_device;
  26. extern struct serial_device uart2;
  27. extern struct rt_device uart2_device;
  28. /*@{*/
  29. extern int rt_application_init(void);
  30. #ifdef RT_USING_FINSH
  31. extern void finsh_system_init(void);
  32. #endif
  33. #ifdef __CC_ARM
  34. extern int Image$$RW_IRAM1$$ZI$$Limit;
  35. #elif __ICCARM__
  36. #pragma section="HEAP"
  37. #else
  38. extern int __bss_end;
  39. #endif
  40. /**
  41. * This function will startup RT-Thread RTOS.
  42. */
  43. void rtthread_startup(void)
  44. {
  45. /* init board */
  46. rt_hw_board_init();
  47. /* show version */
  48. rt_show_version();
  49. /* init tick */
  50. rt_system_tick_init();
  51. /* init timer system */
  52. rt_system_timer_init();
  53. #ifdef RT_USING_HEAP
  54. #ifdef __CC_ARM
  55. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  56. #elif __ICCARM__
  57. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  58. #else
  59. /* init memory system */
  60. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  61. #endif
  62. #endif
  63. /* init scheduler system */
  64. rt_system_scheduler_init();
  65. #ifdef RT_USING_DFS
  66. #ifdef RT_USING_DFS_UFFS
  67. rt_hw_nand_init();
  68. #endif
  69. #endif
  70. /* init application */
  71. rt_application_init();
  72. #ifdef RT_USING_FINSH
  73. /* init finsh */
  74. finsh_system_init();
  75. #ifdef RT_USING_DEVICE
  76. finsh_set_device("uart2");
  77. #endif
  78. #endif
  79. /* init timer thread */
  80. rt_system_timer_thread_init();
  81. /* init idle thread */
  82. rt_thread_idle_init();
  83. /* start scheduler */
  84. rt_system_scheduler_start();
  85. /* never reach here */
  86. return ;
  87. }
  88. int main(void)
  89. {
  90. /* disable interrupt first */
  91. rt_hw_interrupt_disable();
  92. /* init system setting */
  93. SystemInit();
  94. /* startup RT-Thread RTOS */
  95. rtthread_startup();
  96. return 0;
  97. }
  98. /*@}*/