startup.c 2.1 KB

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