startup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_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 void 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()
  37. {
  38. unsigned char *dst;
  39. dst = __bss_start;
  40. while(dst < __bss_end) *dst++ = 0;
  41. }
  42. /**
  43. * This function will startup RT-Thread RTOS
  44. */
  45. void rtthread_startup()
  46. {
  47. /* clear .bss */
  48. rt_hw_clear_bss();
  49. /* init hardware interrupt */
  50. rt_hw_interrupt_init();
  51. /* init the console */
  52. rt_hw_console_init();
  53. rt_console_set_device("console");
  54. /* init board */
  55. rt_hw_board_init();
  56. rt_show_version();
  57. /* init tick */
  58. rt_system_tick_init();
  59. /* init kernel object */
  60. rt_system_object_init();
  61. /* init timer system */
  62. rt_system_timer_init();
  63. /* init memory system */
  64. #ifdef RT_USING_HEAP
  65. rt_system_heap_init((void*)&__bss_end, (void*)(1024UL*1024*8)); /* RAM 16M */
  66. #endif
  67. /* init scheduler system */
  68. rt_system_scheduler_init();
  69. /* init application */
  70. rt_application_init();
  71. #ifdef RT_USING_FINSH
  72. /* init finsh */
  73. finsh_system_init();
  74. finsh_set_device("console");
  75. #endif
  76. /* init idle thread */
  77. rt_thread_idle_init();
  78. /* start scheduler */
  79. rt_system_scheduler_start();
  80. /* never reach here */
  81. return ;
  82. }
  83. /*@}*/