startup.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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://openlab.rt-thread.com/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 "board.h"
  17. #ifdef RT_USING_LWIP
  18. #include <lwip/sys.h>
  19. #include <netif/ethernetif.h>
  20. #endif
  21. /**
  22. * @addtogroup LM3S
  23. */
  24. extern void rt_hw_serial_init(void);
  25. /*@{*/
  26. #ifdef RT_USING_FINSH
  27. extern int finsh_system_init(void);
  28. extern void finsh_set_device(const char *device);
  29. #endif
  30. extern int rt_application_init(void);
  31. extern void rt_hw_sdcard_init(void);
  32. extern int rt_hw_luminaryif_init(void);
  33. #ifdef __CC_ARM
  34. extern int Image$$RW_IRAM1$$ZI$$Limit;
  35. #elif __ICCARM__
  36. #pragma section="HEAP"
  37. #else
  38. extern int __bss_end;
  39. #endif
  40. #ifdef DEBUG
  41. /*******************************************************************************
  42. * Function Name : assert_failed
  43. * Description : Reports the name of the source file and the source line number
  44. * where the assert error has occurred.
  45. * Input : - file: pointer to the source file name
  46. * - line: assert error line source number
  47. * Output : None
  48. * Return : None
  49. *******************************************************************************/
  50. void assert_failed(u8 *file, u32 line)
  51. {
  52. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  53. rt_kprintf(" file %s\r\n", file);
  54. rt_kprintf(" line %d\r\n", line);
  55. while (1) ;
  56. }
  57. #endif
  58. /**
  59. * This function will startup RT-Thread RTOS.
  60. */
  61. void rtthread_startup(void)
  62. {
  63. /* init board */
  64. rt_hw_board_init();
  65. /* show version */
  66. rt_show_version();
  67. /* init timer system */
  68. rt_system_timer_init();
  69. #ifdef RT_USING_HEAP
  70. #ifdef __CC_ARM
  71. rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)LM3S_SRAM_END);
  72. #elif __ICCARM__
  73. rt_system_heap_init(__segment_end("HEAP"), (void *)LM3S_SRAM_END);
  74. #else
  75. /* init memory system */
  76. rt_system_heap_init((void *)&__bss_end, (void *)LM3S_SRAM_END);
  77. #endif
  78. #endif
  79. #ifdef RT_USING_MODULE
  80. /* init module system */
  81. rt_system_module_init();
  82. #endif
  83. /* init scheduler system */
  84. rt_system_scheduler_init();
  85. #ifdef RT_USING_LWIP
  86. eth_system_device_init();
  87. /* register ethernetif device */
  88. rt_hw_luminaryif_init();
  89. #endif
  90. /* init hardware serial device */
  91. rt_hw_serial_init();
  92. #ifdef RT_USING_DFS
  93. /* init sd card device */
  94. rt_hw_sdcard_init();
  95. #endif
  96. /* init application */
  97. rt_application_init();
  98. #ifdef RT_USING_FINSH
  99. /* init finsh */
  100. finsh_system_init();
  101. #if !defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_DEVICE)
  102. finsh_set_device("uart1");
  103. #endif
  104. #endif
  105. /* init idle thread */
  106. rt_thread_idle_init();
  107. /* start scheduler */
  108. rt_system_scheduler_start();
  109. /* never reach here */
  110. return ;
  111. }
  112. int main(void)
  113. {
  114. /* disable interrupt first */
  115. rt_hw_interrupt_disable();
  116. rtthread_startup();
  117. return 0;
  118. }
  119. /*@}*/