arm_startup_nrf9160.s 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. ; Copyright (c) 2009-2018 ARM Limited. All rights reserved.
  2. ;
  3. ; SPDX-License-Identifier: Apache-2.0
  4. ;
  5. ; Licensed under the Apache License, Version 2.0 (the License); you may
  6. ; not use this file except in compliance with the License.
  7. ; You may obtain a copy of the License at
  8. ;
  9. ; www.apache.org/licenses/LICENSE-2.0
  10. ;
  11. ; Unless required by applicable law or agreed to in writing, software
  12. ; distributed under the License is distributed on an AS IS BASIS, WITHOUT
  13. ; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. ; See the License for the specific language governing permissions and
  15. ; limitations under the License.
  16. ;
  17. ; NOTICE: This file has been modified by Nordic Semiconductor ASA.
  18. IF :DEF: __STARTUP_CONFIG
  19. #ifdef __STARTUP_CONFIG
  20. #include "startup_config.h"
  21. #ifndef __STARTUP_CONFIG_STACK_ALIGNEMENT
  22. #define __STARTUP_CONFIG_STACK_ALIGNEMENT 3
  23. #endif
  24. #endif
  25. ENDIF
  26. IF :DEF: __STARTUP_CONFIG
  27. Stack_Size EQU __STARTUP_CONFIG_STACK_SIZE
  28. ELIF :DEF: __STACK_SIZE
  29. Stack_Size EQU __STACK_SIZE
  30. ELSE
  31. Stack_Size EQU 8192
  32. ENDIF
  33. IF :DEF: __STARTUP_CONFIG
  34. Stack_Align EQU __STARTUP_CONFIG_STACK_ALIGNEMENT
  35. ELSE
  36. Stack_Align EQU 3
  37. ENDIF
  38. AREA STACK, NOINIT, READWRITE, ALIGN=Stack_Align
  39. Stack_Mem SPACE Stack_Size
  40. __initial_sp
  41. IF :DEF: __STARTUP_CONFIG
  42. Heap_Size EQU __STARTUP_CONFIG_HEAP_SIZE
  43. ELIF :DEF: __HEAP_SIZE
  44. Heap_Size EQU __HEAP_SIZE
  45. ELSE
  46. Heap_Size EQU 8192
  47. ENDIF
  48. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  49. __heap_base
  50. Heap_Mem SPACE Heap_Size
  51. __heap_limit
  52. PRESERVE8
  53. THUMB
  54. ; Vector Table Mapped to Address 0 at Reset
  55. AREA RESET, DATA, READONLY
  56. EXPORT __Vectors
  57. EXPORT __Vectors_End
  58. EXPORT __Vectors_Size
  59. __Vectors DCD __initial_sp ; Top of Stack
  60. DCD Reset_Handler
  61. DCD NMI_Handler
  62. DCD HardFault_Handler
  63. DCD MemoryManagement_Handler
  64. DCD BusFault_Handler
  65. DCD UsageFault_Handler
  66. DCD SecureFault_Handler
  67. DCD 0 ; Reserved
  68. DCD 0 ; Reserved
  69. DCD 0 ; Reserved
  70. DCD SVC_Handler
  71. DCD DebugMon_Handler
  72. DCD 0 ; Reserved
  73. DCD PendSV_Handler
  74. DCD SysTick_Handler
  75. ; External Interrupts
  76. DCD 0 ; Reserved
  77. DCD 0 ; Reserved
  78. DCD 0 ; Reserved
  79. DCD SPU_IRQHandler
  80. DCD 0 ; Reserved
  81. DCD CLOCK_POWER_IRQHandler
  82. DCD 0 ; Reserved
  83. DCD 0 ; Reserved
  84. DCD UARTE0_SPIM0_SPIS0_TWIM0_TWIS0_IRQHandler
  85. DCD UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQHandler
  86. DCD UARTE2_SPIM2_SPIS2_TWIM2_TWIS2_IRQHandler
  87. DCD UARTE3_SPIM3_SPIS3_TWIM3_TWIS3_IRQHandler
  88. DCD 0 ; Reserved
  89. DCD GPIOTE0_IRQHandler
  90. DCD SAADC_IRQHandler
  91. DCD TIMER0_IRQHandler
  92. DCD TIMER1_IRQHandler
  93. DCD TIMER2_IRQHandler
  94. DCD 0 ; Reserved
  95. DCD 0 ; Reserved
  96. DCD RTC0_IRQHandler
  97. DCD RTC1_IRQHandler
  98. DCD 0 ; Reserved
  99. DCD 0 ; Reserved
  100. DCD WDT_IRQHandler
  101. DCD 0 ; Reserved
  102. DCD 0 ; Reserved
  103. DCD EGU0_IRQHandler
  104. DCD EGU1_IRQHandler
  105. DCD EGU2_IRQHandler
  106. DCD EGU3_IRQHandler
  107. DCD EGU4_IRQHandler
  108. DCD EGU5_IRQHandler
  109. DCD PWM0_IRQHandler
  110. DCD PWM1_IRQHandler
  111. DCD PWM2_IRQHandler
  112. DCD PWM3_IRQHandler
  113. DCD 0 ; Reserved
  114. DCD PDM_IRQHandler
  115. DCD 0 ; Reserved
  116. DCD I2S_IRQHandler
  117. DCD 0 ; Reserved
  118. DCD IPC_IRQHandler
  119. DCD 0 ; Reserved
  120. DCD FPU_IRQHandler
  121. DCD 0 ; Reserved
  122. DCD 0 ; Reserved
  123. DCD 0 ; Reserved
  124. DCD 0 ; Reserved
  125. DCD GPIOTE1_IRQHandler
  126. DCD 0 ; Reserved
  127. DCD 0 ; Reserved
  128. DCD 0 ; Reserved
  129. DCD 0 ; Reserved
  130. DCD 0 ; Reserved
  131. DCD 0 ; Reserved
  132. DCD 0 ; Reserved
  133. DCD KMU_IRQHandler
  134. DCD 0 ; Reserved
  135. DCD 0 ; Reserved
  136. DCD 0 ; Reserved
  137. DCD 0 ; Reserved
  138. DCD 0 ; Reserved
  139. DCD 0 ; Reserved
  140. DCD CRYPTOCELL_IRQHandler
  141. DCD 0 ; Reserved
  142. DCD 0 ; Reserved
  143. DCD 0 ; Reserved
  144. DCD 0 ; Reserved
  145. DCD 0 ; Reserved
  146. DCD 0 ; Reserved
  147. DCD 0 ; Reserved
  148. DCD 0 ; Reserved
  149. DCD 0 ; Reserved
  150. DCD 0 ; Reserved
  151. DCD 0 ; Reserved
  152. DCD 0 ; Reserved
  153. DCD 0 ; Reserved
  154. DCD 0 ; Reserved
  155. DCD 0 ; Reserved
  156. DCD 0 ; Reserved
  157. DCD 0 ; Reserved
  158. DCD 0 ; Reserved
  159. DCD 0 ; Reserved
  160. DCD 0 ; Reserved
  161. DCD 0 ; Reserved
  162. DCD 0 ; Reserved
  163. DCD 0 ; Reserved
  164. DCD 0 ; Reserved
  165. DCD 0 ; Reserved
  166. DCD 0 ; Reserved
  167. DCD 0 ; Reserved
  168. DCD 0 ; Reserved
  169. DCD 0 ; Reserved
  170. DCD 0 ; Reserved
  171. DCD 0 ; Reserved
  172. DCD 0 ; Reserved
  173. DCD 0 ; Reserved
  174. DCD 0 ; Reserved
  175. DCD 0 ; Reserved
  176. DCD 0 ; Reserved
  177. DCD 0 ; Reserved
  178. DCD 0 ; Reserved
  179. DCD 0 ; Reserved
  180. DCD 0 ; Reserved
  181. DCD 0 ; Reserved
  182. DCD 0 ; Reserved
  183. DCD 0 ; Reserved
  184. DCD 0 ; Reserved
  185. DCD 0 ; Reserved
  186. DCD 0 ; Reserved
  187. DCD 0 ; Reserved
  188. DCD 0 ; Reserved
  189. DCD 0 ; Reserved
  190. DCD 0 ; Reserved
  191. DCD 0 ; Reserved
  192. DCD 0 ; Reserved
  193. DCD 0 ; Reserved
  194. DCD 0 ; Reserved
  195. DCD 0 ; Reserved
  196. DCD 0 ; Reserved
  197. DCD 0 ; Reserved
  198. DCD 0 ; Reserved
  199. DCD 0 ; Reserved
  200. DCD 0 ; Reserved
  201. DCD 0 ; Reserved
  202. DCD 0 ; Reserved
  203. DCD 0 ; Reserved
  204. DCD 0 ; Reserved
  205. DCD 0 ; Reserved
  206. DCD 0 ; Reserved
  207. DCD 0 ; Reserved
  208. DCD 0 ; Reserved
  209. DCD 0 ; Reserved
  210. DCD 0 ; Reserved
  211. DCD 0 ; Reserved
  212. DCD 0 ; Reserved
  213. DCD 0 ; Reserved
  214. DCD 0 ; Reserved
  215. DCD 0 ; Reserved
  216. DCD 0 ; Reserved
  217. DCD 0 ; Reserved
  218. DCD 0 ; Reserved
  219. DCD 0 ; Reserved
  220. DCD 0 ; Reserved
  221. DCD 0 ; Reserved
  222. DCD 0 ; Reserved
  223. DCD 0 ; Reserved
  224. DCD 0 ; Reserved
  225. DCD 0 ; Reserved
  226. DCD 0 ; Reserved
  227. DCD 0 ; Reserved
  228. DCD 0 ; Reserved
  229. DCD 0 ; Reserved
  230. DCD 0 ; Reserved
  231. DCD 0 ; Reserved
  232. DCD 0 ; Reserved
  233. DCD 0 ; Reserved
  234. DCD 0 ; Reserved
  235. DCD 0 ; Reserved
  236. DCD 0 ; Reserved
  237. DCD 0 ; Reserved
  238. DCD 0 ; Reserved
  239. DCD 0 ; Reserved
  240. DCD 0 ; Reserved
  241. DCD 0 ; Reserved
  242. DCD 0 ; Reserved
  243. DCD 0 ; Reserved
  244. DCD 0 ; Reserved
  245. DCD 0 ; Reserved
  246. DCD 0 ; Reserved
  247. DCD 0 ; Reserved
  248. DCD 0 ; Reserved
  249. DCD 0 ; Reserved
  250. DCD 0 ; Reserved
  251. DCD 0 ; Reserved
  252. DCD 0 ; Reserved
  253. DCD 0 ; Reserved
  254. DCD 0 ; Reserved
  255. DCD 0 ; Reserved
  256. DCD 0 ; Reserved
  257. DCD 0 ; Reserved
  258. DCD 0 ; Reserved
  259. DCD 0 ; Reserved
  260. DCD 0 ; Reserved
  261. DCD 0 ; Reserved
  262. DCD 0 ; Reserved
  263. DCD 0 ; Reserved
  264. DCD 0 ; Reserved
  265. DCD 0 ; Reserved
  266. DCD 0 ; Reserved
  267. DCD 0 ; Reserved
  268. DCD 0 ; Reserved
  269. DCD 0 ; Reserved
  270. DCD 0 ; Reserved
  271. DCD 0 ; Reserved
  272. DCD 0 ; Reserved
  273. DCD 0 ; Reserved
  274. DCD 0 ; Reserved
  275. DCD 0 ; Reserved
  276. DCD 0 ; Reserved
  277. DCD 0 ; Reserved
  278. DCD 0 ; Reserved
  279. DCD 0 ; Reserved
  280. DCD 0 ; Reserved
  281. DCD 0 ; Reserved
  282. DCD 0 ; Reserved
  283. DCD 0 ; Reserved
  284. DCD 0 ; Reserved
  285. DCD 0 ; Reserved
  286. DCD 0 ; Reserved
  287. DCD 0 ; Reserved
  288. DCD 0 ; Reserved
  289. DCD 0 ; Reserved
  290. DCD 0 ; Reserved
  291. DCD 0 ; Reserved
  292. DCD 0 ; Reserved
  293. DCD 0 ; Reserved
  294. DCD 0 ; Reserved
  295. DCD 0 ; Reserved
  296. DCD 0 ; Reserved
  297. DCD 0 ; Reserved
  298. DCD 0 ; Reserved
  299. DCD 0 ; Reserved
  300. DCD 0 ; Reserved
  301. DCD 0 ; Reserved
  302. DCD 0 ; Reserved
  303. DCD 0 ; Reserved
  304. DCD 0 ; Reserved
  305. DCD 0 ; Reserved
  306. DCD 0 ; Reserved
  307. DCD 0 ; Reserved
  308. DCD 0 ; Reserved
  309. DCD 0 ; Reserved
  310. DCD 0 ; Reserved
  311. DCD 0 ; Reserved
  312. DCD 0 ; Reserved
  313. DCD 0 ; Reserved
  314. DCD 0 ; Reserved
  315. DCD 0 ; Reserved
  316. __Vectors_End
  317. __Vectors_Size EQU __Vectors_End - __Vectors
  318. AREA |.text|, CODE, READONLY
  319. ; Reset Handler
  320. Reset_Handler PROC
  321. EXPORT Reset_Handler [WEAK]
  322. IMPORT SystemInit
  323. IMPORT __main
  324. LDR R0, =SystemInit
  325. BLX R0
  326. LDR R0, =__main
  327. BX R0
  328. ENDP
  329. ; Dummy Exception Handlers (infinite loops which can be modified)
  330. NMI_Handler PROC
  331. EXPORT NMI_Handler [WEAK]
  332. B .
  333. ENDP
  334. HardFault_Handler\
  335. PROC
  336. EXPORT HardFault_Handler [WEAK]
  337. B .
  338. ENDP
  339. MemoryManagement_Handler\
  340. PROC
  341. EXPORT MemoryManagement_Handler [WEAK]
  342. B .
  343. ENDP
  344. BusFault_Handler\
  345. PROC
  346. EXPORT BusFault_Handler [WEAK]
  347. B .
  348. ENDP
  349. UsageFault_Handler\
  350. PROC
  351. EXPORT UsageFault_Handler [WEAK]
  352. B .
  353. ENDP
  354. SecureFault_Handler\
  355. PROC
  356. EXPORT SecureFault_Handler [WEAK]
  357. B .
  358. ENDP
  359. SVC_Handler PROC
  360. EXPORT SVC_Handler [WEAK]
  361. B .
  362. ENDP
  363. DebugMon_Handler\
  364. PROC
  365. EXPORT DebugMon_Handler [WEAK]
  366. B .
  367. ENDP
  368. PendSV_Handler PROC
  369. EXPORT PendSV_Handler [WEAK]
  370. B .
  371. ENDP
  372. SysTick_Handler PROC
  373. EXPORT SysTick_Handler [WEAK]
  374. B .
  375. ENDP
  376. Default_Handler PROC
  377. EXPORT SPU_IRQHandler [WEAK]
  378. EXPORT CLOCK_POWER_IRQHandler [WEAK]
  379. EXPORT UARTE0_SPIM0_SPIS0_TWIM0_TWIS0_IRQHandler [WEAK]
  380. EXPORT UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQHandler [WEAK]
  381. EXPORT UARTE2_SPIM2_SPIS2_TWIM2_TWIS2_IRQHandler [WEAK]
  382. EXPORT UARTE3_SPIM3_SPIS3_TWIM3_TWIS3_IRQHandler [WEAK]
  383. EXPORT GPIOTE0_IRQHandler [WEAK]
  384. EXPORT SAADC_IRQHandler [WEAK]
  385. EXPORT TIMER0_IRQHandler [WEAK]
  386. EXPORT TIMER1_IRQHandler [WEAK]
  387. EXPORT TIMER2_IRQHandler [WEAK]
  388. EXPORT RTC0_IRQHandler [WEAK]
  389. EXPORT RTC1_IRQHandler [WEAK]
  390. EXPORT WDT_IRQHandler [WEAK]
  391. EXPORT EGU0_IRQHandler [WEAK]
  392. EXPORT EGU1_IRQHandler [WEAK]
  393. EXPORT EGU2_IRQHandler [WEAK]
  394. EXPORT EGU3_IRQHandler [WEAK]
  395. EXPORT EGU4_IRQHandler [WEAK]
  396. EXPORT EGU5_IRQHandler [WEAK]
  397. EXPORT PWM0_IRQHandler [WEAK]
  398. EXPORT PWM1_IRQHandler [WEAK]
  399. EXPORT PWM2_IRQHandler [WEAK]
  400. EXPORT PWM3_IRQHandler [WEAK]
  401. EXPORT PDM_IRQHandler [WEAK]
  402. EXPORT I2S_IRQHandler [WEAK]
  403. EXPORT IPC_IRQHandler [WEAK]
  404. EXPORT FPU_IRQHandler [WEAK]
  405. EXPORT GPIOTE1_IRQHandler [WEAK]
  406. EXPORT KMU_IRQHandler [WEAK]
  407. EXPORT CRYPTOCELL_IRQHandler [WEAK]
  408. SPU_IRQHandler
  409. CLOCK_POWER_IRQHandler
  410. UARTE0_SPIM0_SPIS0_TWIM0_TWIS0_IRQHandler
  411. UARTE1_SPIM1_SPIS1_TWIM1_TWIS1_IRQHandler
  412. UARTE2_SPIM2_SPIS2_TWIM2_TWIS2_IRQHandler
  413. UARTE3_SPIM3_SPIS3_TWIM3_TWIS3_IRQHandler
  414. GPIOTE0_IRQHandler
  415. SAADC_IRQHandler
  416. TIMER0_IRQHandler
  417. TIMER1_IRQHandler
  418. TIMER2_IRQHandler
  419. RTC0_IRQHandler
  420. RTC1_IRQHandler
  421. WDT_IRQHandler
  422. EGU0_IRQHandler
  423. EGU1_IRQHandler
  424. EGU2_IRQHandler
  425. EGU3_IRQHandler
  426. EGU4_IRQHandler
  427. EGU5_IRQHandler
  428. PWM0_IRQHandler
  429. PWM1_IRQHandler
  430. PWM2_IRQHandler
  431. PWM3_IRQHandler
  432. PDM_IRQHandler
  433. I2S_IRQHandler
  434. IPC_IRQHandler
  435. FPU_IRQHandler
  436. GPIOTE1_IRQHandler
  437. KMU_IRQHandler
  438. CRYPTOCELL_IRQHandler
  439. B .
  440. ENDP
  441. ALIGN
  442. ; User Initial Stack & Heap
  443. IF :DEF:__MICROLIB
  444. EXPORT __initial_sp
  445. EXPORT __heap_base
  446. EXPORT __heap_limit
  447. ELSE
  448. IMPORT __use_two_region_memory
  449. EXPORT __user_initial_stackheap
  450. __user_initial_stackheap PROC
  451. LDR R0, = Heap_Mem
  452. LDR R1, = (Stack_Mem + Stack_Size)
  453. LDR R2, = (Heap_Mem + Heap_Size)
  454. LDR R3, = Stack_Mem
  455. BX LR
  456. ENDP
  457. ALIGN
  458. ENDIF
  459. END