1
0

startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 timer system */
  43. rt_system_timer_init();
  44. #ifdef RT_USING_HEAP
  45. #ifdef __CC_ARM
  46. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000);
  47. #elif __ICCARM__
  48. rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000);
  49. #else
  50. rt_system_heap_init((void*)&__bss_end, (void*)(&__bss_end+0x4000));
  51. #endif
  52. #endif
  53. /* init scheduler system */
  54. rt_system_scheduler_init();
  55. #ifdef RT_USING_HOOK /* if the hook is used */
  56. /* set idle thread hook */
  57. rt_thread_idle_sethook(rt_hw_led_flash);
  58. #endif
  59. #ifdef RT_USING_DEVICE
  60. /* init hardware serial device */
  61. rt_hw_serial_init();
  62. #endif
  63. /* init application */
  64. rt_application_init();
  65. #ifdef RT_USING_FINSH
  66. /* init finsh */
  67. finsh_system_init();
  68. #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
  69. finsh_set_device("uart1");
  70. #endif
  71. #endif
  72. /* init idle thread */
  73. rt_thread_idle_init();
  74. /* start scheduler */
  75. rt_system_scheduler_start();
  76. /* never reach here */
  77. return ;
  78. }
  79. int main (void)
  80. {
  81. /* invoke rtthread_startup */
  82. rtthread_startup();
  83. return 0;
  84. }
  85. /*@}*/