gcc_startup_nrf5340_application.S 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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 armv8-m.main
  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, 16384
  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, 16384
  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 SecureFault_Handler
  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 FPU_IRQHandler
  81. .long CACHE_IRQHandler
  82. .long 0 /*Reserved */
  83. .long SPU_IRQHandler
  84. .long 0 /*Reserved */
  85. .long CLOCK_POWER_IRQHandler
  86. .long 0 /*Reserved */
  87. .long 0 /*Reserved */
  88. .long SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
  89. .long SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
  90. .long SPIM4_IRQHandler
  91. .long SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
  92. .long SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
  93. .long GPIOTE0_IRQHandler
  94. .long SAADC_IRQHandler
  95. .long TIMER0_IRQHandler
  96. .long TIMER1_IRQHandler
  97. .long TIMER2_IRQHandler
  98. .long 0 /*Reserved */
  99. .long 0 /*Reserved */
  100. .long RTC0_IRQHandler
  101. .long RTC1_IRQHandler
  102. .long 0 /*Reserved */
  103. .long 0 /*Reserved */
  104. .long WDT0_IRQHandler
  105. .long WDT1_IRQHandler
  106. .long COMP_LPCOMP_IRQHandler
  107. .long EGU0_IRQHandler
  108. .long EGU1_IRQHandler
  109. .long EGU2_IRQHandler
  110. .long EGU3_IRQHandler
  111. .long EGU4_IRQHandler
  112. .long EGU5_IRQHandler
  113. .long PWM0_IRQHandler
  114. .long PWM1_IRQHandler
  115. .long PWM2_IRQHandler
  116. .long PWM3_IRQHandler
  117. .long 0 /*Reserved */
  118. .long PDM0_IRQHandler
  119. .long 0 /*Reserved */
  120. .long I2S0_IRQHandler
  121. .long 0 /*Reserved */
  122. .long IPC_IRQHandler
  123. .long QSPI_IRQHandler
  124. .long 0 /*Reserved */
  125. .long NFCT_IRQHandler
  126. .long 0 /*Reserved */
  127. .long GPIOTE1_IRQHandler
  128. .long 0 /*Reserved */
  129. .long 0 /*Reserved */
  130. .long 0 /*Reserved */
  131. .long QDEC0_IRQHandler
  132. .long QDEC1_IRQHandler
  133. .long 0 /*Reserved */
  134. .long USBD_IRQHandler
  135. .long USBREGULATOR_IRQHandler
  136. .long 0 /*Reserved */
  137. .long KMU_IRQHandler
  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 CRYPTOCELL_IRQHandler
  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. .long 0 /*Reserved */
  193. .long 0 /*Reserved */
  194. .long 0 /*Reserved */
  195. .long 0 /*Reserved */
  196. .long 0 /*Reserved */
  197. .long 0 /*Reserved */
  198. .long 0 /*Reserved */
  199. .long 0 /*Reserved */
  200. .long 0 /*Reserved */
  201. .long 0 /*Reserved */
  202. .long 0 /*Reserved */
  203. .long 0 /*Reserved */
  204. .long 0 /*Reserved */
  205. .long 0 /*Reserved */
  206. .long 0 /*Reserved */
  207. .long 0 /*Reserved */
  208. .long 0 /*Reserved */
  209. .long 0 /*Reserved */
  210. .long 0 /*Reserved */
  211. .long 0 /*Reserved */
  212. .long 0 /*Reserved */
  213. .long 0 /*Reserved */
  214. .long 0 /*Reserved */
  215. .long 0 /*Reserved */
  216. .long 0 /*Reserved */
  217. .long 0 /*Reserved */
  218. .long 0 /*Reserved */
  219. .long 0 /*Reserved */
  220. .long 0 /*Reserved */
  221. .long 0 /*Reserved */
  222. .long 0 /*Reserved */
  223. .long 0 /*Reserved */
  224. .long 0 /*Reserved */
  225. .long 0 /*Reserved */
  226. .long 0 /*Reserved */
  227. .long 0 /*Reserved */
  228. .long 0 /*Reserved */
  229. .long 0 /*Reserved */
  230. .long 0 /*Reserved */
  231. .long 0 /*Reserved */
  232. .long 0 /*Reserved */
  233. .long 0 /*Reserved */
  234. .long 0 /*Reserved */
  235. .long 0 /*Reserved */
  236. .long 0 /*Reserved */
  237. .long 0 /*Reserved */
  238. .long 0 /*Reserved */
  239. .long 0 /*Reserved */
  240. .long 0 /*Reserved */
  241. .long 0 /*Reserved */
  242. .long 0 /*Reserved */
  243. .long 0 /*Reserved */
  244. .long 0 /*Reserved */
  245. .long 0 /*Reserved */
  246. .long 0 /*Reserved */
  247. .long 0 /*Reserved */
  248. .long 0 /*Reserved */
  249. .long 0 /*Reserved */
  250. .long 0 /*Reserved */
  251. .long 0 /*Reserved */
  252. .long 0 /*Reserved */
  253. .long 0 /*Reserved */
  254. .long 0 /*Reserved */
  255. .long 0 /*Reserved */
  256. .long 0 /*Reserved */
  257. .long 0 /*Reserved */
  258. .long 0 /*Reserved */
  259. .long 0 /*Reserved */
  260. .long 0 /*Reserved */
  261. .long 0 /*Reserved */
  262. .long 0 /*Reserved */
  263. .long 0 /*Reserved */
  264. .long 0 /*Reserved */
  265. .long 0 /*Reserved */
  266. .long 0 /*Reserved */
  267. .long 0 /*Reserved */
  268. .long 0 /*Reserved */
  269. .long 0 /*Reserved */
  270. .long 0 /*Reserved */
  271. .long 0 /*Reserved */
  272. .long 0 /*Reserved */
  273. .long 0 /*Reserved */
  274. .long 0 /*Reserved */
  275. .long 0 /*Reserved */
  276. .long 0 /*Reserved */
  277. .long 0 /*Reserved */
  278. .long 0 /*Reserved */
  279. .long 0 /*Reserved */
  280. .long 0 /*Reserved */
  281. .long 0 /*Reserved */
  282. .long 0 /*Reserved */
  283. .long 0 /*Reserved */
  284. .long 0 /*Reserved */
  285. .long 0 /*Reserved */
  286. .long 0 /*Reserved */
  287. .long 0 /*Reserved */
  288. .long 0 /*Reserved */
  289. .long 0 /*Reserved */
  290. .long 0 /*Reserved */
  291. .long 0 /*Reserved */
  292. .long 0 /*Reserved */
  293. .long 0 /*Reserved */
  294. .long 0 /*Reserved */
  295. .long 0 /*Reserved */
  296. .long 0 /*Reserved */
  297. .long 0 /*Reserved */
  298. .long 0 /*Reserved */
  299. .long 0 /*Reserved */
  300. .long 0 /*Reserved */
  301. .long 0 /*Reserved */
  302. .long 0 /*Reserved */
  303. .long 0 /*Reserved */
  304. .long 0 /*Reserved */
  305. .long 0 /*Reserved */
  306. .long 0 /*Reserved */
  307. .long 0 /*Reserved */
  308. .long 0 /*Reserved */
  309. .long 0 /*Reserved */
  310. .long 0 /*Reserved */
  311. .long 0 /*Reserved */
  312. .long 0 /*Reserved */
  313. .long 0 /*Reserved */
  314. .long 0 /*Reserved */
  315. .long 0 /*Reserved */
  316. .long 0 /*Reserved */
  317. .long 0 /*Reserved */
  318. .long 0 /*Reserved */
  319. .long 0 /*Reserved */
  320. .size __isr_vector, . - __isr_vector
  321. /* Reset Handler */
  322. .text
  323. .thumb
  324. .thumb_func
  325. .align 1
  326. .globl Reset_Handler
  327. .type Reset_Handler, %function
  328. Reset_Handler:
  329. /* Loop to copy data from read only memory to RAM.
  330. * The ranges of copy from/to are specified by following symbols:
  331. * __etext: LMA of start of the section to copy from. Usually end of text
  332. * __data_start__: VMA of start of the section to copy to.
  333. * __bss_start__: VMA of end of the section to copy to. Normally __data_end__ is used, but by using __bss_start__
  334. * the user can add their own initialized data section before BSS section with the INSERT AFTER command.
  335. *
  336. * All addresses must be aligned to 4 bytes boundary.
  337. */
  338. #ifndef __STARTUP_SKIP_ETEXT
  339. ldr r1, =__etext
  340. ldr r2, =__data_start__
  341. ldr r3, =__bss_start__
  342. subs r3, r3, r2
  343. ble .L_loop1_done
  344. .L_loop1:
  345. subs r3, r3, #4
  346. ldr r0, [r1,r3]
  347. str r0, [r2,r3]
  348. bgt .L_loop1
  349. .L_loop1_done:
  350. #endif
  351. /* This part of work usually is done in C library startup code. Otherwise,
  352. * define __STARTUP_CLEAR_BSS to enable it in this startup. This section
  353. * clears the RAM where BSS data is located.
  354. *
  355. * The BSS section is specified by following symbols
  356. * __bss_start__: start of the BSS section.
  357. * __bss_end__: end of the BSS section.
  358. *
  359. * All addresses must be aligned to 4 bytes boundary.
  360. */
  361. #ifdef __STARTUP_CLEAR_BSS
  362. ldr r1, =__bss_start__
  363. ldr r2, =__bss_end__
  364. movs r0, 0
  365. subs r2, r2, r1
  366. ble .L_loop3_done
  367. .L_loop3:
  368. subs r2, r2, #4
  369. str r0, [r1, r2]
  370. bgt .L_loop3
  371. .L_loop3_done:
  372. #endif /* __STARTUP_CLEAR_BSS */
  373. /* Execute SystemInit function. */
  374. bl SystemInit
  375. /* Call _start function provided by libraries.
  376. * If those libraries are not accessible, define __START as your entry point.
  377. */
  378. #ifndef __START
  379. #define __START _start
  380. #endif
  381. bl __START
  382. .pool
  383. .size Reset_Handler,.-Reset_Handler
  384. .section ".text"
  385. /* Dummy Exception Handlers (infinite loops which can be modified) */
  386. .weak NMI_Handler
  387. .type NMI_Handler, %function
  388. NMI_Handler:
  389. b .
  390. .size NMI_Handler, . - NMI_Handler
  391. .weak HardFault_Handler
  392. .type HardFault_Handler, %function
  393. HardFault_Handler:
  394. b .
  395. .size HardFault_Handler, . - HardFault_Handler
  396. .weak MemoryManagement_Handler
  397. .type MemoryManagement_Handler, %function
  398. MemoryManagement_Handler:
  399. b .
  400. .size MemoryManagement_Handler, . - MemoryManagement_Handler
  401. .weak BusFault_Handler
  402. .type BusFault_Handler, %function
  403. BusFault_Handler:
  404. b .
  405. .size BusFault_Handler, . - BusFault_Handler
  406. .weak UsageFault_Handler
  407. .type UsageFault_Handler, %function
  408. UsageFault_Handler:
  409. b .
  410. .size UsageFault_Handler, . - UsageFault_Handler
  411. .weak SecureFault_Handler
  412. .type SecureFault_Handler, %function
  413. SecureFault_Handler:
  414. b .
  415. .size SecureFault_Handler, . - SecureFault_Handler
  416. .weak SVC_Handler
  417. .type SVC_Handler, %function
  418. SVC_Handler:
  419. b .
  420. .size SVC_Handler, . - SVC_Handler
  421. .weak DebugMon_Handler
  422. .type DebugMon_Handler, %function
  423. DebugMon_Handler:
  424. b .
  425. .size DebugMon_Handler, . - DebugMon_Handler
  426. .weak PendSV_Handler
  427. .type PendSV_Handler, %function
  428. PendSV_Handler:
  429. b .
  430. .size PendSV_Handler, . - PendSV_Handler
  431. .weak SysTick_Handler
  432. .type SysTick_Handler, %function
  433. SysTick_Handler:
  434. b .
  435. .size SysTick_Handler, . - SysTick_Handler
  436. /* IRQ Handlers */
  437. .globl Default_Handler
  438. .type Default_Handler, %function
  439. Default_Handler:
  440. b .
  441. .size Default_Handler, . - Default_Handler
  442. .macro IRQ handler
  443. .weak \handler
  444. .set \handler, Default_Handler
  445. .endm
  446. IRQ FPU_IRQHandler
  447. IRQ CACHE_IRQHandler
  448. IRQ SPU_IRQHandler
  449. IRQ CLOCK_POWER_IRQHandler
  450. IRQ SPIM0_SPIS0_TWIM0_TWIS0_UARTE0_IRQHandler
  451. IRQ SPIM1_SPIS1_TWIM1_TWIS1_UARTE1_IRQHandler
  452. IRQ SPIM4_IRQHandler
  453. IRQ SPIM2_SPIS2_TWIM2_TWIS2_UARTE2_IRQHandler
  454. IRQ SPIM3_SPIS3_TWIM3_TWIS3_UARTE3_IRQHandler
  455. IRQ GPIOTE0_IRQHandler
  456. IRQ SAADC_IRQHandler
  457. IRQ TIMER0_IRQHandler
  458. IRQ TIMER1_IRQHandler
  459. IRQ TIMER2_IRQHandler
  460. IRQ RTC0_IRQHandler
  461. IRQ RTC1_IRQHandler
  462. IRQ WDT0_IRQHandler
  463. IRQ WDT1_IRQHandler
  464. IRQ COMP_LPCOMP_IRQHandler
  465. IRQ EGU0_IRQHandler
  466. IRQ EGU1_IRQHandler
  467. IRQ EGU2_IRQHandler
  468. IRQ EGU3_IRQHandler
  469. IRQ EGU4_IRQHandler
  470. IRQ EGU5_IRQHandler
  471. IRQ PWM0_IRQHandler
  472. IRQ PWM1_IRQHandler
  473. IRQ PWM2_IRQHandler
  474. IRQ PWM3_IRQHandler
  475. IRQ PDM0_IRQHandler
  476. IRQ I2S0_IRQHandler
  477. IRQ IPC_IRQHandler
  478. IRQ QSPI_IRQHandler
  479. IRQ NFCT_IRQHandler
  480. IRQ GPIOTE1_IRQHandler
  481. IRQ QDEC0_IRQHandler
  482. IRQ QDEC1_IRQHandler
  483. IRQ USBD_IRQHandler
  484. IRQ USBREGULATOR_IRQHandler
  485. IRQ KMU_IRQHandler
  486. IRQ CRYPTOCELL_IRQHandler
  487. .end