startup.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * 2011-02-14 aozima first implementation for Nios II.
  9. * 2011-03-04 aozima add HEAP and finsh support .
  10. */
  11. #include <rtthread.h>
  12. #include "system.h"
  13. #include "board.h"
  14. /**
  15. * @addtogroup NIOS_II
  16. */
  17. /*@{*/
  18. extern int rt_application_init(void);
  19. #ifdef RT_USING_FINSH
  20. extern int finsh_system_init(void);
  21. extern void finsh_set_device(const char* device);
  22. #endif
  23. #ifdef RT_USING_HEAP
  24. extern int _alt_partition_sdram_load_addr;
  25. #endif
  26. /**
  27. * This function will startup RT-Thread RTOS.
  28. */
  29. void rtthread_startup(void)
  30. {
  31. /* init board */
  32. rt_hw_board_init();
  33. /* show version */
  34. rt_show_version();
  35. /* init timer system */
  36. rt_system_timer_init();
  37. #ifdef RT_USING_HEAP
  38. rt_system_heap_init( &_alt_partition_sdram_load_addr, (void*)(SDRAM_BASE + SDRAM_SPAN) );
  39. #endif
  40. /* init scheduler system */
  41. rt_system_scheduler_init();
  42. /* init application */
  43. rt_application_init();
  44. /* init timer thread */
  45. rt_system_timer_thread_init();
  46. #ifdef RT_USING_FINSH
  47. /* init finsh */
  48. finsh_system_init();
  49. finsh_set_device("uart");
  50. #endif
  51. /* init idle thread */
  52. rt_thread_idle_init();
  53. /* start scheduler */
  54. rt_system_scheduler_start();
  55. /* never reach here */
  56. return ;
  57. }
  58. int main(void)
  59. {
  60. /* disable interrupt first */
  61. rt_hw_interrupt_disable();
  62. /* startup RT-Thread RTOS */
  63. rtthread_startup();
  64. return 0;
  65. }
  66. /*@}*/