gcc_startup_nrf52810.S 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. /*
  2. Copyright (c) 2009-2020 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, "ax"
  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. /* Workaround for Errata 185 RAM: RAM corruption at extreme corners
  202. * found at the Errata document for your device located
  203. * at https://infocenter.nordicsemi.com/index.jsp */
  204. LDR R0, =0x10000130
  205. LDR R0, [R0]
  206. LDR R1, =0x10000134
  207. LDR R1, [R1]
  208. CMP R0, #0xA
  209. BNE skip
  210. CMP R1, #0x0
  211. BNE skip
  212. LDR R0, =0x40000EE4
  213. LDR R2, [R0]
  214. LDR R3, =0xFFFFFF8F
  215. ANDS R2, R2, R3
  216. LDR R3, =0x00000040
  217. ORRS R2, R2, R3
  218. STR R2, [R0]
  219. skip:
  220. /* Loop to copy data from read only memory to RAM.
  221. * The ranges of copy from/to are specified by following symbols:
  222. * __etext: LMA of start of the section to copy from. Usually end of text
  223. * __data_start__: VMA of start of the section to copy to.
  224. * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__
  225. * the user can add their own initialized data section before BSS section with the INSERT AFTER command.
  226. *
  227. * All addresses must be aligned to 4 bytes boundary.
  228. */
  229. #ifndef __STARTUP_SKIP_ETEXT
  230. ldr r1, =__etext
  231. ldr r2, =__data_start__
  232. ldr r3, =__bss_start__
  233. subs r3, r3, r2
  234. ble .L_loop1_done
  235. .L_loop1:
  236. subs r3, r3, #4
  237. ldr r0, [r1,r3]
  238. str r0, [r2,r3]
  239. bgt .L_loop1
  240. .L_loop1_done:
  241. #endif
  242. /* This part of work usually is done in C library startup code. Otherwise,
  243. * define __STARTUP_CLEAR_BSS to enable it in this startup. This section
  244. * clears the RAM where BSS data is located.
  245. *
  246. * The BSS section is specified by following symbols
  247. * __bss_start__: start of the BSS section.
  248. * __bss_end__: end of the BSS section.
  249. *
  250. * All addresses must be aligned to 4 bytes boundary.
  251. */
  252. #ifdef __STARTUP_CLEAR_BSS
  253. ldr r1, =__bss_start__
  254. ldr r2, =__bss_end__
  255. movs r0, 0
  256. subs r2, r2, r1
  257. ble .L_loop3_done
  258. .L_loop3:
  259. subs r2, r2, #4
  260. str r0, [r1, r2]
  261. bgt .L_loop3
  262. .L_loop3_done:
  263. #endif /* __STARTUP_CLEAR_BSS */
  264. /* Execute SystemInit function. */
  265. bl SystemInit
  266. /* Call _start function provided by libraries.
  267. * If those libraries are not accessible, define __START as your entry point.
  268. */
  269. #ifndef __START
  270. #define __START _start
  271. #endif
  272. bl __START
  273. .pool
  274. .size Reset_Handler,.-Reset_Handler
  275. .section ".text"
  276. /* Dummy Exception Handlers (infinite loops which can be modified) */
  277. .weak NMI_Handler
  278. .type NMI_Handler, %function
  279. NMI_Handler:
  280. b .
  281. .size NMI_Handler, . - NMI_Handler
  282. .weak HardFault_Handler
  283. .type HardFault_Handler, %function
  284. HardFault_Handler:
  285. b .
  286. .size HardFault_Handler, . - HardFault_Handler
  287. .weak MemoryManagement_Handler
  288. .type MemoryManagement_Handler, %function
  289. MemoryManagement_Handler:
  290. b .
  291. .size MemoryManagement_Handler, . - MemoryManagement_Handler
  292. .weak BusFault_Handler
  293. .type BusFault_Handler, %function
  294. BusFault_Handler:
  295. b .
  296. .size BusFault_Handler, . - BusFault_Handler
  297. .weak UsageFault_Handler
  298. .type UsageFault_Handler, %function
  299. UsageFault_Handler:
  300. b .
  301. .size UsageFault_Handler, . - UsageFault_Handler
  302. .weak SVC_Handler
  303. .type SVC_Handler, %function
  304. SVC_Handler:
  305. b .
  306. .size SVC_Handler, . - SVC_Handler
  307. .weak DebugMon_Handler
  308. .type DebugMon_Handler, %function
  309. DebugMon_Handler:
  310. b .
  311. .size DebugMon_Handler, . - DebugMon_Handler
  312. .weak PendSV_Handler
  313. .type PendSV_Handler, %function
  314. PendSV_Handler:
  315. b .
  316. .size PendSV_Handler, . - PendSV_Handler
  317. .weak SysTick_Handler
  318. .type SysTick_Handler, %function
  319. SysTick_Handler:
  320. b .
  321. .size SysTick_Handler, . - SysTick_Handler
  322. /* IRQ Handlers */
  323. .globl Default_Handler
  324. .type Default_Handler, %function
  325. Default_Handler:
  326. b .
  327. .size Default_Handler, . - Default_Handler
  328. .macro IRQ handler
  329. .weak \handler
  330. .set \handler, Default_Handler
  331. .endm
  332. IRQ POWER_CLOCK_IRQHandler
  333. IRQ RADIO_IRQHandler
  334. IRQ UARTE0_UART0_IRQHandler
  335. IRQ TWIM0_TWIS0_TWI0_IRQHandler
  336. IRQ SPIM0_SPIS0_SPI0_IRQHandler
  337. IRQ GPIOTE_IRQHandler
  338. IRQ SAADC_IRQHandler
  339. IRQ TIMER0_IRQHandler
  340. IRQ TIMER1_IRQHandler
  341. IRQ TIMER2_IRQHandler
  342. IRQ RTC0_IRQHandler
  343. IRQ TEMP_IRQHandler
  344. IRQ RNG_IRQHandler
  345. IRQ ECB_IRQHandler
  346. IRQ CCM_AAR_IRQHandler
  347. IRQ WDT_IRQHandler
  348. IRQ RTC1_IRQHandler
  349. IRQ QDEC_IRQHandler
  350. IRQ COMP_IRQHandler
  351. IRQ SWI0_EGU0_IRQHandler
  352. IRQ SWI1_EGU1_IRQHandler
  353. IRQ SWI2_IRQHandler
  354. IRQ SWI3_IRQHandler
  355. IRQ SWI4_IRQHandler
  356. IRQ SWI5_IRQHandler
  357. IRQ PWM0_IRQHandler
  358. IRQ PDM_IRQHandler
  359. .end