startup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009, 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. * 2009-01-05 Bernard first implementation
  13. * 2010-04-09 fify for M16C
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "iom16c62p.h"
  18. #include "board.h"
  19. #include "bsp.h"
  20. extern void rt_hw_interrupt_init(void);
  21. extern int rt_application_init(void);
  22. #ifdef RT_USING_FINSH
  23. extern void finsh_system_init(void);
  24. extern void finsh_set_device(const char* device);
  25. #endif
  26. #ifdef RT_USING_HEAP
  27. #ifdef __ICCM16C__
  28. #pragma section="DATA16_HEAP"
  29. #endif
  30. #endif
  31. /**
  32. * This function will startup RT-Thread RTOS.
  33. */
  34. void rtthread_startup(void)
  35. {
  36. /* init hardware interrupt */
  37. rt_hw_interrupt_init();
  38. /* init board */
  39. rt_hw_board_init();
  40. /* show version */
  41. rt_show_version();
  42. /* init tick */
  43. rt_system_tick_init();
  44. /* init kernel object */
  45. rt_system_object_init();
  46. /* init timer system */
  47. rt_system_timer_init();
  48. #ifdef RT_USING_HEAP
  49. #ifdef __ICCM16C__
  50. rt_system_heap_init(__segment_begin("DATA16_HEAP"), __segment_end("DATA16_HEAP"));
  51. #endif
  52. #endif
  53. /* init scheduler system */
  54. rt_system_scheduler_init();
  55. #ifdef RT_USING_DEVICE
  56. /* init all device */
  57. rt_device_init_all();
  58. #endif
  59. /* init application */
  60. rt_application_init();
  61. #ifdef RT_USING_FINSH
  62. /* init finsh */
  63. finsh_system_init();
  64. finsh_set_device("uart0");
  65. #endif
  66. /* init timer thread */
  67. rt_system_timer_thread_init();
  68. /* init idle thread */
  69. rt_thread_idle_init();
  70. /* start scheduler */
  71. rt_system_scheduler_start();
  72. /* never reach here */
  73. return ;
  74. }
  75. int main(void)
  76. {
  77. /* disable interrupt first */
  78. rt_hw_interrupt_disable();
  79. /* init system setting */
  80. system_init();
  81. /* startup RT-Thread RTOS */
  82. rtthread_startup();
  83. return 0;
  84. }