startup.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. extern struct serial_device uart2;
  38. extern struct rt_device uart2_device;
  39. /**
  40. * @addtogroup mini2440
  41. */
  42. /*@{*/
  43. #if defined(__CC_ARM)
  44. extern int Image$$ER_ZI$$ZI$$Base;
  45. extern int Image$$ER_ZI$$ZI$$Length;
  46. extern int Image$$ER_ZI$$ZI$$Limit;
  47. #elif (defined (__GNUC__))
  48. rt_uint8_t _irq_stack_start[1024];
  49. rt_uint8_t _fiq_stack_start[1024];
  50. rt_uint8_t _undefined_stack_start[512];
  51. rt_uint8_t _abort_stack_start[512];
  52. rt_uint8_t _svc_stack_start[4096] SECTION(".nobss");
  53. extern unsigned char __bss_start;
  54. extern unsigned char __bss_end;
  55. #endif
  56. #ifdef RT_USING_FINSH
  57. extern int finsh_system_init(void);
  58. #endif
  59. /**
  60. * This function will startup RT-Thread RTOS.
  61. */
  62. void rtthread_startup(void)
  63. {
  64. /* enable cpu cache */
  65. rt_hw_cpu_icache_enable();
  66. rt_hw_cpu_dcache_enable();
  67. /* init hardware interrupt */
  68. rt_hw_interrupt_init();
  69. /* init board */
  70. rt_hw_board_init();
  71. /* show version */
  72. rt_show_version();
  73. /* init tick */
  74. rt_system_tick_init();
  75. /* init kernel object */
  76. rt_system_object_init();
  77. /* init timer system */
  78. rt_system_timer_init();
  79. /* init heap memory system */
  80. #ifdef __CC_ARM
  81. rt_system_heap_init((void*)&Image$$ER_ZI$$ZI$$Limit, (void*)0x33F00000);
  82. #else
  83. rt_system_heap_init((void*)&__bss_end, (void*)0x33F00000);
  84. #endif
  85. #ifdef RT_USING_MODULE
  86. /* init module system*/
  87. rt_system_module_init();
  88. #endif
  89. /* init scheduler system */
  90. rt_system_scheduler_init();
  91. #ifdef RT_USING_DEVICE
  92. /* register uart0 */
  93. rt_hw_serial_register(&uart0_device, "uart0",
  94. RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  95. &uart0);
  96. /* register uart2, used for RTI debug */
  97. rt_hw_serial_register(&uart2_device, "uart2",
  98. RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  99. &uart2);
  100. #ifdef RT_USING_DFS
  101. rt_hw_sdcard_init();
  102. #ifdef RT_USING_DFS_UFFS
  103. rt_hw_nand_init();
  104. #endif
  105. #endif
  106. /* rtc init */
  107. rt_hw_rtc_init();
  108. #endif
  109. /* init application */
  110. rt_application_init();
  111. #ifdef RT_USING_FINSH
  112. /* init finsh */
  113. finsh_system_init();
  114. #ifdef RT_USING_DEVICE
  115. finsh_set_device("uart0");
  116. #endif
  117. #endif
  118. rt_system_timer_thread_init();
  119. /* init idle thread */
  120. rt_thread_idle_init();
  121. /* start scheduler */
  122. rt_system_scheduler_start();
  123. /* never reach here */
  124. return ;
  125. }
  126. int main(void)
  127. {
  128. /* disable interrupt first */
  129. rt_hw_interrupt_disable();
  130. /* startup RT-Thread RTOS */
  131. rtthread_startup();
  132. return 0;
  133. }
  134. /*@}*/