startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2012, 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. */
  13. #include <rthw.h>
  14. #include <rtthread.h>
  15. #include <sep4020.h>
  16. #include <board.h>
  17. #include <serial.h>
  18. #ifdef RT_USING_FINSH
  19. #include <finsh.h>
  20. #endif
  21. #ifdef RT_USING_LWIP
  22. #include <lwip/sys.h>
  23. #include <netif/ethernetif.h>
  24. #endif
  25. #define SDRAM_BASE 0x30000000
  26. #ifdef __CC_ARM
  27. extern int Image$$RW_RAM1$$ZI$$Limit;
  28. #elif (defined (__GNUC__))
  29. extern unsigned char __bss_end;
  30. #endif
  31. extern void rt_application_init(void);
  32. extern int finsh_system_init(void);
  33. extern void sd_init(void);
  34. void rtthread_startup()
  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. /* init heap memory system */
  49. #ifdef __CC_ARM
  50. rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000));
  51. #else
  52. rt_system_heap_init(&__bss_end, (void*)0x34000000);
  53. #endif
  54. /* init scheduler system */
  55. rt_system_scheduler_init();
  56. #ifdef RT_USING_DEVICE
  57. #ifdef RT_USING_DFS
  58. rt_hw_sdcard_init();
  59. #endif
  60. #ifdef RT_USING_LWIP
  61. eth_system_device_init();
  62. rt_hw_dm9161_init();
  63. #endif
  64. #endif
  65. /* init application */
  66. rt_application_init();
  67. #ifdef RT_USING_FINSH
  68. /* init finsh */
  69. finsh_system_init();
  70. #ifdef RT_USING_DEVICE
  71. finsh_set_device("uart0");
  72. #endif
  73. #endif
  74. /* init idle thread */
  75. rt_thread_idle_init();
  76. /* start scheduler */
  77. rt_system_scheduler_start();
  78. /* never reach here */
  79. return ;
  80. }
  81. int main()
  82. {
  83. /* disable interrupt first */
  84. rt_hw_interrupt_disable();
  85. /* startup RT-Thread RTOS */
  86. rtthread_startup();
  87. return 0;
  88. }