startup.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. * 2015-04-21 ArdaFu Using init componment module
  24. * 2015-04-27 ArdaFu Port bsp from at91sam9260 to asm9260t
  25. */
  26. #include <rthw.h>
  27. #include <rtthread.h>
  28. #include "board.h"
  29. extern void rt_application_init(void);
  30. #if defined(__CC_ARM)
  31. extern int Image$$ER_ZI$$ZI$$Limit;
  32. #define HEAP_BEGIN (&Image$$ER_ZI$$ZI$$Limit)
  33. #elif(defined(__GNUC__))
  34. extern unsigned char __bss_end__;
  35. #define HEAP_BEGIN (&__bss_end__)
  36. #elif(defined(__ICCARM__))
  37. #pragma section = ".noinit"
  38. #define HEAP_BEGIN (__section_end(".noinit"))
  39. #endif
  40. #define HEAP_END (0x22000000)
  41. /**
  42. * This function will startup RT-Thread RTOS.
  43. */
  44. static void rtthread_startup(void)
  45. {
  46. /* initialize board */
  47. rt_hw_board_init();
  48. /* show version */
  49. rt_show_version();
  50. #ifdef RT_USING_HEAP
  51. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  52. #endif
  53. /* initialize scheduler system */
  54. rt_system_scheduler_init();
  55. /* initialize system timer*/
  56. rt_system_timer_init();
  57. /* initialize application */
  58. rt_application_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. }