gcc_startup_nrf52810.S 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. /*
  2. Copyright (c) 2009-2018 ARM Limited. All rights reserved.
  3. SPDX-License-Identifier: Apache-2.0
  4. Licensed under the Apache License, Version 2.0 (the License); you may
  5. not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an AS IS BASIS, WITHOUT
  10. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. NOTICE: This file has been modified by Nordic Semiconductor ASA.
  14. */
  15. .syntax unified
  16. .arch armv7e-m
  17. #ifdef __STARTUP_CONFIG
  18. #include "startup_config.h"
  19. #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT
  20. #define __STARTUP_CONFIG_STACK_ALIGNEMENT 3
  21. #endif
  22. #endif
  23. .section .stack
  24. #if defined(__STARTUP_CONFIG)
  25. .align __STARTUP_CONFIG_STACK_ALIGNEMENT
  26. .equ Stack_Size, __STARTUP_CONFIG_STACK_SIZE
  27. #elif defined(__STACK_SIZE)
  28. .align 3
  29. .equ Stack_Size, __STACK_SIZE
  30. #else
  31. .align 3
  32. .equ Stack_Size, 2048
  33. #endif
  34. .globl __StackTop
  35. .globl __StackLimit
  36. __StackLimit:
  37. .space Stack_Size
  38. .size __StackLimit, . - __StackLimit
  39. __StackTop:
  40. .size __StackTop, . - __StackTop
  41. .section .heap
  42. .align 3
  43. #if defined(__STARTUP_CONFIG)
  44. .equ Heap_Size, __STARTUP_CONFIG_HEAP_SIZE
  45. #elif defined(__HEAP_SIZE)
  46. .equ Heap_Size, __HEAP_SIZE
  47. #else
  48. .equ Heap_Size, 2048
  49. #endif
  50. .globl __HeapBase
  51. .globl __HeapLimit
  52. __HeapBase:
  53. .if Heap_Size
  54. .space Heap_Size
  55. .endif
  56. .size __HeapBase, . - __HeapBase
  57. __HeapLimit:
  58. .size __HeapLimit, . - __HeapLimit
  59. .section .isr_vector
  60. .align 2
  61. .globl __isr_vector
  62. __isr_vector:
  63. .long __StackTop /* Top of Stack */
  64. .long Reset_Handler
  65. .long NMI_Handler
  66. .long HardFault_Handler
  67. .long MemoryManagement_Handler
  68. .long BusFault_Handler
  69. .long UsageFault_Handler
  70. .long 0 /*Reserved */
  71. .long 0 /*Reserved */
  72. .long 0 /*Reserved */
  73. .long 0 /*Reserved */
  74. .long SVC_Handler
  75. .long DebugMon_Handler
  76. .long 0 /*Reserved */
  77. .long PendSV_Handler
  78. .long SysTick_Handler
  79. /* External Interrupts */
  80. .long POWER_CLOCK_IRQHandler
  81. .long RADIO_IRQHandler
  82. .long UARTE0_UART0_IRQHandler
  83. .long TWIM0_TWIS0_TWI0_IRQHandler
  84. .long SPIM0_SPIS0_SPI0_IRQHandler
  85. .long 0 /*Reserved */
  86. .long GPIOTE_IRQHandler
  87. .long SAADC_IRQHandler
  88. .long TIMER0_IRQHandler
  89. .long TIMER1_IRQHandler
  90. .long TIMER2_IRQHandler
  91. .long RTC0_IRQHandler
  92. .long TEMP_IRQHandler
  93. .long RNG_IRQHandler
  94. .long ECB_IRQHandler
  95. .long CCM_AAR_IRQHandler
  96. .long WDT_IRQHandler
  97. .long RTC1_IRQHandler
  98. .long QDEC_IRQHandler
  99. .long COMP_IRQHandler
  100. .long SWI0_EGU0_IRQHandler
  101. .long SWI1_EGU1_IRQHandler
  102. .long SWI2_IRQHandler
  103. .long SWI3_IRQHandler
  104. .long SWI4_IRQHandler
  105. .long SWI5_IRQHandler
  106. .long 0 /*Reserved */
  107. .long 0 /*Reserved */
  108. .long PWM0_IRQHandler
  109. .long PDM_IRQHandler
  110. .long 0 /*Reserved */
  111. .long 0 /*Reserved */
  112. .long 0 /*Reserved */
  113. .long 0 /*Reserved */
  114. .long 0 /*Reserved */
  115. .long 0 /*Reserved */
  116. .long 0 /*Reserved */
  117. .long 0 /*Reserved */
  118. .long 0 /*Reserved */
  119. .long 0 /*Reserved */
  120. .long 0 /*Reserved */
  121. .long 0 /*Reserved */
  122. .long 0 /*Reserved */
  123. .long 0 /*Reserved */
  124. .long 0 /*Reserved */
  125. .long 0 /*Reserved */
  126. .long 0 /*Reserved */
  127. .long 0 /*Reserved */
  128. .long 0 /*Reserved */
  129. .long 0 /*Reserved */
  130. .long 0 /*Reserved */
  131. .long 0 /*Reserved */
  132. .long 0 /*Reserved */
  133. .long 0 /*Reserved */
  134. .long 0 /*Reserved */
  135. .long 0 /*Reserved */
  136. .long 0 /*Reserved */
  137. .long 0 /*Reserved */
  138. .long 0 /*Reserved */
  139. .long 0 /*Reserved */
  140. .long 0 /*Reserved */
  141. .long 0 /*Reserved */
  142. .long 0 /*Reserved */
  143. .long 0 /*Reserved */
  144. .long 0 /*Reserved */
  145. .long 0 /*Reserved */
  146. .long 0 /*Reserved */
  147. .long 0 /*Reserved */
  148. .long 0 /*Reserved */
  149. .long 0 /*Reserved */
  150. .long 0 /*Reserved */
  151. .long 0 /*Reserved */
  152. .long 0 /*Reserved */
  153. .long 0 /*Reserved */
  154. .long 0 /*Reserved */
  155. .long 0 /*Reserved */
  156. .long 0 /*Reserved */
  157. .long 0 /*Reserved */
  158. .long 0 /*Reserved */
  159. .long 0 /*Reserved */
  160. .long 0 /*Reserved */
  161. .long 0 /*Reserved */
  162. .long 0 /*Reserved */
  163. .long 0 /*Reserved */
  164. .long 0 /*Reserved */
  165. .long 0 /*Reserved */
  166. .long 0 /*Reserved */
  167. .long 0 /*Reserved */
  168. .long 0 /*Reserved */
  169. .long 0 /*Reserved */
  170. .long 0 /*Reserved */
  171. .long 0 /*Reserved */
  172. .long 0 /*Reserved */
  173. .long 0 /*Reserved */
  174. .long 0 /*Reserved */
  175. .long 0 /*Reserved */
  176. .long 0 /*Reserved */
  177. .long 0 /*Reserved */
  178. .long 0 /*Reserved */
  179. .long 0 /*Reserved */
  180. .long 0 /*Reserved */
  181. .long 0 /*Reserved */
  182. .long 0 /*Reserved */
  183. .long 0 /*Reserved */
  184. .long 0 /*Reserved */
  185. .long 0 /*Reserved */
  186. .long 0 /*Reserved */
  187. .long 0 /*Reserved */
  188. .long 0 /*Reserved */
  189. .long 0 /*Reserved */
  190. .long 0 /*Reserved */
  191. .long 0 /*Reserved */
  192. .size __isr_vector, . - __isr_vector
  193. /* Reset Handler */
  194. .text
  195. .thumb
  196. .thumb_func
  197. .align 1
  198. .globl Reset_Handler
  199. .type Reset_Handler, %function
  200. Reset_Handler:
  201. /* Loop to copy data from read only memory to RAM.
  202. * The ranges of copy from/to are specified by following symbols:
  203. * __etext: LMA of start of the section to copy from. Usually end of text
  204. * __data_start__: VMA of start of the section to copy to.
  205. * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__
  206. * the user can add their own initialized data section before BSS section with the INTERT AFTER command.
  207. *
  208. * All addresses must be aligned to 4 bytes boundary.
  209. */
  210. ldr r1, =__etext
  211. ldr r2, =__data_start__
  212. ldr r3, =__bss_start__
  213. subs r3, r3, r2
  214. ble .L_loop1_done
  215. .L_loop1:
  216. subs r3, r3, #4
  217. ldr r0, [r1,r3]
  218. str r0, [r2,r3]
  219. bgt .L_loop1
  220. .L_loop1_done:
  221. /* This part of work usually is done in C library startup code. Otherwise,
  222. * define __STARTUP_CLEAR_BSS to enable it in this startup. This section
  223. * clears the RAM where BSS data is located.
  224. *
  225. * The BSS section is specified by following symbols
  226. * __bss_start__: start of the BSS section.
  227. * __bss_end__: end of the BSS section.
  228. *
  229. * All addresses must be aligned to 4 bytes boundary.
  230. */
  231. #ifdef __STARTUP_CLEAR_BSS
  232. ldr r1, =__bss_start__
  233. ldr r2, =__bss_end__
  234. movs r0, 0
  235. subs r2, r2, r1
  236. ble .L_loop3_done
  237. .L_loop3:
  238. subs r2, r2, #4
  239. str r0, [r1, r2]
  240. bgt .L_loop3
  241. .L_loop3_done:
  242. #endif /* __STARTUP_CLEAR_BSS */
  243. /* Execute SystemInit function. */
  244. bl SystemInit
  245. /* Call _start function provided by libraries.
  246. * If those libraries are not accessible, define __START as your entry point.
  247. */
  248. #ifndef __START
  249. #define __START _start
  250. #endif
  251. bl __START
  252. .pool
  253. .size Reset_Handler,.-Reset_Handler
  254. .section ".text"
  255. /* Dummy Exception Handlers (infinite loops which can be modified) */
  256. .weak NMI_Handler
  257. .type NMI_Handler, %function
  258. NMI_Handler:
  259. b .
  260. .size NMI_Handler, . - NMI_Handler
  261. .weak HardFault_Handler
  262. .type HardFault_Handler, %function
  263. HardFault_Handler:
  264. b .
  265. .size HardFault_Handler, . - HardFault_Handler
  266. .weak MemoryManagement_Handler
  267. .type MemoryManagement_Handler, %function
  268. MemoryManagement_Handler:
  269. b .
  270. .size MemoryManagement_Handler, . - MemoryManagement_Handler
  271. .weak BusFault_Handler
  272. .type BusFault_Handler, %function
  273. BusFault_Handler:
  274. b .
  275. .size BusFault_Handler, . - BusFault_Handler
  276. .weak UsageFault_Handler
  277. .type UsageFault_Handler, %function
  278. UsageFault_Handler:
  279. b .
  280. .size UsageFault_Handler, . - UsageFault_Handler
  281. .weak SVC_Handler
  282. .type SVC_Handler, %function
  283. SVC_Handler:
  284. b .
  285. .size SVC_Handler, . - SVC_Handler
  286. .weak DebugMon_Handler
  287. .type DebugMon_Handler, %function
  288. DebugMon_Handler:
  289. b .
  290. .size DebugMon_Handler, . - DebugMon_Handler
  291. .weak PendSV_Handler
  292. .type PendSV_Handler, %function
  293. PendSV_Handler:
  294. b .
  295. .size PendSV_Handler, . - PendSV_Handler
  296. .weak SysTick_Handler
  297. .type SysTick_Handler, %function
  298. SysTick_Handler:
  299. b .
  300. .size SysTick_Handler, . - SysTick_Handler
  301. /* IRQ Handlers */
  302. .globl Default_Handler
  303. .type Default_Handler, %function
  304. Default_Handler:
  305. b .
  306. .size Default_Handler, . - Default_Handler
  307. .macro IRQ handler
  308. .weak \handler
  309. .set \handler, Default_Handler
  310. .endm
  311. IRQ POWER_CLOCK_IRQHandler
  312. IRQ RADIO_IRQHandler
  313. IRQ UARTE0_UART0_IRQHandler
  314. IRQ TWIM0_TWIS0_TWI0_IRQHandler
  315. IRQ SPIM0_SPIS0_SPI0_IRQHandler
  316. IRQ GPIOTE_IRQHandler
  317. IRQ SAADC_IRQHandler
  318. IRQ TIMER0_IRQHandler
  319. IRQ TIMER1_IRQHandler
  320. IRQ TIMER2_IRQHandler
  321. IRQ RTC0_IRQHandler
  322. IRQ TEMP_IRQHandler
  323. IRQ RNG_IRQHandler
  324. IRQ ECB_IRQHandler
  325. IRQ CCM_AAR_IRQHandler
  326. IRQ WDT_IRQHandler
  327. IRQ RTC1_IRQHandler
  328. IRQ QDEC_IRQHandler
  329. IRQ COMP_IRQHandler
  330. IRQ SWI0_EGU0_IRQHandler
  331. IRQ SWI1_EGU1_IRQHandler
  332. IRQ SWI2_IRQHandler
  333. IRQ SWI3_IRQHandler
  334. IRQ SWI4_IRQHandler
  335. IRQ SWI5_IRQHandler
  336. IRQ PWM0_IRQHandler
  337. IRQ PDM_IRQHandler
  338. .end