start_gcc.S 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /******************************************************************//**
  2. * @file start_gcc.S
  3. * @brief Context switch functions
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. * @author onelife
  6. * @version 0.4 beta
  7. **********************************************************************
  8. * @section License
  9. * The license and distribution terms for this file may be found in the file LICENSE in this
  10. * distribution or at http://www.rt-thread.org/license/LICENSE
  11. **********************************************************************
  12. * @section Change Logs
  13. * Date Author Notes
  14. * 2010-12-21 onelife Initial creation for EFM32
  15. *********************************************************************/
  16. /******************************************************************//**
  17. * @addtogroup cortex-m3
  18. * @{
  19. *********************************************************************/
  20. .syntax unified
  21. .cpu cortex-m3
  22. .fpu softvfp
  23. .thumb
  24. /* start address for the initialization values of the .data section.
  25. defined in linker script */
  26. .word _sidata
  27. /* start address for the .data section. defined in linker script */
  28. .word _sdata
  29. /* end address for the .data section. defined in linker script */
  30. .word _edata
  31. /* start address for the .bss section. defined in linker script */
  32. .word _sbss
  33. /* end address for the .bss section. defined in linker script */
  34. .word _ebss
  35. /******************************************************************************
  36. *
  37. * The minimal vector table for a Cortex M3. Note that the proper constructs
  38. * must be placed on this to ensure that it ends up at physical address
  39. * 0x0000.0000.
  40. *
  41. ******************************************************************************/
  42. .section .isr_vector, "a", %progbits
  43. .global g_pfnVectors
  44. .type g_pfnVectors, %object
  45. g_pfnVectors:
  46. .word Initial_spTop
  47. .word Reset_Handler
  48. .word NMI_Handler
  49. .word rt_hw_hard_fault
  50. .word MemManage_Handler
  51. .word BusFault_Handler
  52. .word UsageFault_Handler
  53. .word 0
  54. .word 0
  55. .word 0
  56. .word 0
  57. .word SVC_Handler
  58. .word DebugMon_Handler
  59. .word 0
  60. .word rt_hw_pend_sv
  61. .word rt_hw_timer_handler
  62. /* External Interrupts */
  63. .word DMA_IRQHandler /* 0: DMA Interrupt (efm32_dma.c) */
  64. .word GPIO_EVEN_IRQHandler /* 1: GPIO_EVEN Interrupt */
  65. .word TIMER0_IRQHandler /* 2: TIMER0 Interrupt */
  66. .word USART0_RX_IRQHandler /* 3: USART0_RX Interrupt */
  67. .word USART0_TX_IRQHandler /* 4: USART0_TX Interrupt */
  68. .word ACMP0_IRQHandler /* 5: ACMP0 Interrupt */
  69. .word ADC0_IRQHandler /* 6: ADC0 Interrupt */
  70. .word DAC0_IRQHandler /* 7: DAC0 Interrupt */
  71. .word I2C0_IRQHandler /* 8: I2C0 Interrupt */
  72. .word GPIO_ODD_IRQHandler /* 9: GPIO_ODD Interrupt */
  73. .word TIMER1_IRQHandler /* 10: TIMER1 Interrupt */
  74. .word TIMER2_IRQHandler /* 11: TIMER2 Interrupt */
  75. .word USART1_RX_IRQHandler /* 12: USART1_RX Interrupt */
  76. .word USART1_TX_IRQHandler /* 13: USART1_TX Interrupt */
  77. .word USART2_RX_IRQHandler /* 14: USART2_RX Interrupt */
  78. .word USART2_TX_IRQHandler /* 15: USART2_TX Interrupt */
  79. .word UART0_RX_IRQHandler /* 16: UART0_RX Interrupt */
  80. .word UART0_TX_IRQHandler /* 17: UART0_TX Interrupt */
  81. .word LEUART0_IRQHandler /* 18: LEUART0 Interrupt */
  82. .word LEUART1_IRQHandler /* 19: LEUART1 Interrupt */
  83. .word LETIMER0_IRQHandler /* 20: LETIMER0 Interrupt */
  84. .word PCNT0_IRQHandler /* 21: PCNT0 Interrupt */
  85. .word PCNT1_IRQHandler /* 22: PCNT1 Interrupt */
  86. .word PCNT2_IRQHandler /* 23: PCNT2 Interrupt */
  87. .word RTC_IRQHandler /* 24: RTC Interrupt */
  88. .word CMU_IRQHandler /* 25: CMU Interrupt */
  89. .word VCMP_IRQHandler /* 26: VCMP Interrupt */
  90. .word LCD_IRQHandler /* 27: LCD Interrupt */
  91. .word MSC_IRQHandler /* 28: MSC Interrupt */
  92. .word AES_IRQHandler /* 29: AES Interrupt */
  93. .size g_pfnVectors, .-g_pfnVectors
  94. /**
  95. * @brief Top of stack pointer
  96. */
  97. .section .bss.init
  98. .equ Stack_Size, 0x00000200
  99. .space Stack_Size
  100. Initial_spTop:
  101. /**
  102. * @brief This is the code that gets called when the processor first
  103. * starts execution following a reset event. Only the absolutely
  104. * necessary set is performed, after which the application
  105. * supplied main() routine is called.
  106. * @param None
  107. * @retval None
  108. */
  109. .thumb
  110. .thumb_func
  111. .section .text.Reset_Handler, "ax", %progbits
  112. .weak Reset_Handler
  113. .global Reset_Handler
  114. .type Reset_Handler, %function
  115. Reset_Handler:
  116. /* restore original stack pointer */
  117. ldr r0, =Initial_spTop
  118. msr msp, r0
  119. /* Copy the data segment initializers from flash to SRAM */
  120. movs r1, #0
  121. b LoopCopyDataInit
  122. CopyDataInit:
  123. ldr r3, =_sidata
  124. ldr r3, [r3, r1]
  125. str r3, [r0, r1]
  126. adds r1, r1, #4
  127. LoopCopyDataInit:
  128. ldr r0, =_sdata
  129. ldr r3, =_edata
  130. adds r2, r0, r1
  131. cmp r2, r3
  132. bcc CopyDataInit
  133. ldr r2, =_sbss
  134. b LoopFillZerobss
  135. /* Zero fill the bss segment. */
  136. FillZerobss:
  137. movs r3, #0
  138. str r3, [r2], #4
  139. LoopFillZerobss:
  140. ldr r3, = _ebss
  141. cmp r2, r3
  142. bcc FillZerobss
  143. /* Call the application's entry point.*/
  144. bl main
  145. bx lr
  146. .size Reset_Handler, .-Reset_Handler
  147. /**
  148. * @brief This is the code that gets called when the processor receives an
  149. * unexpected interrupt. This simply enters an infinite loop, preserving
  150. * the system state for examination by a debugger.
  151. *
  152. * @param None
  153. * @retval None
  154. */
  155. .thumb
  156. .thumb_func
  157. .section .text.Default_Handler, "ax", %progbits
  158. .global Default_Handler
  159. .type Default_Handler, %function
  160. Default_Handler:
  161. Infinite_Loop:
  162. b Infinite_Loop
  163. .size Default_Handler, .-Default_Handler
  164. /*******************************************************************************
  165. *
  166. * Provide weak aliases for each Exception handler to the Default_Handler.
  167. * As they are weak aliases, any function with the same name will override
  168. * this definition.
  169. *
  170. *******************************************************************************/
  171. .weak NMI_Handler
  172. .thumb_set NMI_Handler, Default_Handler
  173. .weak MemManage_Handler
  174. .thumb_set MemManage_Handler, Default_Handler
  175. .weak BusFault_Handler
  176. .thumb_set BusFault_Handler, Default_Handler
  177. .weak UsageFault_Handler
  178. .thumb_set UsageFault_Handler, Default_Handler
  179. .weak SVC_Handler
  180. .thumb_set SVC_Handler, Default_Handler
  181. .weak DebugMon_Handler
  182. .thumb_set DebugMon_Handler ,Default_Handler
  183. .weak DMA_IRQHandler
  184. .thumb_set DMA_IRQHandler, Default_Handler
  185. .weak GPIO_EVEN_IRQHandler
  186. .thumb_set GPIO_EVEN_IRQHandler, Default_Handler
  187. .weak TIMER0_IRQHandler
  188. .thumb_set TIMER0_IRQHandler, Default_Handler
  189. .weak USART0_RX_IRQHandler
  190. .thumb_set USART0_RX_IRQHandler, Default_Handler
  191. .weak USART0_TX_IRQHandler
  192. .thumb_set USART0_TX_IRQHandler, Default_Handler
  193. .weak ACMP0_IRQHandler
  194. .thumb_set ACMP0_IRQHandler, Default_Handler
  195. .weak ADC0_IRQHandler
  196. .thumb_set ADC0_IRQHandler, Default_Handler
  197. .weak DAC0_IRQHandler
  198. .thumb_set DAC0_IRQHandler, Default_Handler
  199. .weak I2C0_IRQHandler
  200. .thumb_set I2C0_IRQHandler, Default_Handler
  201. .weak GPIO_ODD_IRQHandler
  202. .thumb_set GPIO_ODD_IRQHandler, Default_Handler
  203. .weak TIMER1_IRQHandler
  204. .thumb_set TIMER1_IRQHandler, Default_Handler
  205. .weak TIMER2_IRQHandler
  206. .thumb_set TIMER2_IRQHandler, Default_Handler
  207. .weak USART1_RX_IRQHandler
  208. .thumb_set USART1_RX_IRQHandler, Default_Handler
  209. .weak USART1_TX_IRQHandler
  210. .thumb_set USART1_TX_IRQHandler, Default_Handler
  211. .weak USART2_RX_IRQHandler
  212. .thumb_set USART2_RX_IRQHandler, Default_Handler
  213. .weak USART2_TX_IRQHandler
  214. .thumb_set USART2_TX_IRQHandler, Default_Handler
  215. .weak UART0_RX_IRQHandler
  216. .thumb_set UART0_RX_IRQHandler, Default_Handler
  217. .weak UART0_TX_IRQHandler
  218. .thumb_set UART0_TX_IRQHandler, Default_Handler
  219. .weak LEUART0_IRQHandler
  220. .thumb_set LEUART0_IRQHandler, Default_Handler
  221. .weak LEUART1_IRQHandler
  222. .thumb_set LEUART1_IRQHandler, Default_Handler
  223. .weak LETIMER0_IRQHandler
  224. .thumb_set LETIMER0_IRQHandler, Default_Handler
  225. .weak PCNT0_IRQHandler
  226. .thumb_set PCNT0_IRQHandler, Default_Handler
  227. .weak PCNT1_IRQHandler
  228. .thumb_set PCNT1_IRQHandler, Default_Handler
  229. .weak PCNT2_IRQHandler
  230. .thumb_set PCNT2_IRQHandler, Default_Handler
  231. .weak RTC_IRQHandler
  232. .thumb_set RTC_IRQHandler, Default_Handler
  233. .weak CMU_IRQHandler
  234. .thumb_set CMU_IRQHandler, Default_Handler
  235. .weak VCMP_IRQHandler
  236. .thumb_set VCMP_IRQHandler, Default_Handler
  237. .weak LCD_IRQHandler
  238. .thumb_set LCD_IRQHandler, Default_Handler
  239. .weak MSC_IRQHandler
  240. .thumb_set MSC_IRQHandler, Default_Handler
  241. .weak AES_IRQHandler
  242. .thumb_set AES_IRQHandler, Default_Handler
  243. /******************************************************************//**
  244. * @}
  245. *********************************************************************/