1
0

startup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-08-31 Bernard first implementation
  13. * 2011-12-17 nl1031 for MicroBlaze
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "board.h"
  18. #ifdef RT_USING_FINSH
  19. #include <finsh.h>
  20. extern void finsh_system_init(void);
  21. #endif
  22. extern void rt_hw_led_flash(void);
  23. /*@{*/
  24. #ifdef __CC_ARM
  25. extern int Image$$RW_IRAM1$$ZI$$Limit;
  26. #endif
  27. #ifdef __GNUC__
  28. extern unsigned char __bss_start;
  29. extern unsigned char __bss_end;
  30. #endif
  31. extern void rt_hw_interrupt_init(void);
  32. extern int rt_application_init(void);
  33. #ifdef RT_USING_DEVICE
  34. extern rt_err_t rt_hw_serial_init(void);
  35. #endif
  36. /**
  37. * This function will startup RT-Thread RTOS.
  38. */
  39. void rtthread_startup(void)
  40. {
  41. /* init hardware interrupt */
  42. rt_hw_interrupt_init();
  43. /* init board */
  44. rt_hw_board_init();
  45. rt_show_version();
  46. /* init tick */
  47. rt_system_tick_init();
  48. /* init kernel object */
  49. rt_system_object_init();
  50. /* init timer system */
  51. rt_system_timer_init();
  52. #ifdef RT_USING_HEAP
  53. #ifdef __CC_ARM
  54. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000);
  55. #elif __ICCARM__
  56. rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000);
  57. #else
  58. rt_system_heap_init((void*)&__bss_end, (void*)(&__bss_end+0x4000));
  59. #endif
  60. #endif
  61. /* init scheduler system */
  62. rt_system_scheduler_init();
  63. #ifdef RT_USING_HOOK /* if the hook is used */
  64. /* set idle thread hook */
  65. rt_thread_idle_sethook(rt_hw_led_flash);
  66. #endif
  67. #ifdef RT_USING_DEVICE
  68. /* init hardware serial device */
  69. rt_hw_serial_init();
  70. #endif
  71. /* init application */
  72. rt_application_init();
  73. #ifdef RT_USING_FINSH
  74. /* init finsh */
  75. finsh_system_init();
  76. finsh_set_device("uart1");
  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. int main (void)
  86. {
  87. /* invoke rtthread_startup */
  88. rtthread_startup();
  89. return 0;
  90. }
  91. /*@}*/