startup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2011-01-13 weety first version
  23. */
  24. #include <rthw.h>
  25. #include <rtthread.h>
  26. #include <at91sam926x.h>
  27. #ifdef RT_USING_FINSH
  28. #include <finsh.h>
  29. #endif
  30. extern void rt_application_init(void);
  31. /**
  32. * @addtogroup at91sam9260
  33. */
  34. /*@{*/
  35. #if defined(__CC_ARM)
  36. extern int Image$$ER_ZI$$ZI$$Limit;
  37. #define HEAP_BEGIN (&Image$$ER_ZI$$ZI$$Limit)
  38. #elif (defined (__GNUC__))
  39. extern unsigned char __bss_end__;
  40. #define HEAP_BEGIN (&__bss_end__)
  41. #elif (defined (__ICCARM__))
  42. #pragma section=".noinit"
  43. #define HEAP_BEGIN (__section_end(".noinit"))
  44. #endif
  45. #define HEAP_END (0x24000000)
  46. /**
  47. * This function will startup RT-Thread RTOS.
  48. */
  49. static void rtthread_startup(void)
  50. {
  51. /* initialize board */
  52. rt_hw_board_init();
  53. /* show version */
  54. rt_show_version();
  55. #ifdef RT_USING_HEAP
  56. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  57. #endif
  58. /* initialize scheduler system */
  59. rt_system_scheduler_init();
  60. /* initialize system timer*/
  61. rt_system_timer_init();
  62. /* initialize application */
  63. rt_application_init();
  64. #ifdef RT_USING_FINSH
  65. /* initialize finsh */
  66. finsh_system_init();
  67. #ifdef RT_USING_DEVICE
  68. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  69. #endif
  70. #endif
  71. /* initialize timer thread */
  72. rt_system_timer_thread_init();
  73. /* initialize idle thread */
  74. rt_thread_idle_init();
  75. /* start scheduler */
  76. rt_system_scheduler_start();
  77. /* never reach here */
  78. return ;
  79. }
  80. int main(void)
  81. {
  82. /* disable interrupt first */
  83. rt_hw_interrupt_disable();
  84. /* startup RT-Thread RTOS */
  85. rtthread_startup();
  86. return 0;
  87. }
  88. /*@}*/