startup_efm32gg.s 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /* @file
  2. * @brief startup file for Energy Micro 'EFM32GG/LG' devices.
  3. * For use with GCC for ARM Embedded Processors
  4. * @version 3.0.0
  5. * Date: 08 Feb 2012
  6. *
  7. * Copyright (c) 2012, ARM Limited
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. * Redistributions of source code must retain the above copyright
  13. notice, this list of conditions and the following disclaimer.
  14. * Redistributions in binary form must reproduce the above copyright
  15. notice, this list of conditions and the following disclaimer in the
  16. documentation and/or other materials provided with the distribution.
  17. * Neither the name of the ARM Limited nor the
  18. names of its contributors may be used to endorse or promote products
  19. derived from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  22. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  23. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY
  25. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  26. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  27. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  28. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * Energy Micro release version
  33. * @version 3.0.0
  34. */
  35. .syntax unified
  36. .arch armv7-m
  37. .section .stack
  38. .align 3
  39. #ifdef __STACK_SIZE
  40. .equ Stack_Size, __STACK_SIZE
  41. #else
  42. .equ Stack_Size, 0x400
  43. #endif
  44. .globl __StackTop
  45. .globl __StackLimit
  46. __StackLimit:
  47. .space Stack_Size
  48. .size __StackLimit, . - __StackLimit
  49. __StackTop:
  50. .size __StackTop, . - __StackTop
  51. .section .heap
  52. .align 3
  53. #ifdef __HEAP_SIZE
  54. .equ Heap_Size, __HEAP_SIZE
  55. #else
  56. .equ Heap_Size, 0xC00
  57. #endif
  58. .globl __HeapBase
  59. .globl __HeapLimit
  60. __HeapBase:
  61. .if Heap_Size
  62. .space Heap_Size
  63. .endif
  64. .size __HeapBase, . - __HeapBase
  65. __HeapLimit:
  66. .size __HeapLimit, . - __HeapLimit
  67. .section .isr_vector
  68. .align 8
  69. .globl __isr_vector
  70. __isr_vector:
  71. .long __StackTop /* Top of Stack */
  72. .long Reset_Handler /* Reset Handler */
  73. .long NMI_Handler /* NMI Handler */
  74. .long HardFault_Handler /* Hard Fault Handler */
  75. .long MemManage_Handler /* MPU Fault Handler */
  76. .long BusFault_Handler /* Bus Fault Handler */
  77. .long UsageFault_Handler /* Usage Fault Handler */
  78. .long Default_Handler /* Reserved */
  79. .long Default_Handler /* Reserved */
  80. .long Default_Handler /* Reserved */
  81. .long Default_Handler /* Reserved */
  82. .long SVC_Handler /* SVCall Handler */
  83. .long DebugMon_Handler /* Debug Monitor Handler */
  84. .long Default_Handler /* Reserved */
  85. .long PendSV_Handler /* PendSV Handler */
  86. .long SysTick_Handler /* SysTick Handler */
  87. /* External interrupts */
  88. .long DMA_IRQHandler /* 0 - DMA */
  89. .long GPIO_EVEN_IRQHandler /* 1 - GPIO_EVEN */
  90. .long TIMER0_IRQHandler /* 2 - TIMER0 */
  91. .long USART0_RX_IRQHandler /* 3 - USART0_RX */
  92. .long USART0_TX_IRQHandler /* 4 - USART0_TX */
  93. .long USB_IRQHandler /* 5 - USB */
  94. .long ACMP0_IRQHandler /* 6 - ACMP0 */
  95. .long ADC0_IRQHandler /* 7 - ADC0 */
  96. .long DAC0_IRQHandler /* 8 - DAC0 */
  97. .long I2C0_IRQHandler /* 9 - I2C0 */
  98. .long I2C1_IRQHandler /* 10 - I2C1 */
  99. .long GPIO_ODD_IRQHandler /* 11 - GPIO_ODD */
  100. .long TIMER1_IRQHandler /* 12 - TIMER1 */
  101. .long TIMER2_IRQHandler /* 13 - TIMER2 */
  102. .long TIMER3_IRQHandler /* 14 - TIMER3 */
  103. .long USART1_RX_IRQHandler /* 15 - USART1_RX */
  104. .long USART1_TX_IRQHandler /* 16 - USART1_TX */
  105. .long LESENSE_IRQHandler /* 17 - LESENSE */
  106. .long USART2_RX_IRQHandler /* 18 - USART2_RX */
  107. .long USART2_TX_IRQHandler /* 19 - USART2_TX */
  108. .long UART0_RX_IRQHandler /* 20 - UART0_RX */
  109. .long UART0_TX_IRQHandler /* 21 - UART0_TX */
  110. .long UART1_RX_IRQHandler /* 22 - UART1_RX */
  111. .long UART1_TX_IRQHandler /* 23 - UART1_TX */
  112. .long LEUART0_IRQHandler /* 24 - LEUART0 */
  113. .long LEUART1_IRQHandler /* 25 - LEUART1 */
  114. .long LETIMER0_IRQHandler /* 26 - LETIMER0 */
  115. .long PCNT0_IRQHandler /* 27 - PCNT0 */
  116. .long PCNT1_IRQHandler /* 28 - PCNT1 */
  117. .long PCNT2_IRQHandler /* 29 - PCNT2 */
  118. .long RTC_IRQHandler /* 30 - RTC */
  119. .long BURTC_IRQHandler /* 31 - BURTC */
  120. .long CMU_IRQHandler /* 32 - CMU */
  121. .long VCMP_IRQHandler /* 33 - VCMP */
  122. .long LCD_IRQHandler /* 34 - LCD */
  123. .long MSC_IRQHandler /* 35 - MSC */
  124. .long AES_IRQHandler /* 36 - AES */
  125. .long EBI_IRQHandler /* 37 - EBI */
  126. .long EMU_IRQHandler /* 38 - EMU */
  127. .size __isr_vector, . - __isr_vector
  128. .text
  129. .thumb
  130. .thumb_func
  131. .align 2
  132. .globl Reset_Handler
  133. .type Reset_Handler, %function
  134. Reset_Handler:
  135. /* Loop to copy data from read only memory to RAM. The ranges
  136. * of copy from/to are specified by following symbols evaluated in
  137. * linker script.
  138. * __etext: End of code section, i.e., begin of data sections to copy from.
  139. * __data_start__/__data_end__: RAM address range that data should be
  140. * copied to. Both must be aligned to 4 bytes boundary. */
  141. #ifndef __NO_SYSTEM_INIT
  142. ldr r0, =SystemInit
  143. blx r0
  144. #endif
  145. ldr r1, =__etext
  146. ldr r2, =__data_start__
  147. ldr r3, =__data_end__
  148. #if 1
  149. /* Here are two copies of loop implemenations. First one favors code size
  150. * and the second one favors performance. Default uses the first one.
  151. * Change to "#if 0" to use the second one */
  152. .flash_to_ram_loop:
  153. cmp r2, r3
  154. ittt lt
  155. ldrlt r0, [r1], #4
  156. strlt r0, [r2], #4
  157. blt .flash_to_ram_loop
  158. #else
  159. subs r3, r2
  160. ble .flash_to_ram_loop_end
  161. .flash_to_ram_loop:
  162. subs r3, #4
  163. ldr r0, [r1, r3]
  164. str r0, [r2, r3]
  165. bgt .flash_to_ram_loop
  166. .flash_to_ram_loop_end:
  167. #endif
  168. #ifndef __NO_SYSTEM_INIT
  169. ldr r0, =SystemInit
  170. blx r0
  171. #endif
  172. ldr r0, =_start
  173. bx r0
  174. .pool
  175. .size Reset_Handler, . - Reset_Handler
  176. /* Macro to define default handlers. Default handler
  177. * will be weak symbol and just dead loops. They can be
  178. * overwritten by other handlers */
  179. .macro def_irq_handler handler_name
  180. .align 1
  181. .thumb_func
  182. .weak \handler_name
  183. .type \handler_name, %function
  184. \handler_name:
  185. b .
  186. .size \handler_name, . - \handler_name
  187. .endm
  188. def_irq_handler Default_Handler
  189. def_irq_handler NMI_Handler
  190. def_irq_handler HardFault_Handler
  191. def_irq_handler MemManage_Handler
  192. def_irq_handler BusFault_Handler
  193. def_irq_handler UsageFault_Handler
  194. def_irq_handler SVC_Handler
  195. def_irq_handler DebugMon_Handler
  196. def_irq_handler PendSV_Handler
  197. def_irq_handler SysTick_Handler
  198. def_irq_handler DMA_IRQHandler
  199. def_irq_handler GPIO_EVEN_IRQHandler
  200. def_irq_handler TIMER0_IRQHandler
  201. def_irq_handler USART0_RX_IRQHandler
  202. def_irq_handler USART0_TX_IRQHandler
  203. def_irq_handler USB_IRQHandler
  204. def_irq_handler ACMP0_IRQHandler
  205. def_irq_handler ADC0_IRQHandler
  206. def_irq_handler DAC0_IRQHandler
  207. def_irq_handler I2C0_IRQHandler
  208. def_irq_handler I2C1_IRQHandler
  209. def_irq_handler GPIO_ODD_IRQHandler
  210. def_irq_handler TIMER1_IRQHandler
  211. def_irq_handler TIMER2_IRQHandler
  212. def_irq_handler TIMER3_IRQHandler
  213. def_irq_handler USART1_RX_IRQHandler
  214. def_irq_handler USART1_TX_IRQHandler
  215. def_irq_handler LESENSE_IRQHandler
  216. def_irq_handler USART2_RX_IRQHandler
  217. def_irq_handler USART2_TX_IRQHandler
  218. def_irq_handler UART0_RX_IRQHandler
  219. def_irq_handler UART0_TX_IRQHandler
  220. def_irq_handler UART1_RX_IRQHandler
  221. def_irq_handler UART1_TX_IRQHandler
  222. def_irq_handler LEUART0_IRQHandler
  223. def_irq_handler LEUART1_IRQHandler
  224. def_irq_handler LETIMER0_IRQHandler
  225. def_irq_handler PCNT0_IRQHandler
  226. def_irq_handler PCNT1_IRQHandler
  227. def_irq_handler PCNT2_IRQHandler
  228. def_irq_handler RTC_IRQHandler
  229. def_irq_handler BURTC_IRQHandler
  230. def_irq_handler CMU_IRQHandler
  231. def_irq_handler VCMP_IRQHandler
  232. def_irq_handler LCD_IRQHandler
  233. def_irq_handler MSC_IRQHandler
  234. def_irq_handler AES_IRQHandler
  235. def_irq_handler EBI_IRQHandler
  236. def_irq_handler EMU_IRQHandler
  237. .end