startup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2012, 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_hw_console_init(void);
  19. extern void rt_hw_board_init(void);
  20. extern int rt_application_init(void);
  21. //extern void rt_hw_interrupt_init(void);
  22. //extern void rt_system_timer_init(void);
  23. //extern void rt_system_scheduler_init(void);
  24. //extern void rt_thread_idle_init(void);
  25. #ifdef RT_USING_FINSH
  26. extern int finsh_system_init(void);
  27. extern void finsh_set_device(const char *device);
  28. #endif
  29. extern unsigned char __bss_start[];
  30. extern unsigned char __bss_end[];
  31. /**
  32. * @addtogroup QEMU
  33. */
  34. /*@{*/
  35. /* clear .bss */
  36. void rt_hw_clear_bss(void)
  37. {
  38. unsigned char *dst;
  39. dst = __bss_start;
  40. while (dst < __bss_end)
  41. *dst++ = 0;
  42. }
  43. /**
  44. * This function will startup RT-Thread RTOS
  45. */
  46. void rtthread_startup(void)
  47. {
  48. /* clear .bss */
  49. rt_hw_clear_bss();
  50. /* init hardware interrupt */
  51. rt_hw_interrupt_init();
  52. /* init the console */
  53. rt_hw_console_init();
  54. rt_console_set_device("console");
  55. /* init board */
  56. rt_hw_board_init();
  57. rt_show_version();
  58. /* init tick */
  59. rt_system_tick_init();
  60. /* init kernel object */
  61. rt_system_object_init();
  62. /* init timer system */
  63. rt_system_timer_init();
  64. /* init memory system */
  65. #ifdef RT_USING_HEAP
  66. /* RAM 16M */
  67. rt_system_heap_init((void *)&__bss_end, (void *)(1024UL*1024*8));
  68. #endif
  69. /* init scheduler system */
  70. rt_system_scheduler_init();
  71. /* init application */
  72. rt_application_init();
  73. #ifdef RT_USING_FINSH
  74. /* init finsh */
  75. finsh_system_init();
  76. finsh_set_device("console");
  77. #endif
  78. /* init idle thread */
  79. rt_thread_idle_init();
  80. /* start scheduler */
  81. rt_system_scheduler_start();
  82. /* never reach here */
  83. return ;
  84. }
  85. /*@}*/