startup.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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://www.rt-thread.org/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 <rthw.h>
  18. #include <rtthread.h>
  19. #include <s3c24x0.h>
  20. #ifdef RT_USING_FINSH
  21. #include <finsh.h>
  22. #endif
  23. extern void rt_hw_interrupt_init(void);
  24. extern void rt_hw_board_init(void);
  25. extern void rt_hw_rtc_init(void);
  26. extern void rt_serial_init(void);
  27. extern void rt_system_timer_init(void);
  28. extern void rt_system_scheduler_init(void);
  29. extern void rt_thread_idle_init(void);
  30. extern void rt_hw_cpu_icache_enable(void);
  31. extern void rt_show_version(void);
  32. extern void rt_system_heap_init(void*, void*);
  33. extern void rt_hw_finsh_init(void);
  34. extern void rt_application_init(void);
  35. extern struct serial_device uart0;
  36. extern struct rt_device uart0_device;
  37. /**
  38. * @addtogroup mini2440
  39. */
  40. /*@{*/
  41. #if defined(__CC_ARM)
  42. extern int Image$$ER_ZI$$ZI$$Base;
  43. extern int Image$$ER_ZI$$ZI$$Length;
  44. extern int Image$$ER_ZI$$ZI$$Limit;
  45. #elif (defined (__GNUC__))
  46. rt_uint8_t _irq_stack_start[1024];
  47. rt_uint8_t _fiq_stack_start[1024];
  48. rt_uint8_t _undefined_stack_start[512];
  49. rt_uint8_t _abort_stack_start[512];
  50. rt_uint8_t _svc_stack_start[1024] SECTION(".nobss");
  51. extern unsigned char __bss_start;
  52. extern unsigned char __bss_end;
  53. #endif
  54. #ifdef RT_USING_FINSH
  55. extern void finsh_system_init(void);
  56. #endif
  57. /**
  58. * This function will startup RT-Thread RTOS.
  59. */
  60. void rtthread_startup(void)
  61. {
  62. /* enable cpu cache */
  63. rt_hw_cpu_icache_enable();
  64. rt_hw_cpu_dcache_enable();
  65. /* init hardware interrupt */
  66. rt_hw_interrupt_init();
  67. /* init board */
  68. rt_hw_board_init();
  69. /* show version */
  70. rt_show_version();
  71. /* init tick */
  72. rt_system_tick_init();
  73. /* init kernel object */
  74. rt_system_object_init();
  75. /* init timer system */
  76. rt_system_timer_init();
  77. /* init heap memory system */
  78. #ifdef __CC_ARM
  79. rt_system_heap_init((void*)&Image$$ER_ZI$$ZI$$Limit, (void*)0x33F00000);
  80. #else
  81. rt_system_heap_init((void*)&__bss_end, (void*)0x33F00000);
  82. #endif
  83. #ifdef RT_USING_MODULE
  84. /* init module system*/
  85. rt_system_module_init();
  86. #endif
  87. /* init scheduler system */
  88. rt_system_scheduler_init();
  89. #ifdef RT_USING_DEVICE
  90. /* register uart1 */
  91. rt_hw_serial_register(&uart0_device, "uart0",
  92. RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  93. &uart0);
  94. #ifdef RT_USING_DFS
  95. rt_hw_sdcard_init();
  96. #endif
  97. /* rtc init */
  98. rt_hw_rtc_init();
  99. /*init all registed devices */
  100. rt_device_init_all();
  101. #endif
  102. /* init application */
  103. rt_application_init();
  104. #ifdef RT_USING_FINSH
  105. /* init finsh */
  106. finsh_system_init();
  107. #ifdef RT_USING_DEVICE
  108. finsh_set_device("uart0");
  109. #endif
  110. #endif
  111. rt_system_timer_thread_init();
  112. /* init idle thread */
  113. rt_thread_idle_init();
  114. /* start scheduler */
  115. rt_system_scheduler_start();
  116. /* never reach here */
  117. return ;
  118. }
  119. int main(void)
  120. {
  121. rt_uint32_t UNUSED level;
  122. /* disable interrupt first */
  123. level = rt_hw_interrupt_disable();
  124. /* startup RT-Thread RTOS */
  125. rtthread_startup();
  126. return 0;
  127. }
  128. /*@}*/