startup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. * 2010-01-25 Bernard first version
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. #ifdef RT_USING_FINSH
  18. #include "finsh.h"
  19. extern void finsh_system_init(void);
  20. #endif
  21. /**
  22. * @addtogroup NUC100
  23. */
  24. /*@{*/
  25. #if defined(__CC_ARM)
  26. extern int Image$$RW_IRAM1$$ZI$$Limit;
  27. #elif defined(__GNUC__)
  28. extern unsigned char __bss_start;
  29. extern unsigned char __bss_end;
  30. #endif
  31. extern int rt_application_init(void);
  32. /**
  33. * This function will startup RT-Thread RTOS.
  34. */
  35. void rtthread_startup(void)
  36. {
  37. /* init kernel object */
  38. rt_system_object_init();
  39. /* init board */
  40. rt_hw_board_init();
  41. rt_show_version();
  42. /* init tick */
  43. rt_system_tick_init();
  44. /* init timer system */
  45. rt_system_timer_init();
  46. #ifdef RT_USING_HEAP
  47. #ifdef __CC_ARM
  48. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x20004000);
  49. #elif __ICCARM__
  50. rt_system_heap_init(__segment_end("HEAP"), (void*)0x20004000);
  51. #else
  52. rt_system_heap_init((void*)&__bss_end, (void*)0x20004000);
  53. #endif
  54. #endif
  55. /* init scheduler system */
  56. rt_system_scheduler_init();
  57. #ifdef RT_USING_HOOK /* if the hook is used */
  58. /* set idle thread hook */
  59. rt_thread_idle_sethook(rt_hw_led_flash);
  60. #endif
  61. #ifdef RT_USING_DEVICE
  62. /* init all device */
  63. rt_device_init_all();
  64. #endif
  65. /* init application */
  66. rt_application_init();
  67. #ifdef RT_USING_FINSH
  68. /* init finsh */
  69. finsh_system_init();
  70. finsh_set_device("uart1");
  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. rt_uint32_t UNUSED level;
  82. /* disable interrupt first */
  83. level = rt_hw_interrupt_disable();
  84. /* invoke rtthread_startup */
  85. rtthread_startup();
  86. return 0;
  87. }
  88. /*@}*/