startup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. * 2009-02-16 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #ifdef RT_USING_FINSH
  17. #include <finsh.h>
  18. #endif
  19. #include "board.h"
  20. #ifdef RT_USING_LWIP
  21. #include <netif/ethernetif.h>
  22. #include "dm9000.h"
  23. #endif
  24. #ifdef RT_USING_DFS
  25. #include "sd.h"
  26. #endif
  27. /**
  28. * @addtogroup lpc2148
  29. */
  30. /*@{*/
  31. #ifdef RT_USING_FINSH
  32. extern void finsh_system_init(void);
  33. #endif
  34. extern int rt_application_init(void);
  35. extern void rt_show_version(void);
  36. #ifdef RT_USING_DEVICE
  37. extern rt_err_t rt_hw_serial_init(void);
  38. #endif
  39. #ifdef RT_USING_FINSH
  40. extern void finsh_system_init(void);
  41. #endif
  42. #ifdef __CC_ARM
  43. extern int Image$$RW_IRAM1$$ZI$$Limit;
  44. #else
  45. extern int __bss_end;
  46. #endif
  47. /**
  48. * This function will startup RT-Thread RTOS.
  49. */
  50. void rtthread_startup(void)
  51. {
  52. /* init hardware interrupt */
  53. rt_hw_interrupt_init();
  54. /* init board */
  55. rt_hw_board_init();
  56. /* init tick */
  57. rt_system_tick_init();
  58. /* init kernel object */
  59. rt_system_object_init();
  60. rt_show_version();
  61. /* init timer system */
  62. rt_system_timer_init();
  63. #ifdef RT_USING_HEAP
  64. #ifdef __CC_ARM
  65. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x40008000);
  66. #else
  67. /* init memory system */
  68. rt_system_heap_init((void*)&__bss_end, (void*)0x40008000);
  69. #endif
  70. #endif
  71. /* init scheduler system */
  72. rt_system_scheduler_init();
  73. #ifdef RT_USING_DEVICE
  74. #ifdef RT_USING_DFS
  75. /* init sd card */
  76. rt_hw_sdcard_init();
  77. #endif
  78. #ifdef RT_USING_LWIP
  79. eth_system_device_init();
  80. /* init ethernetif device */
  81. rt_hw_dm9000_init();
  82. #endif
  83. /* init hardware serial device */
  84. rt_hw_serial_init();
  85. /*init all registed devices*/
  86. rt_device_init_all();
  87. #endif
  88. /* init application */
  89. rt_application_init();
  90. #ifdef RT_USING_FINSH
  91. /* init finsh */
  92. finsh_system_init();
  93. finsh_set_device("uart1");
  94. #endif
  95. /* init idle thread */
  96. rt_thread_idle_init();
  97. /* start scheduler */
  98. rt_system_scheduler_start();
  99. /* never reach here */
  100. return ;
  101. }
  102. int main (void)
  103. {
  104. /* invoke rtthread_startup */
  105. rtthread_startup();
  106. return 0;
  107. }
  108. /*@}*/