startup.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development 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 <dm36x.h>
  27. #ifdef RT_USING_FINSH
  28. #include <finsh.h>
  29. #endif
  30. extern void rt_hw_interrupt_init(void);
  31. extern void rt_hw_board_init(void);
  32. extern void rt_serial_init(void);
  33. extern void rt_system_timer_init(void);
  34. extern void rt_system_scheduler_init(void);
  35. extern void rt_thread_idle_init(void);
  36. extern void rt_hw_cpu_icache_enable(void);
  37. extern void rt_show_version(void);
  38. extern void rt_system_heap_init(void*, void*);
  39. extern void rt_hw_finsh_init(void);
  40. extern void rt_application_init(void);
  41. /**
  42. * @addtogroup dm365
  43. */
  44. /*@{*/
  45. #if defined(__CC_ARM)
  46. extern int Image$$ER_ZI$$ZI$$Base;
  47. extern int Image$$ER_ZI$$ZI$$Length;
  48. extern int Image$$ER_ZI$$ZI$$Limit;
  49. #elif (defined (__GNUC__))
  50. rt_uint8_t _irq_stack_start[1024];
  51. rt_uint8_t _fiq_stack_start[1024];
  52. rt_uint8_t _undefined_stack_start[512];
  53. rt_uint8_t _abort_stack_start[512];
  54. rt_uint8_t _svc_stack_start[1024] SECTION(".nobss");
  55. extern unsigned char __bss_start;
  56. extern unsigned char __bss_end;
  57. #endif
  58. #ifdef RT_USING_FINSH
  59. extern void finsh_system_init(void);
  60. #endif
  61. /**
  62. * This function will startup RT-Thread RTOS.
  63. */
  64. void rtthread_startup(void)
  65. {
  66. /* enable cpu cache */
  67. //rt_hw_cpu_icache_enable();
  68. //rt_hw_cpu_dcache_enable();
  69. /* initialize hardware interrupt */
  70. rt_hw_interrupt_init();
  71. /* initialize board */
  72. rt_hw_board_init();
  73. /* show version */
  74. rt_show_version();
  75. /* initialize tick */
  76. rt_system_tick_init();
  77. /* initialize kernel object */
  78. rt_system_object_init();
  79. /* initialize timer system */
  80. rt_system_timer_init();
  81. /* initialize heap memory system */
  82. #ifdef __CC_ARM
  83. rt_system_heap_init((void*)&Image$$ER_ZI$$ZI$$Limit, (void*)0x88000000);
  84. #else
  85. rt_system_heap_init((void*)&__bss_end, (void*)0x88000000);
  86. #endif
  87. #ifdef RT_USING_MODULE
  88. /* initialize module system*/
  89. rt_system_module_init();
  90. #endif
  91. /* initialize scheduler system */
  92. rt_system_scheduler_init();
  93. /* initialize application */
  94. rt_application_init();
  95. #ifdef RT_USING_FINSH
  96. /* initialize finsh */
  97. finsh_system_init();
  98. #ifdef RT_USING_DEVICE
  99. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  100. #endif
  101. #endif
  102. /* initialize system timer thread */
  103. rt_system_timer_thread_init();
  104. /* initialize idle thread */
  105. rt_thread_idle_init();
  106. /* start scheduler */
  107. rt_system_scheduler_start();
  108. /* never reach here */
  109. return ;
  110. }
  111. int main(void)
  112. {
  113. rt_uint32_t RT_UNUSED level;
  114. /* disable interrupt first */
  115. level = rt_hw_interrupt_disable();
  116. /* startup RT-Thread RTOS */
  117. rtthread_startup();
  118. return 0;
  119. }
  120. /*@}*/