startup.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2014, 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://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2014-08-03 aozima first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. /**
  18. * @addtogroup CME_M7
  19. */
  20. /*@{*/
  21. extern int rt_application_init(void);
  22. #ifdef __CC_ARM
  23. extern int Image$$RW_IRAM1$$ZI$$Limit;
  24. #define SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
  25. #elif __ICCARM__
  26. #pragma section="HEAP"
  27. #define SRAM_BEGIN (__segment_end("HEAP"))
  28. #else
  29. extern int __bss_end;
  30. #define SRAM_BEGIN (&__bss_end)
  31. #endif
  32. /**
  33. * This function will startup RT-Thread RTOS.
  34. */
  35. void rtthread_startup(void)
  36. {
  37. /* init board */
  38. rt_hw_board_init();
  39. /* show version */
  40. rt_show_version();
  41. /* init tick */
  42. rt_system_tick_init();
  43. /* init kernel object */
  44. rt_system_object_init();
  45. /* init timer system */
  46. rt_system_timer_init();
  47. rt_system_heap_init((void*)SRAM_BEGIN, (void*)SRAM_END);
  48. /* init scheduler system */
  49. rt_system_scheduler_init();
  50. /* init application */
  51. rt_application_init();
  52. /* init timer thread */
  53. rt_system_timer_thread_init();
  54. /* init idle thread */
  55. rt_thread_idle_init();
  56. /* start scheduler */
  57. rt_system_scheduler_start();
  58. /* never reach here */
  59. return ;
  60. }
  61. int main(void)
  62. {
  63. /* disable interrupt first */
  64. rt_hw_interrupt_disable();
  65. /* startup RT-Thread RTOS */
  66. rtthread_startup();
  67. return 0;
  68. }
  69. /*@}*/