startup.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 timer system */
  43. rt_system_timer_init();
  44. /* init heap memory system */
  45. #ifdef __CC_ARM
  46. rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000));
  47. #else
  48. rt_system_heap_init(&__bss_end, (void*)0x34000000);
  49. #endif
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. #ifdef RT_USING_DEVICE
  53. #ifdef RT_USING_DFS
  54. rt_hw_sdcard_init();
  55. #endif
  56. #ifdef RT_USING_LWIP
  57. eth_system_device_init();
  58. rt_hw_dm9161_init();
  59. #endif
  60. #endif
  61. /* init application */
  62. rt_application_init();
  63. #ifdef RT_USING_FINSH
  64. /* init finsh */
  65. finsh_system_init();
  66. #ifdef RT_USING_DEVICE
  67. finsh_set_device("uart0");
  68. #endif
  69. #endif
  70. /* init idle thread */
  71. rt_thread_idle_init();
  72. /* start scheduler */
  73. rt_system_scheduler_start();
  74. /* never reach here */
  75. return ;
  76. }
  77. int main()
  78. {
  79. /* disable interrupt first */
  80. rt_hw_interrupt_disable();
  81. /* startup RT-Thread RTOS */
  82. rtthread_startup();
  83. return 0;
  84. }