startup.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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-02-26 Bernard first implementation
  13. * 2006-05-05 Bernard add two test thread
  14. * 2006-08-10 Bernard use rt_show_version to display version information
  15. * 2008-07-14 Bernard modify the heap memory init parameter
  16. */
  17. #include <rtthread.h>
  18. #include <rthw.h>
  19. #include <s3c24x0.h>
  20. extern void rt_hw_interrupt_init(void);
  21. extern void rt_hw_board_init(void);
  22. extern void rt_serial_init(void);
  23. extern void rt_system_timer_init(void);
  24. extern void rt_system_scheduler_init(void);
  25. extern void rt_thread_idle_init(void);
  26. extern void rt_hw_cpu_icache_enable(void);
  27. extern void rt_show_version(void);
  28. extern void rt_system_heap_init(void*, void*);
  29. extern void rt_hw_finsh_init(void);
  30. extern void rt_application_init(void);
  31. extern struct serial_device uart0;
  32. extern struct rt_device uart0_device;
  33. /**
  34. * @addtogroup mini2440
  35. */
  36. /*@{*/
  37. #if defined(__CC_ARM)
  38. extern int Image$$ER_ZI$$ZI$$Base;
  39. extern int Image$$ER_ZI$$ZI$$Length;
  40. extern int Image$$ER_ZI$$ZI$$Limit;
  41. #elif defined(__GNU_C__)
  42. extern int __bss_end;
  43. #endif
  44. #ifdef RT_USING_FINSH
  45. extern void finsh_system_init(void);
  46. #endif
  47. /**
  48. * This function will startup RT-Thread RTOS.
  49. */
  50. void rtthread_startup(void)
  51. {
  52. /* enable cpu cache */
  53. rt_hw_cpu_icache_enable();
  54. rt_hw_cpu_dcache_enable();
  55. /* init hardware interrupt */
  56. rt_hw_interrupt_init();
  57. /* init board */
  58. rt_hw_board_init();
  59. /* show version */
  60. rt_show_version();
  61. /* init tick */
  62. rt_system_tick_init();
  63. /* init kernel object */
  64. rt_system_object_init();
  65. /* init timer system */
  66. rt_system_timer_init();
  67. /* init heap memory system */
  68. #ifdef __CC_ARM
  69. rt_system_heap_init((void*)&Image$$ER_ZI$$ZI$$Limit, (void*)0x07400000);
  70. #else
  71. rt_system_heap_init(&__bss_end, (void*)0x34000000);
  72. #endif
  73. /* init scheduler system */
  74. rt_system_scheduler_init();
  75. #ifdef RT_USING_DEVICE
  76. /* register uart1 */
  77. rt_hw_serial_register(&uart0_device, "uart0",
  78. RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  79. &uart0);
  80. rt_hw_sdcard_init();
  81. /*init all registed devices */
  82. rt_device_init_all();
  83. #endif
  84. /* init application */
  85. rt_application_init();
  86. #ifdef RT_USING_FINSH
  87. /* init finsh */
  88. finsh_system_init();
  89. #ifdef RT_USING_DEVICE
  90. finsh_set_device("uart0");
  91. #endif
  92. #endif
  93. /* init idle thread */
  94. rt_thread_idle_init();
  95. /* start scheduler */
  96. rt_system_scheduler_start();
  97. /* never reach here */
  98. return ;
  99. }
  100. int main(void)
  101. {
  102. rt_uint32_t UNUSED level;
  103. /* disable interrupt first */
  104. level = rt_hw_interrupt_disable();
  105. /* startup RT-Thread RTOS */
  106. rtthread_startup();
  107. return 0;
  108. }
  109. /*@}*/