startup_efm32g.s 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /* @file
  2. * @brief startup file for Energy Micro 'EFM32G' 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 ACMP0_IRQHandler /* 5 - ACMP0 */
  94. .long ADC0_IRQHandler /* 6 - ADC0 */
  95. .long DAC0_IRQHandler /* 7 - DAC0 */
  96. .long I2C0_IRQHandler /* 8 - I2C0 */
  97. .long GPIO_ODD_IRQHandler /* 9 - GPIO_ODD */
  98. .long TIMER1_IRQHandler /* 10 - TIMER1 */
  99. .long TIMER2_IRQHandler /* 11 - TIMER2 */
  100. .long USART1_RX_IRQHandler /* 12 - USART1_RX */
  101. .long USART1_TX_IRQHandler /* 13 - USART1_TX */
  102. .long USART2_RX_IRQHandler /* 14 - USART2_RX */
  103. .long USART2_TX_IRQHandler /* 15 - USART2_TX */
  104. .long UART0_RX_IRQHandler /* 16 - UART0_RX */
  105. .long UART0_TX_IRQHandler /* 17 - UART0_TX */
  106. .long LEUART0_IRQHandler /* 18 - LEUART0 */
  107. .long LEUART1_IRQHandler /* 19 - LEUART1 */
  108. .long LETIMER0_IRQHandler /* 20 - LETIMER0 */
  109. .long PCNT0_IRQHandler /* 21 - PCNT0 */
  110. .long PCNT1_IRQHandler /* 22 - PCNT1 */
  111. .long PCNT2_IRQHandler /* 23 - PCNT2 */
  112. .long RTC_IRQHandler /* 24 - RTC */
  113. .long CMU_IRQHandler /* 25 - CMU */
  114. .long VCMP_IRQHandler /* 26 - VCMP */
  115. .long LCD_IRQHandler /* 27 - LCD */
  116. .long MSC_IRQHandler /* 28 - MSC */
  117. .long AES_IRQHandler /* 29 - AES */
  118. .size __isr_vector, . - __isr_vector
  119. .text
  120. .thumb
  121. .thumb_func
  122. .align 2
  123. .globl Reset_Handler
  124. .type Reset_Handler, %function
  125. Reset_Handler:
  126. /* Loop to copy data from read only memory to RAM. The ranges
  127. * of copy from/to are specified by following symbols evaluated in
  128. * linker script.
  129. * __etext: End of code section, i.e., begin of data sections to copy from.
  130. * __data_start__/__data_end__: RAM address range that data should be
  131. * copied to. Both must be aligned to 4 bytes boundary. */
  132. #ifndef __NO_SYSTEM_INIT
  133. ldr r0, =SystemInit
  134. blx r0
  135. #endif
  136. ldr r1, =__etext
  137. ldr r2, =__data_start__
  138. ldr r3, =__data_end__
  139. #if 1
  140. /* Here are two copies of loop implemenations. First one favors code size
  141. * and the second one favors performance. Default uses the first one.
  142. * Change to "#if 0" to use the second one */
  143. .flash_to_ram_loop:
  144. cmp r2, r3
  145. ittt lt
  146. ldrlt r0, [r1], #4
  147. strlt r0, [r2], #4
  148. blt .flash_to_ram_loop
  149. #else
  150. subs r3, r2
  151. ble .flash_to_ram_loop_end
  152. .flash_to_ram_loop:
  153. subs r3, #4
  154. ldr r0, [r1, r3]
  155. str r0, [r2, r3]
  156. bgt .flash_to_ram_loop
  157. .flash_to_ram_loop_end:
  158. #endif
  159. #ifndef __NO_SYSTEM_INIT
  160. ldr r0, =SystemInit
  161. blx r0
  162. #endif
  163. ldr r0, =_start
  164. bx r0
  165. .pool
  166. .size Reset_Handler, . - Reset_Handler
  167. /* Macro to define default handlers. Default handler
  168. * will be weak symbol and just dead loops. They can be
  169. * overwritten by other handlers */
  170. .macro def_irq_handler handler_name
  171. .align 1
  172. .thumb_func
  173. .weak \handler_name
  174. .type \handler_name, %function
  175. \handler_name:
  176. b .
  177. .size \handler_name, . - \handler_name
  178. .endm
  179. def_irq_handler Default_Handler
  180. def_irq_handler NMI_Handler
  181. def_irq_handler HardFault_Handler
  182. def_irq_handler MemManage_Handler
  183. def_irq_handler BusFault_Handler
  184. def_irq_handler UsageFault_Handler
  185. def_irq_handler SVC_Handler
  186. def_irq_handler DebugMon_Handler
  187. def_irq_handler PendSV_Handler
  188. def_irq_handler SysTick_Handler
  189. def_irq_handler DMA_IRQHandler
  190. def_irq_handler GPIO_EVEN_IRQHandler
  191. def_irq_handler TIMER0_IRQHandler
  192. def_irq_handler USART0_RX_IRQHandler
  193. def_irq_handler USART0_TX_IRQHandler
  194. def_irq_handler ACMP0_IRQHandler
  195. def_irq_handler ADC0_IRQHandler
  196. def_irq_handler DAC0_IRQHandler
  197. def_irq_handler I2C0_IRQHandler
  198. def_irq_handler GPIO_ODD_IRQHandler
  199. def_irq_handler TIMER1_IRQHandler
  200. def_irq_handler TIMER2_IRQHandler
  201. def_irq_handler USART1_RX_IRQHandler
  202. def_irq_handler USART1_TX_IRQHandler
  203. def_irq_handler USART2_RX_IRQHandler
  204. def_irq_handler USART2_TX_IRQHandler
  205. def_irq_handler UART0_RX_IRQHandler
  206. def_irq_handler UART0_TX_IRQHandler
  207. def_irq_handler LEUART0_IRQHandler
  208. def_irq_handler LEUART1_IRQHandler
  209. def_irq_handler LETIMER0_IRQHandler
  210. def_irq_handler PCNT0_IRQHandler
  211. def_irq_handler PCNT1_IRQHandler
  212. def_irq_handler PCNT2_IRQHandler
  213. def_irq_handler RTC_IRQHandler
  214. def_irq_handler CMU_IRQHandler
  215. def_irq_handler VCMP_IRQHandler
  216. def_irq_handler LCD_IRQHandler
  217. def_irq_handler MSC_IRQHandler
  218. def_irq_handler AES_IRQHandler
  219. .end