startup.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include <rthw.h>
  2. #include <rtthread.h>
  3. #include <sep4020.h>
  4. #include <board.h>
  5. #include <serial.h>
  6. #ifdef RT_USING_FINSH
  7. #include <finsh.h>
  8. #endif
  9. #ifdef RT_USING_LWIP
  10. #include <lwip/sys.h>
  11. #include <netif/ethernetif.h>
  12. #endif
  13. #define SDRAM_BASE 0x30000000
  14. #ifdef __CC_ARM
  15. extern int Image$$RW_RAM1$$ZI$$Limit;
  16. #elif (defined (__GNUC__))
  17. extern unsigned char __bss_end;
  18. #endif
  19. extern void rt_application_init(void);
  20. extern void finsh_system_init(void);
  21. extern void sd_init(void);
  22. void rtthread_startup()
  23. {
  24. /* init hardware interrupt */
  25. rt_hw_interrupt_init();
  26. /* init board */
  27. rt_hw_board_init();
  28. /* show version */
  29. rt_show_version();
  30. /* init tick */
  31. rt_system_tick_init();
  32. /* init kernel object */
  33. rt_system_object_init();
  34. /* init timer system */
  35. rt_system_timer_init();
  36. /* init heap memory system */
  37. #ifdef __CC_ARM
  38. rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000));
  39. #else
  40. rt_system_heap_init(&__bss_end, (void*)0x34000000);
  41. #endif
  42. /* init scheduler system */
  43. rt_system_scheduler_init();
  44. #ifdef RT_USING_DEVICE
  45. #ifdef RT_USING_DFS
  46. rt_hw_sdcard_init();
  47. #endif
  48. #ifdef RT_USING_LWIP
  49. eth_system_device_init();
  50. rt_hw_dm9161_init();
  51. #endif
  52. /*init all registed devices */
  53. rt_device_init_all();
  54. #endif
  55. /* init application */
  56. rt_application_init();
  57. #ifdef RT_USING_FINSH
  58. /* init finsh */
  59. finsh_system_init();
  60. #ifdef RT_USING_DEVICE
  61. finsh_set_device("uart0");
  62. #endif
  63. #endif
  64. /* init idle thread */
  65. rt_thread_idle_init();
  66. /* start scheduler */
  67. rt_system_scheduler_start();
  68. /* never reach here */
  69. return ;
  70. }
  71. int main()
  72. {
  73. rt_uint32_t UNUSED level;
  74. /* disable interrupt first */
  75. level = rt_hw_interrupt_disable();
  76. /* startup RT-Thread RTOS */
  77. rtthread_startup();
  78. return 0;
  79. }