startup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. * 2006-08-31 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include <AT91SAM7S.h>
  17. #include "board.h"
  18. #ifdef RT_USING_FINSH
  19. #include <finsh.h>
  20. extern void finsh_system_init(void);
  21. #endif
  22. /**
  23. * @addtogroup sam7s
  24. */
  25. /*@{*/
  26. #ifdef __CC_ARM
  27. extern int Image$$RW_IRAM1$$ZI$$Limit;
  28. #endif
  29. #ifdef __GNUC__
  30. extern unsigned char __bss_start;
  31. extern unsigned char __bss_end;
  32. #endif
  33. extern void rt_hw_interrupt_init(void);
  34. extern int rt_application_init(void);
  35. #ifdef RT_USING_DEVICE
  36. extern rt_err_t rt_hw_serial_init(void);
  37. #endif
  38. /**
  39. * This function will startup RT-Thread RTOS.
  40. */
  41. void rtthread_startup(void)
  42. {
  43. /* init hardware interrupt */
  44. rt_hw_interrupt_init();
  45. /* init board */
  46. rt_hw_board_init();
  47. rt_show_version();
  48. /* init tick */
  49. rt_system_tick_init();
  50. /* init kernel object */
  51. rt_system_object_init();
  52. /* init timer system */
  53. rt_system_timer_init();
  54. #ifdef RT_USING_HEAP
  55. #ifdef __CC_ARM
  56. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x204000);
  57. #elif __ICCARM__
  58. rt_system_heap_init(__segment_end("HEAP"), (void*)0x204000);
  59. #else
  60. rt_system_heap_init((void*)&__bss_end, (void*)0x204000);
  61. #endif
  62. #endif
  63. /* init scheduler system */
  64. rt_system_scheduler_init();
  65. #ifdef RT_USING_HOOK /* if the hook is used */
  66. /* set idle thread hook */
  67. rt_thread_idle_sethook(rt_hw_led_flash);
  68. #endif
  69. #ifdef RT_USING_DEVICE
  70. /* init hardware serial device */
  71. rt_hw_serial_init();
  72. /* init all device */
  73. rt_device_init_all();
  74. #endif
  75. /* init application */
  76. rt_application_init();
  77. #ifdef RT_USING_FINSH
  78. /* init finsh */
  79. finsh_system_init();
  80. finsh_set_device("uart1");
  81. #endif
  82. /* init idle thread */
  83. rt_thread_idle_init();
  84. /* start scheduler */
  85. rt_system_scheduler_start();
  86. /* never reach here */
  87. return ;
  88. }
  89. int main (void)
  90. {
  91. /* invoke rtthread_startup */
  92. rtthread_startup();
  93. return 0;
  94. }
  95. /*@}*/