startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, 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://www.fayfayspace.org/license/LICENSE.
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-09-15 QiuYi the first version
  13. * 2006-10-10 Bernard update to 0.2.2 version
  14. */
  15. #include <rtthread.h>
  16. #include <rthw.h>
  17. #include "board.h"
  18. extern void rt_console_init(void);
  19. extern void rt_hw_interrupt_init(void);
  20. extern void rt_hw_board_init(void);
  21. extern void rt_system_timer_init(void);
  22. extern void rt_system_scheduler_init(void);
  23. extern void rt_thread_idle_init(void);
  24. extern unsigned char __bss_start[];
  25. extern unsigned char __bss_end[];
  26. /**
  27. * @addtogroup QEMU
  28. */
  29. /*@{*/
  30. /* clear .bss */
  31. void rt_hw_clear_bss()
  32. {
  33. unsigned char *dst;
  34. dst = __bss_start;
  35. while(dst < __bss_end) *dst++ = 0;
  36. }
  37. extern void finsh_system_init(void);
  38. extern int rt_application_init(void);
  39. /**
  40. * This function will startup RT-Thread RTOS
  41. */
  42. void rtthread_startup()
  43. {
  44. /* clear .bss */
  45. rt_hw_clear_bss();
  46. /* init hardware interrupt */
  47. rt_hw_interrupt_init();
  48. /* init the console */
  49. rt_console_init();
  50. /* init board */
  51. rt_hw_board_init();
  52. rt_show_version();
  53. /* init tick */
  54. rt_system_tick_init();
  55. /* init kernel object */
  56. rt_system_object_init();
  57. /* init timer system */
  58. rt_system_timer_init();
  59. /* init memory system */
  60. #ifdef RT_USING_HEAP
  61. //rt_system_heap_init();
  62. #endif
  63. /* init scheduler system */
  64. rt_system_scheduler_init();
  65. /* init application */
  66. rt_application_init();
  67. /* init the finsh input */
  68. rt_hw_finsh_init();
  69. /* init finsh */
  70. finsh_system_init();
  71. #ifdef RT_USING_HOOK
  72. /* set idle thread hook */
  73. rt_thread_idle_sethook(RT_NULL);
  74. #endif
  75. /* init idle thread */
  76. rt_thread_idle_init();
  77. /* start scheduler */
  78. rt_system_scheduler_start();
  79. /* never reach here */
  80. return ;
  81. }
  82. /*@}*/