startup.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2011, RT-Thread Development 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. * 2011-02-14 aozima first implementation for Nios II.
  13. * 2011-03-04 aozima add HEAP and finsh support .
  14. */
  15. #include <rtthread.h>
  16. #include "system.h"
  17. #include "board.h"
  18. /**
  19. * @addtogroup NIOS_II
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  23. #ifdef RT_USING_FINSH
  24. extern void finsh_system_init(void);
  25. extern void finsh_set_device(const char* device);
  26. #endif
  27. #ifdef RT_USING_HEAP
  28. extern int _alt_partition_sdram_load_addr;
  29. #endif
  30. /**
  31. * This function will startup RT-Thread RTOS.
  32. */
  33. void rtthread_startup(void)
  34. {
  35. /* init board */
  36. rt_hw_board_init();
  37. /* show version */
  38. rt_show_version();
  39. /* init tick */
  40. rt_system_tick_init();
  41. /* init kernel object */
  42. rt_system_object_init();
  43. /* init timer system */
  44. rt_system_timer_init();
  45. #ifdef RT_USING_HEAP
  46. rt_system_heap_init( &_alt_partition_sdram_load_addr, (void*)(SDRAM_BASE + SDRAM_SPAN) );
  47. #endif
  48. /* init scheduler system */
  49. rt_system_scheduler_init();
  50. /* init application */
  51. rt_application_init();
  52. /* init timer thread */
  53. rt_system_timer_thread_init();
  54. #ifdef RT_USING_FINSH
  55. /* init finsh */
  56. finsh_system_init();
  57. finsh_set_device("uart");
  58. #endif
  59. /* init idle thread */
  60. rt_thread_idle_init();
  61. /* start scheduler */
  62. rt_system_scheduler_start();
  63. /* never reach here */
  64. return ;
  65. }
  66. int main(void)
  67. {
  68. rt_uint32_t UNUSED level;
  69. /* disable interrupt first */
  70. level = rt_hw_interrupt_disable();
  71. /* startup RT-Thread RTOS */
  72. rtthread_startup();
  73. return 0;
  74. }
  75. /*@}*/