startup_m2sxxx.S 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. /*******************************************************************************
  2. * (c) Copyright 2012-2015 Microsemi SoC Products Group. All rights reserved.
  3. *
  4. * @file startup_m2sxxx.S
  5. * @author Microsemi SoC Products Group
  6. * @brief SmartFusion2 vector table and startup code for CodeSourcery G++.
  7. *
  8. * SVN $Revision: 7424 $
  9. * SVN $Date: 2015-05-19 21:16:09 +0530 (Tue, 19 May 2015) $
  10. */
  11. .syntax unified
  12. .cpu cortex-m3
  13. .thumb
  14. /* #define UNIT_TEST_FILL_MEMORY only uncommented if carring out unit test */
  15. /*==============================================================================
  16. * Vector table
  17. */
  18. .global g_pfnVectors
  19. .section .isr_vector,"ax",%progbits /* added "x" so appears in .lst file even though not executable code- to help in debug process */
  20. .type g_pfnVectors, %object
  21. .size g_pfnVectors, .-g_pfnVectors
  22. g_pfnVectors:
  23. .word _estack
  24. .word Reset_Handler
  25. .word NMI_Handler
  26. .word HardFault_Handler
  27. .word MemManage_Handler
  28. .word BusFault_Handler
  29. .word UsageFault_Handler
  30. .word 0
  31. .word 0
  32. .word 0
  33. .word 0
  34. .word SVC_Handler
  35. .word DebugMon_Handler
  36. .word 0
  37. .word PendSV_Handler
  38. .word SysTick_Handler
  39. .word WdogWakeup_IRQHandler
  40. .word RTC_Wakeup_IRQHandler
  41. .word SPI0_IRQHandler
  42. .word SPI1_IRQHandler
  43. .word I2C0_IRQHandler
  44. .word I2C0_SMBAlert_IRQHandler
  45. .word I2C0_SMBus_IRQHandler
  46. .word I2C1_IRQHandler
  47. .word I2C1_SMBAlert_IRQHandler
  48. .word I2C1_SMBus_IRQHandler
  49. .word UART0_IRQHandler
  50. .word UART1_IRQHandler
  51. .word EthernetMAC_IRQHandler
  52. .word DMA_IRQHandler
  53. .word Timer1_IRQHandler
  54. .word Timer2_IRQHandler
  55. .word CAN_IRQHandler
  56. .word ENVM0_IRQHandler
  57. .word ENVM1_IRQHandler
  58. .word ComBlk_IRQHandler
  59. .word USB_IRQHandler
  60. .word USB_DMA_IRQHandler
  61. .word PLL_Lock_IRQHandler
  62. .word PLL_LockLost_IRQHandler
  63. .word CommSwitchError_IRQHandler
  64. .word CacheError_IRQHandler
  65. .word DDR_IRQHandler
  66. .word HPDMA_Complete_IRQHandler
  67. .word HPDMA_Error_IRQHandler
  68. .word ECC_Error_IRQHandler
  69. .word MDDR_IOCalib_IRQHandler
  70. .word FAB_PLL_Lock_IRQHandler
  71. .word FAB_PLL_LockLost_IRQHandler
  72. .word FIC64_IRQHandler
  73. .word FabricIrq0_IRQHandler
  74. .word FabricIrq1_IRQHandler
  75. .word FabricIrq2_IRQHandler
  76. .word FabricIrq3_IRQHandler
  77. .word FabricIrq4_IRQHandler
  78. .word FabricIrq5_IRQHandler
  79. .word FabricIrq6_IRQHandler
  80. .word FabricIrq7_IRQHandler
  81. .word FabricIrq8_IRQHandler
  82. .word FabricIrq9_IRQHandler
  83. .word FabricIrq10_IRQHandler
  84. .word FabricIrq11_IRQHandler
  85. .word FabricIrq12_IRQHandler
  86. .word FabricIrq13_IRQHandler
  87. .word FabricIrq14_IRQHandler
  88. .word FabricIrq15_IRQHandler
  89. .word GPIO0_IRQHandler
  90. .word GPIO1_IRQHandler
  91. .word GPIO2_IRQHandler
  92. .word GPIO3_IRQHandler
  93. .word GPIO4_IRQHandler
  94. .word GPIO5_IRQHandler
  95. .word GPIO6_IRQHandler
  96. .word GPIO7_IRQHandler
  97. .word GPIO8_IRQHandler
  98. .word GPIO9_IRQHandler
  99. .word GPIO10_IRQHandler
  100. .word GPIO11_IRQHandler
  101. .word GPIO12_IRQHandler
  102. .word GPIO13_IRQHandler
  103. .word GPIO14_IRQHandler
  104. .word GPIO15_IRQHandler
  105. .word GPIO16_IRQHandler
  106. .word GPIO17_IRQHandler
  107. .word GPIO18_IRQHandler
  108. .word GPIO19_IRQHandler
  109. .word GPIO20_IRQHandler
  110. .word GPIO21_IRQHandler
  111. .word GPIO22_IRQHandler
  112. .word GPIO23_IRQHandler
  113. .word GPIO24_IRQHandler
  114. .word GPIO25_IRQHandler
  115. .word GPIO26_IRQHandler
  116. .word GPIO27_IRQHandler
  117. .word GPIO28_IRQHandler
  118. .word GPIO29_IRQHandler
  119. .word GPIO30_IRQHandler
  120. .word GPIO31_IRQHandler
  121. .word 0
  122. .word 0
  123. /*==============================================================================
  124. * Reset_Handler
  125. * Register r11 is used to keep track of whether we need to initialize RAMs
  126. * because ECC/ SECDED is enabled.
  127. */
  128. .global Reset_Handler
  129. .section .boot_code,"ax",%progbits
  130. .type Reset_Handler, %function
  131. Reset_Handler:
  132. _start:
  133. /*------------------------------------------------------------------------------
  134. * Initialize stack RAM content to initialize the error detection and correction
  135. * (EDAC). This is done if EDAC is enabled for the eSRAM blocks or the
  136. * ECC/SECDED is enabled for the MDDR.
  137. * Register r11 is used to keep track of the RAM intialization decision outcome
  138. * for later use for heap RAM initialization at the end of the startup code.
  139. * Please note that the stack has to be located in eSRAM at this point and
  140. * cannot be located in MDDR since MDDR is not available at this point.
  141. * The bits of the content of register r11 have the following meaning:
  142. * reg11[0]: eSRAM EDAC enabled
  143. * reg11[1]: MDDR ECC/SECDED enabled
  144. */
  145. mov r11, #0
  146. ldr r0, SF2_MDDR_MODE_CR
  147. ldr r0, [r0]
  148. ldr r1, SF2_EDAC_CR
  149. ldr r1, [r1]
  150. and r1, r1, #3
  151. and r0, r0, #0x1C
  152. cmp r0, #0x14
  153. bne check_esram_edac
  154. orr r11, r11, #2
  155. check_esram_edac:
  156. cmp r1, #0
  157. beq check_stack_init
  158. orr r11, r11, #1
  159. check_stack_init:
  160. cmp r11, #0
  161. beq system_init
  162. clear_stack:
  163. ldr r0, = __stack_start__
  164. ldr r1, =_estack
  165. ldr r2, RAM_INIT_PATTERN
  166. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments uses r4, r5, r6, r7, r8, r9, and does not preserve contents */
  167. /*------------------------------------------------------------------------------
  168. * Call CMSIS system init function.
  169. */
  170. system_init:
  171. ldr r0, =SystemInit
  172. blx r0
  173. /*------------------------------------------------------------------------------
  174. * Modify MDDR configuration if ECC/SECDED is enabled for MDDR.
  175. * Enable write combining on MDDR bridge, disable non-bufferable regions.
  176. */
  177. and r10, r11, 0x2
  178. cmp r10, #0
  179. beq remap_memory
  180. ldr r0, SF2_DDRB_NB_SIZE
  181. ldr r1, SF2_DDRB_CR
  182. ldr r2, [r0]
  183. ldr r3, [r1]
  184. push {r0, r1, r2, r3}
  185. mov r2, #0
  186. mov r3, #0xFF
  187. str r2, [r0]
  188. str r3, [r1]
  189. /*------------------------------------------------------------------------------
  190. * Perform memory remapping based on the value of __smartfusion2_memory_remap
  191. * set in the linker script.
  192. */
  193. remap_memory:
  194. ldr r0, =__smartfusion2_memory_remap
  195. ldr r2, =0
  196. ldr r3, =1
  197. cmp r0, #2
  198. bne check_esram_remap
  199. /*
  200. * Remap external RAM to address 0x00000000
  201. */
  202. ldr r1, SF2_ESRAM_CR
  203. str r2, [r1]
  204. ldr r1, SF2_ENVM_REMAP_CR
  205. str r2, [r1]
  206. ldr r1, SF2_DDR_CR
  207. str r3, [r1]
  208. check_esram_remap:
  209. cmp r0, #1
  210. bne check_mirrored_nvm
  211. /*
  212. * Remap internal eSRAM to address 0x00000000
  213. */
  214. ldr r1, SF2_DDR_CR
  215. str r2, [r1]
  216. ldr r1, SF2_ENVM_REMAP_CR
  217. str r2, [r1]
  218. ldr r1, SF2_ESRAM_CR
  219. str r3, [r1]
  220. /*------------------------------------------------------------------------------
  221. * Check if the executable is built for NVM LMA mirrored to VMA address.
  222. * This is done for debugging executables running out of eNVM with SoftConsole.
  223. * The .text section should not be copied in this case since both the LMA and
  224. * VMA point at the eNVM despite the LMA and VMa having different values.
  225. */
  226. check_mirrored_nvm:
  227. ldr r0, =__mirrored_nvm
  228. cmp r0, #0
  229. bne copy_data
  230. /*------------------------------------------------------------------------------
  231. * Copy vector table.
  232. */
  233. ldr r0, =__vector_table_load
  234. ldr r1, =__vector_table_start
  235. ldr r2, =_evector_table
  236. bl block_copy
  237. /*------------------------------------------------------------------------------
  238. * Copy code section.
  239. */
  240. copy_text:
  241. ldr r0, =__text_load
  242. ldr r1, =__text_start
  243. ldr r2, =_etext
  244. bl block_copy
  245. /*------------------------------------------------------------------------------
  246. * Copy data section.
  247. */
  248. copy_data:
  249. ldr r0, =__data_load
  250. ldr r1, =__data_start
  251. ldr r2, =_edata
  252. bl block_copy
  253. /*------------------------------------------------------------------------------
  254. * Clear .bss
  255. */
  256. clear_bss:
  257. ldr r0, =__bss_start__
  258. ldr r1, =__bss_end__
  259. ldr r2, RAM_INIT_PATTERN
  260. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments uses r4, r5, r6, r7, r8, r9, and does not preserve contents */
  261. #ifdef UNIT_TEST_FILL_MEMORY
  262. bl unit_test_fill_memory
  263. #endif
  264. /*------------------------------------------------------------------------------
  265. * Initialize heap RAM content to initialize the error detection and correction
  266. * (EDAC). We use the decision made earlier in the startup code of whether or
  267. * not the stack RAM should be initialized. This decision is held in register
  268. * r11. A non-zero value indicates that the RAM content should be initialized.
  269. */
  270. clear_heap:
  271. cmp r11, #0
  272. beq call_glob_ctor
  273. ldr r0, =__heap_start__
  274. ldr r1, =_eheap
  275. ldr r2, HEAP_INIT_PATTERN
  276. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments uses r4, r5, r6, r7, r8, r9, and does not preserve contents */
  277. /*------------------------------------------------------------------------------
  278. * Restore MDDR configuration.
  279. */
  280. and r10, r11, 0x2
  281. cmp r10, #0
  282. beq call_glob_ctor
  283. pop {r0, r1, r2, r3}
  284. str r2, [r0]
  285. str r3, [r1]
  286. /*------------------------------------------------------------------------------
  287. * Call global constructors
  288. */
  289. /*
  290. * Align to word and use 32-bits LDR instruction to ensure the ADD instruction
  291. * taking PC as argument is aligned on a word boundary.
  292. */
  293. .align 4
  294. call_glob_ctor:
  295. ldr.w r0, =__libc_init_array
  296. add lr, pc, #3
  297. bx r0
  298. /*------------------------------------------------------------------------------
  299. * branch to main.
  300. */
  301. branch_to_main:
  302. mov r0, #0 /* ; no arguments */
  303. mov r1, #0 /* ; no argv either */
  304. ldr pc, =main
  305. ExitLoop:
  306. B ExitLoop
  307. /*------------------------------------------------------------------------------
  308. * block copy.
  309. *
  310. * r0: source address
  311. * r1: target address
  312. * r2: end target address
  313. *
  314. * note: Most efficient if memory aligned. Linker ALIGN(16) command
  315. * should be used as per example linker scripts.
  316. * Note 1: If the memory address in r0 or r1, byte copy routine is used
  317. * Note 2: If r1 < r2, will loop indefinetley to highlight linker issue.
  318. */
  319. block_copy:
  320. push {r3, r4, r5, r6, r7, r8, lr}
  321. cmp r0, r1
  322. beq block_copy_exit /* ; Exit early if source and destination the same */
  323. subs.w r2, r2, r1 /* ; Calculate number of bytes to move */
  324. bpl block_copy_address_ok /* ; check (end target address) > (target address) => continue */
  325. b . /* ; halt as critical error- memory map not OK- make it easy to catch in debugger */
  326. block_copy_address_ok:
  327. /* ; detect if source or target memory addresses unaligned. If so use byte copy routine */
  328. orr.w r3, r0, r1
  329. ands.w r3, r3, #3
  330. beq block_copy_continue
  331. block_copy_byte_copy:
  332. bl block_copy_byte
  333. b block_copy_exit
  334. block_copy_continue:
  335. mov r3, #0
  336. mov r8,r2 /* ; Save copy of byte count */
  337. asrs r2,r2, #4 /* ; Div by 16 to get number of chunks to move */
  338. beq block_copy_byte_copy /* ; need to use byte copy if less than 16 bytes */
  339. block_copy_loop:
  340. cmp r2, r3
  341. itt ne
  342. ldmne r0!, {r4, r5, r6, r7}
  343. stmne r1!, {r4, r5, r6, r7}
  344. add.w r3, r3, #1 /* ; use Thumb2- make sure condition code reg. not updated */
  345. bne block_copy_loop
  346. /* ; copy spare bytes at the end if any */
  347. and r8, #15 /* ; get spare bytes --check can you do an ands? */
  348. cmp r8, #0 /* ; no spare bytes at end- end now */
  349. beq block_copy_exit
  350. copy_spare_bytes: /* ; From above, R0 contains source address, R1 contains destination address */
  351. ldrb r4, [r0]
  352. strb r4, [r1]
  353. add r0, #1
  354. add r1, #1
  355. subs r8, r8, #1
  356. bne copy_spare_bytes
  357. block_copy_exit:
  358. pop {r3, r4, r5, r6, r7, r8, pc}
  359. /*
  360. * block_copy_byte: used if memory not aligned
  361. * r0: source address
  362. * r1: target address
  363. * r2: number of bytes
  364. */
  365. block_copy_byte:
  366. push {r3, lr}
  367. mov r3, #0
  368. block_copy_byte_loop: /* ; From above, R0 contains source address, R1 contains destination address */
  369. ldrb r3, [r0]
  370. strb r3, [r1]
  371. add r0, #1
  372. add r1, #1
  373. subs r2, r2, #1
  374. bne block_copy_byte_loop
  375. pop {r3, pc}
  376. /*;------------------------------------------------------------------------------
  377. ; * fill_memory.
  378. ; * @brief Fills memory with Pattern contained in r2
  379. ; * This routine uses the stmne instruction to copy 4 words at a time which is very efficient
  380. ; * The instruction can only write to word aligned memory, hence the code at the start and end of this routine
  381. ; * to handle possible unaligned bytes at start and end.
  382. ; *
  383. ; * @param param1 r0: start address
  384. ; * @param param2 r1: end address
  385. ; * @param param3 r2: FILL PATTETN
  386. ; *
  387. ; * @note note: Most efficient if memory aligned. Linker ALIGN(4) command
  388. ; * should be used as per example linker scripts
  389. ; * Stack is not used in this routine
  390. ; * register contents r4, r5, r6, r7, r8, r9, will are used and will be returned undefined
  391. ; * @return none - Used Registers are not preserved
  392. ; */
  393. fill_memory:
  394. /* ;push {r4, r5, r6, r7, r8, r9, lr} We will not use stack as may be not available */
  395. cmp r0, r1
  396. beq fill_memory_exit /* ; Exit early if source and destination the same */
  397. /* ; copy non-aligned bytes at the start */
  398. and.w r6, r0, #3 /* ; see if non-alaigned bytes at the start */
  399. cmp r6, #0
  400. beq fill_memory_end_start /* ; no spare bytes at start, continue */
  401. mov r5, #4
  402. sub.w r4, r5, r6 /* ; now have number of non-aligned bytes in r4 */
  403. mov r7, #8
  404. mul r8, r7, r6 /* ; calculate number of shifts required to initalise pattern for non-aligned bytes */
  405. mov r9, r2 /* ; copy pattern */
  406. ror r9, r9, r8 /* ; Rotate right to keep pattern consistent */
  407. fill_memory_spare_bytes_start: /* ; From above, R0 contains source address, R1 contains destination address */
  408. cmp r4, #0 /* ; no spare bytes at end- end now */
  409. beq fill_memory_end_start
  410. strb r9, [r0] /* ; fill byte */
  411. ror.w r9, r9, r7 /* ; Rotate right by one byte for the next time, to keep pattern consistent */
  412. add r0, r0, #1 /* ; add one to address */
  413. subs r4, r4, #1 /* ; subtract one from byte count 1 */
  414. b fill_memory_spare_bytes_start
  415. fill_memory_end_start:
  416. mov r6, #0
  417. mov r7, r1 /* ; save end address */
  418. subs r1, r1, r0 /* ; Calculate number of bytes to fill */
  419. mov r8,r1 /* ; Save copy of byte count */
  420. asrs r1,r1, #4 /* ; Div by 16 to get number of chunks to move */
  421. mov r9, r2 /* ; copy pattern */
  422. mov r4, r2 /* ; copy pattern */
  423. mov r5, r2 /* ; copy pattern */
  424. cmp r1, r6 /* ; compare to see if all chunks copied */
  425. beq fill_memory_spare_bytes_end
  426. fill_memory_loop:
  427. it ne
  428. stmne r0!, {r2, r4, r5, r9} /* ; copy pattern- note: stmne instruction must me word aligned (address in r0) */
  429. add.w r6, r6, #1 /* ; use Thumb2- make sure condition code reg. not updated */
  430. cmp r1, r6 /* ; compare to see if all chunks copied */
  431. bne fill_memory_loop
  432. fill_memory_spare_bytes_end: /* ; copy spare bytes at the end if any */
  433. and.w r8, r8, #15 /* ; get spare bytes --check can you do an ands? */
  434. fill_memory_spare_end_loop: /* ; From above, R0 contains source address, R1 contains destination address */
  435. cmp r8, #0 /* ; no spare bytes at end- end now */
  436. beq fill_memory_exit
  437. strb r2, [r0]
  438. ror.w r2, r2, #8 /* ; Rotate right by one byte for the next time, to keep pattern consistent */
  439. add r0, r0, #1 /* ; add one to address */
  440. subs r8, r8, #1 /* ; subtract one from byte count 1 */
  441. b fill_memory_spare_end_loop
  442. fill_memory_exit:
  443. bx lr /*; We will not use pop as stack may be not available */
  444. /*------------------------------------------------------------------------------
  445. * unit_test_fill_memory
  446. * calls fills_memory function with various paramaters
  447. *
  448. * r0: start address
  449. * r1: end address
  450. * r2: FILL PATTETN
  451. *
  452. * Debugger used to check filled memeory is as expected.
  453. * Note: Last instruction in this routine deliberatly halts code to prevent accidentle enabeling in
  454. * release code.
  455. */
  456. #ifdef UNIT_TEST_FILL_MEMORY
  457. MEM_TEST_PATTERN: .word 0x12345678
  458. unit_test_fill_memory:
  459. push {r0, r1, r2, lr}
  460. ldr r0, = 0x20000100
  461. ldr r1, = 0x20000200
  462. ldr r2, MEM_TEST_PATTERN
  463. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments */
  464. ldr r0, = 0x20000300 /* ; source address */
  465. ldr r1, = 0x20000400 /* ; dest address */
  466. ldr r2, = 0x200004FF /* ; end address */
  467. bl block_copy /* ; copy above */
  468. /* second test */
  469. ldr r0, = 0x20003300
  470. ldr r1, = 0x20003403
  471. ldr r2, MEM_TEST_PATTERN
  472. bl fill_memory
  473. ldr r0, = 0x20003300
  474. ldr r1, = 0x20003500
  475. ldr r2, = 0x20003603
  476. bl block_copy
  477. /* third test */
  478. ldr r0, = 0x20000702
  479. ldr r1, = 0x20000803
  480. ldr r2, MEM_TEST_PATTERN
  481. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments */
  482. ldr r0, = 0x20000702
  483. ldr r1, = 0x20000902
  484. ldr r2, = 0x20000A03
  485. bl block_copy
  486. /* fourth test */
  487. ldr r0, = 0x20000B01
  488. ldr r1, = 0x20000C03
  489. ldr r2, MEM_TEST_PATTERN
  490. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments */
  491. ldr r0, = 0x20000B01
  492. ldr r1, = 0x20000D01
  493. ldr r2, = 0x20000E03
  494. bl block_copy
  495. /* fith test */
  496. ldr r0, = 0x20002D01
  497. ldr r1, = 0x20002E01
  498. ldr r2, MEM_TEST_PATTERN
  499. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments */
  500. ldr r0, = 0x20002D01
  501. ldr r1, = 0x20002F01
  502. ldr r2, = 0x20003001
  503. bl block_copy
  504. /* sixth test */
  505. ldr r0, = 0x20001903
  506. ldr r1, = 0x20001904
  507. ldr r2, MEM_TEST_PATTERN
  508. bl fill_memory /* ; fill_memory takes r0 - r2 as arguments */
  509. ldr r0, = 0x20001903
  510. ldr r1, = 0x20001A03
  511. ldr r2, = 0x20001A04
  512. bl block_copy
  513. /* ; final test, note: This one will cause a halt in copy function- as designed */
  514. ldr r0, = 0x20001903
  515. ldr r1, = 0x20001A03
  516. ldr r2, = 0x20000A04 /* ; end address < start address */
  517. bl block_copy
  518. unit_test_fill_memory_debug: /* ; delibrately wait here, this function only to be used when carrying out test */
  519. b . /* ; stop debugger here and verify memory as expected in debugger */
  520. pop {r0, r1, r2, pc}
  521. #endif
  522. /*==============================================================================
  523. * NMI_Handler
  524. */
  525. .weak NMI_Handler
  526. .type NMI_Handler, %function
  527. NMI_Handler:
  528. B .
  529. /*==============================================================================
  530. * HardFault_Handler
  531. */
  532. .weak HardFault_Handler
  533. .type HardFault_Handler, %function
  534. HardFault_Handler:
  535. B .
  536. /*==============================================================================
  537. * MemManage_Handler
  538. */
  539. .weak MemManage_Handler
  540. .type MemManage_Handler, %function
  541. MemManage_Handler:
  542. B .
  543. /*==============================================================================
  544. * BusFault_Handler
  545. */
  546. .weak BusFault_Handler
  547. .type BusFault_Handler, %function
  548. BusFault_Handler:
  549. B .
  550. /*==============================================================================
  551. * UsageFault_Handler
  552. */
  553. .weak UsageFault_Handler
  554. .type UsageFault_Handler, %function
  555. UsageFault_Handler:
  556. B .
  557. /*==============================================================================
  558. * SVC_Handler
  559. */
  560. .weak SVC_Handler
  561. .type SVC_Handler, %function
  562. SVC_Handler:
  563. B .
  564. /*==============================================================================
  565. * DebugMon_Handler
  566. */
  567. .weak DebugMon_Handler
  568. .type DebugMon_Handler, %function
  569. DebugMon_Handler:
  570. B .
  571. /*==============================================================================
  572. * PendSV_Handler
  573. */
  574. .weak PendSV_Handler
  575. .type PendSV_Handler, %function
  576. PendSV_Handler:
  577. B .
  578. /*==============================================================================
  579. * SysTick_Handler
  580. */
  581. .weak SysTick_Handler
  582. .type SysTick_Handler, %function
  583. SysTick_Handler:
  584. B .
  585. /*==============================================================================
  586. * WdogWakeup_IRQHandler
  587. */
  588. .weak WdogWakeup_IRQHandler
  589. .type WdogWakeup_IRQHandler, %function
  590. WdogWakeup_IRQHandler:
  591. B .
  592. /*==============================================================================
  593. * RTC_Wakeup_IRQHandler
  594. */
  595. .weak RTC_Wakeup_IRQHandler
  596. .type RTC_Wakeup_IRQHandler, %function
  597. RTC_Wakeup_IRQHandler:
  598. B .
  599. /*==============================================================================
  600. * SPI0_IRQHandler
  601. */
  602. .weak SPI0_IRQHandler
  603. .type SPI0_IRQHandler, %function
  604. SPI0_IRQHandler:
  605. B .
  606. /*==============================================================================
  607. * SPI1_IRQHandler
  608. */
  609. .weak SPI1_IRQHandler
  610. .type SPI1_IRQHandler, %function
  611. SPI1_IRQHandler:
  612. B .
  613. /*==============================================================================
  614. * I2C0_IRQHandler
  615. */
  616. .weak I2C0_IRQHandler
  617. .type I2C0_IRQHandler, %function
  618. I2C0_IRQHandler:
  619. B .
  620. /*==============================================================================
  621. * I2C0_SMBAlert_IRQHandler
  622. */
  623. .weak I2C0_SMBAlert_IRQHandler
  624. .type I2C0_SMBAlert_IRQHandler, %function
  625. I2C0_SMBAlert_IRQHandler:
  626. B .
  627. /*==============================================================================
  628. * I2C0_SMBus_IRQHandler
  629. */
  630. .weak I2C0_SMBus_IRQHandler
  631. .type I2C0_SMBus_IRQHandler, %function
  632. I2C0_SMBus_IRQHandler:
  633. B .
  634. /*==============================================================================
  635. * I2C1_IRQHandler
  636. */
  637. .weak I2C1_IRQHandler
  638. .type I2C1_IRQHandler, %function
  639. I2C1_IRQHandler:
  640. B .
  641. /*==============================================================================
  642. * I2C1_SMBAlert_IRQHandler
  643. */
  644. .weak I2C1_SMBAlert_IRQHandler
  645. .type I2C1_SMBAlert_IRQHandler, %function
  646. I2C1_SMBAlert_IRQHandler:
  647. B .
  648. /*==============================================================================
  649. * I2C1_SMBus_IRQHandler
  650. */
  651. .weak I2C1_SMBus_IRQHandler
  652. .type I2C1_SMBus_IRQHandler, %function
  653. I2C1_SMBus_IRQHandler:
  654. B .
  655. /*==============================================================================
  656. * UART0_IRQHandler
  657. */
  658. .weak UART0_IRQHandler
  659. .type UART0_IRQHandler, %function
  660. UART0_IRQHandler:
  661. B .
  662. /*==============================================================================
  663. * UART1_IRQHandler
  664. */
  665. .weak UART1_IRQHandler
  666. .type UART1_IRQHandler, %function
  667. UART1_IRQHandler:
  668. B .
  669. /*==============================================================================
  670. * EthernetMAC_IRQHandler
  671. */
  672. .weak EthernetMAC_IRQHandler
  673. .type EthernetMAC_IRQHandler, %function
  674. EthernetMAC_IRQHandler:
  675. B .
  676. /*==============================================================================
  677. * DMA_IRQHandler
  678. */
  679. .weak DMA_IRQHandler
  680. .type DMA_IRQHandler, %function
  681. DMA_IRQHandler:
  682. B .
  683. /*==============================================================================
  684. * Timer1_IRQHandler
  685. */
  686. .weak Timer1_IRQHandler
  687. .type Timer1_IRQHandler, %function
  688. Timer1_IRQHandler:
  689. B .
  690. /*==============================================================================
  691. * Timer2_IRQHandler
  692. */
  693. .weak Timer2_IRQHandler
  694. .type Timer2_IRQHandler, %function
  695. Timer2_IRQHandler:
  696. B .
  697. /*==============================================================================
  698. * CAN_IRQHandler
  699. */
  700. .weak CAN_IRQHandler
  701. .type CAN_IRQHandler, %function
  702. CAN_IRQHandler:
  703. B .
  704. /*==============================================================================
  705. * ENVM0_IRQHandler
  706. */
  707. .weak ENVM0_IRQHandler
  708. .type ENVM0_IRQHandler, %function
  709. ENVM0_IRQHandler:
  710. B .
  711. /*==============================================================================
  712. * ENVM1_IRQHandler
  713. */
  714. .weak ENVM1_IRQHandler
  715. .type ENVM1_IRQHandler, %function
  716. ENVM1_IRQHandler:
  717. B .
  718. /*==============================================================================
  719. * ComBlk_IRQHandler
  720. */
  721. .weak ComBlk_IRQHandler
  722. .type ComBlk_IRQHandler, %function
  723. ComBlk_IRQHandler:
  724. B .
  725. /*==============================================================================
  726. * USB_IRQHandler
  727. */
  728. .weak USB_IRQHandler
  729. .type USB_IRQHandler, %function
  730. USB_IRQHandler:
  731. B .
  732. /*==============================================================================
  733. * USB_DMA_IRQHandler
  734. */
  735. .weak USB_DMA_IRQHandler
  736. .type USB_DMA_IRQHandler, %function
  737. USB_DMA_IRQHandler:
  738. B .
  739. /*==============================================================================
  740. * PLL_Lock_IRQHandler
  741. */
  742. .weak PLL_Lock_IRQHandler
  743. .type PLL_Lock_IRQHandler, %function
  744. PLL_Lock_IRQHandler:
  745. B .
  746. /*==============================================================================
  747. * PLL_LockLost_IRQHandler
  748. */
  749. .weak PLL_LockLost_IRQHandler
  750. .type PLL_LockLost_IRQHandler, %function
  751. PLL_LockLost_IRQHandler:
  752. B .
  753. /*==============================================================================
  754. * CommSwitchError_IRQHandler
  755. */
  756. .weak CommSwitchError_IRQHandler
  757. .type CommSwitchError_IRQHandler, %function
  758. CommSwitchError_IRQHandler:
  759. B .
  760. /*==============================================================================
  761. * CacheError_IRQHandler
  762. */
  763. .weak CacheError_IRQHandler
  764. .type CacheError_IRQHandler, %function
  765. CacheError_IRQHandler:
  766. B .
  767. /*==============================================================================
  768. * DDR_IRQHandler
  769. */
  770. .weak DDR_IRQHandler
  771. .type DDR_IRQHandler, %function
  772. DDR_IRQHandler:
  773. B .
  774. /*==============================================================================
  775. * HPDMA_Complete_IRQHandler
  776. */
  777. .weak HPDMA_Complete_IRQHandler
  778. .type HPDMA_Complete_IRQHandler, %function
  779. HPDMA_Complete_IRQHandler:
  780. B .
  781. /*==============================================================================
  782. * HPDMA_Error_IRQHandler
  783. */
  784. .weak HPDMA_Error_IRQHandler
  785. .type HPDMA_Error_IRQHandler, %function
  786. HPDMA_Error_IRQHandler:
  787. B .
  788. /*==============================================================================
  789. * ECC_Error_IRQHandler
  790. */
  791. .weak ECC_Error_IRQHandler
  792. .type ECC_Error_IRQHandler, %function
  793. ECC_Error_IRQHandler:
  794. B .
  795. /*==============================================================================
  796. * MDDR_IOCalib_IRQHandler
  797. */
  798. .weak MDDR_IOCalib_IRQHandler
  799. .type MDDR_IOCalib_IRQHandler, %function
  800. MDDR_IOCalib_IRQHandler:
  801. B .
  802. /*==============================================================================
  803. * FAB_PLL_Lock_IRQHandler
  804. */
  805. .weak FAB_PLL_Lock_IRQHandler
  806. .type FAB_PLL_Lock_IRQHandler, %function
  807. FAB_PLL_Lock_IRQHandler:
  808. B .
  809. /*==============================================================================
  810. * FAB_PLL_LockLost_IRQHandler
  811. */
  812. .weak FAB_PLL_LockLost_IRQHandler
  813. .type FAB_PLL_LockLost_IRQHandler, %function
  814. FAB_PLL_LockLost_IRQHandler:
  815. B .
  816. /*==============================================================================
  817. * FIC64_IRQHandler
  818. */
  819. .weak FIC64_IRQHandler
  820. .type FIC64_IRQHandler, %function
  821. FIC64_IRQHandler:
  822. B .
  823. /*==============================================================================
  824. * FabricIrq0_IRQHandler
  825. */
  826. .weak FabricIrq0_IRQHandler
  827. .type FabricIrq0_IRQHandler, %function
  828. FabricIrq0_IRQHandler:
  829. B .
  830. /*==============================================================================
  831. * FabricIrq1_IRQHandler
  832. */
  833. .weak FabricIrq1_IRQHandler
  834. .type FabricIrq1_IRQHandler, %function
  835. FabricIrq1_IRQHandler:
  836. B .
  837. /*==============================================================================
  838. * FabricIrq2_IRQHandler
  839. */
  840. .weak FabricIrq2_IRQHandler
  841. .type FabricIrq2_IRQHandler, %function
  842. FabricIrq2_IRQHandler:
  843. B .
  844. /*==============================================================================
  845. * FabricIrq3_IRQHandler
  846. */
  847. .weak FabricIrq3_IRQHandler
  848. .type FabricIrq3_IRQHandler, %function
  849. FabricIrq3_IRQHandler:
  850. B .
  851. /*==============================================================================
  852. * FabricIrq4_IRQHandler
  853. */
  854. .weak FabricIrq4_IRQHandler
  855. .type FabricIrq4_IRQHandler, %function
  856. FabricIrq4_IRQHandler:
  857. B .
  858. /*==============================================================================
  859. * FabricIrq5_IRQHandler
  860. */
  861. .weak FabricIrq5_IRQHandler
  862. .type FabricIrq5_IRQHandler, %function
  863. FabricIrq5_IRQHandler:
  864. B .
  865. /*==============================================================================
  866. * FabricIrq6_IRQHandler
  867. */
  868. .weak FabricIrq6_IRQHandler
  869. .type FabricIrq6_IRQHandler, %function
  870. FabricIrq6_IRQHandler:
  871. B .
  872. /*==============================================================================
  873. * FabricIrq7_IRQHandler
  874. */
  875. .weak FabricIrq7_IRQHandler
  876. .type FabricIrq7_IRQHandler, %function
  877. FabricIrq7_IRQHandler:
  878. B .
  879. /*==============================================================================
  880. * FabricIrq8_IRQHandler
  881. */
  882. .weak FabricIrq8_IRQHandler
  883. .type FabricIrq8_IRQHandler, %function
  884. FabricIrq8_IRQHandler:
  885. B .
  886. /*==============================================================================
  887. * FabricIrq9_IRQHandler
  888. */
  889. .weak FabricIrq9_IRQHandler
  890. .type FabricIrq9_IRQHandler, %function
  891. FabricIrq9_IRQHandler:
  892. B .
  893. /*==============================================================================
  894. * FabricIrq10_IRQHandler
  895. */
  896. .weak FabricIrq10_IRQHandler
  897. .type FabricIrq10_IRQHandler, %function
  898. FabricIrq10_IRQHandler:
  899. B .
  900. /*==============================================================================
  901. * FabricIrq11_IRQHandler
  902. */
  903. .weak FabricIrq11_IRQHandler
  904. .type FabricIrq11_IRQHandler, %function
  905. FabricIrq11_IRQHandler:
  906. B .
  907. /*==============================================================================
  908. * FabricIrq12_IRQHandler
  909. */
  910. .weak FabricIrq12_IRQHandler
  911. .type FabricIrq12_IRQHandler, %function
  912. FabricIrq12_IRQHandler:
  913. B .
  914. /*==============================================================================
  915. * FabricIrq13_IRQHandler
  916. */
  917. .weak FabricIrq13_IRQHandler
  918. .type FabricIrq13_IRQHandler, %function
  919. FabricIrq13_IRQHandler:
  920. B .
  921. /*==============================================================================
  922. * FabricIrq14_IRQHandler
  923. */
  924. .weak FabricIrq14_IRQHandler
  925. .type FabricIrq14_IRQHandler, %function
  926. FabricIrq14_IRQHandler:
  927. B .
  928. /*==============================================================================
  929. * FabricIrq15_IRQHandler
  930. */
  931. .weak FabricIrq15_IRQHandler
  932. .type FabricIrq15_IRQHandler, %function
  933. FabricIrq15_IRQHandler:
  934. B .
  935. /*==============================================================================
  936. * GPIO0_IRQHandler
  937. */
  938. .weak GPIO0_IRQHandler
  939. .type GPIO0_IRQHandler, %function
  940. GPIO0_IRQHandler:
  941. B .
  942. /*==============================================================================
  943. * GPIO1_IRQHandler
  944. */
  945. .weak GPIO1_IRQHandler
  946. .type GPIO1_IRQHandler, %function
  947. GPIO1_IRQHandler:
  948. B .
  949. /*==============================================================================
  950. * GPIO2_IRQHandler
  951. */
  952. .weak GPIO2_IRQHandler
  953. .type GPIO2_IRQHandler, %function
  954. GPIO2_IRQHandler:
  955. B .
  956. /*==============================================================================
  957. * GPIO3_IRQHandler
  958. */
  959. .weak GPIO3_IRQHandler
  960. .type GPIO3_IRQHandler, %function
  961. GPIO3_IRQHandler:
  962. B .
  963. /*==============================================================================
  964. * GPIO4_IRQHandler
  965. */
  966. .weak GPIO4_IRQHandler
  967. .type GPIO4_IRQHandler, %function
  968. GPIO4_IRQHandler:
  969. B .
  970. /*==============================================================================
  971. * GPIO5_IRQHandler
  972. */
  973. .weak GPIO5_IRQHandler
  974. .type GPIO5_IRQHandler, %function
  975. GPIO5_IRQHandler:
  976. B .
  977. /*==============================================================================
  978. * GPIO6_IRQHandler
  979. */
  980. .weak GPIO6_IRQHandler
  981. .type GPIO6_IRQHandler, %function
  982. GPIO6_IRQHandler:
  983. B .
  984. /*==============================================================================
  985. * GPIO7_IRQHandler
  986. */
  987. .weak GPIO7_IRQHandler
  988. .type GPIO7_IRQHandler, %function
  989. GPIO7_IRQHandler:
  990. B .
  991. /*==============================================================================
  992. * GPIO8_IRQHandler
  993. */
  994. .weak GPIO8_IRQHandler
  995. .type GPIO8_IRQHandler, %function
  996. GPIO8_IRQHandler:
  997. B .
  998. /*==============================================================================
  999. * GPIO9_IRQHandler
  1000. */
  1001. .weak GPIO9_IRQHandler
  1002. .type GPIO9_IRQHandler, %function
  1003. GPIO9_IRQHandler:
  1004. B .
  1005. /*==============================================================================
  1006. * GPIO10_IRQHandler
  1007. */
  1008. .weak GPIO10_IRQHandler
  1009. .type GPIO10_IRQHandler, %function
  1010. GPIO10_IRQHandler:
  1011. B .
  1012. /*==============================================================================
  1013. * GPIO11_IRQHandler
  1014. */
  1015. .weak GPIO11_IRQHandler
  1016. .type GPIO11_IRQHandler, %function
  1017. GPIO11_IRQHandler:
  1018. B .
  1019. /*==============================================================================
  1020. * GPIO12_IRQHandler
  1021. */
  1022. .weak GPIO12_IRQHandler
  1023. .type GPIO12_IRQHandler, %function
  1024. GPIO12_IRQHandler:
  1025. B .
  1026. /*==============================================================================
  1027. * GPIO13_IRQHandler
  1028. */
  1029. .weak GPIO13_IRQHandler
  1030. .type GPIO13_IRQHandler, %function
  1031. GPIO13_IRQHandler:
  1032. B .
  1033. /*==============================================================================
  1034. * GPIO14_IRQHandler
  1035. */
  1036. .weak GPIO14_IRQHandler
  1037. .type GPIO14_IRQHandler, %function
  1038. GPIO14_IRQHandler:
  1039. B .
  1040. /*==============================================================================
  1041. * GPIO15_IRQHandler
  1042. */
  1043. .weak GPIO15_IRQHandler
  1044. .type GPIO15_IRQHandler, %function
  1045. GPIO15_IRQHandler:
  1046. B .
  1047. /*==============================================================================
  1048. * GPIO16_IRQHandler
  1049. */
  1050. .weak GPIO16_IRQHandler
  1051. .type GPIO16_IRQHandler, %function
  1052. GPIO16_IRQHandler:
  1053. B .
  1054. /*==============================================================================
  1055. * GPIO17_IRQHandler
  1056. */
  1057. .weak GPIO17_IRQHandler
  1058. .type GPIO17_IRQHandler, %function
  1059. GPIO17_IRQHandler:
  1060. B .
  1061. /*==============================================================================
  1062. * GPIO18_IRQHandler
  1063. */
  1064. .weak GPIO18_IRQHandler
  1065. .type GPIO18_IRQHandler, %function
  1066. GPIO18_IRQHandler:
  1067. B .
  1068. /*==============================================================================
  1069. * GPIO19_IRQHandler
  1070. */
  1071. .weak GPIO19_IRQHandler
  1072. .type GPIO19_IRQHandler, %function
  1073. GPIO19_IRQHandler:
  1074. B .
  1075. /*==============================================================================
  1076. * GPIO20_IRQHandler
  1077. */
  1078. .weak GPIO20_IRQHandler
  1079. .type GPIO20_IRQHandler, %function
  1080. GPIO20_IRQHandler:
  1081. B .
  1082. /*==============================================================================
  1083. * GPIO21_IRQHandler
  1084. */
  1085. .weak GPIO21_IRQHandler
  1086. .type GPIO21_IRQHandler, %function
  1087. GPIO21_IRQHandler:
  1088. B .
  1089. /*==============================================================================
  1090. * GPIO22_IRQHandler
  1091. */
  1092. .weak GPIO22_IRQHandler
  1093. .type GPIO22_IRQHandler, %function
  1094. GPIO22_IRQHandler:
  1095. B .
  1096. /*==============================================================================
  1097. * GPIO23_IRQHandler
  1098. */
  1099. .weak GPIO23_IRQHandler
  1100. .type GPIO23_IRQHandler, %function
  1101. GPIO23_IRQHandler:
  1102. B .
  1103. /*==============================================================================
  1104. * GPIO24_IRQHandler
  1105. */
  1106. .weak GPIO24_IRQHandler
  1107. .type GPIO24_IRQHandler, %function
  1108. GPIO24_IRQHandler:
  1109. B .
  1110. /*==============================================================================
  1111. * GPIO25_IRQHandler
  1112. */
  1113. .weak GPIO25_IRQHandler
  1114. .type GPIO25_IRQHandler, %function
  1115. GPIO25_IRQHandler:
  1116. B .
  1117. /*==============================================================================
  1118. * GPIO26_IRQHandler
  1119. */
  1120. .weak GPIO26_IRQHandler
  1121. .type GPIO26_IRQHandler, %function
  1122. GPIO26_IRQHandler:
  1123. B .
  1124. /*==============================================================================
  1125. * GPIO27_IRQHandler
  1126. */
  1127. .weak GPIO27_IRQHandler
  1128. .type GPIO27_IRQHandler, %function
  1129. GPIO27_IRQHandler:
  1130. B .
  1131. /*==============================================================================
  1132. * GPIO28_IRQHandler
  1133. */
  1134. .weak GPIO28_IRQHandler
  1135. .type GPIO28_IRQHandler, %function
  1136. GPIO28_IRQHandler:
  1137. B .
  1138. /*==============================================================================
  1139. * GPIO29_IRQHandler
  1140. */
  1141. .weak GPIO29_IRQHandler
  1142. .type GPIO29_IRQHandler, %function
  1143. GPIO29_IRQHandler:
  1144. B .
  1145. /*==============================================================================
  1146. * GPIO30_IRQHandler
  1147. */
  1148. .weak GPIO30_IRQHandler
  1149. .type GPIO30_IRQHandler, %function
  1150. GPIO30_IRQHandler:
  1151. B .
  1152. /*==============================================================================
  1153. * GPIO31_IRQHandler
  1154. */
  1155. .weak GPIO31_IRQHandler
  1156. .type GPIO31_IRQHandler, %function
  1157. GPIO31_IRQHandler:
  1158. B .
  1159. /*==============================================================================
  1160. * mscc_post_hw_cfg_init
  1161. */
  1162. .weak mscc_post_hw_cfg_init
  1163. .type mscc_post_hw_cfg_init, %function
  1164. mscc_post_hw_cfg_init:
  1165. BX LR
  1166. /*==============================================================================
  1167. * Constants:
  1168. */
  1169. RAM_INIT_PATTERN: .word 0x00000000
  1170. HEAP_INIT_PATTERN: .word 0xA2A2A2A2
  1171. SF2_ESRAM_CR: .word 0x40038000
  1172. SF2_DDR_CR: .word 0x40038008
  1173. SF2_ENVM_REMAP_CR: .word 0x40038010
  1174. SF2_DDRB_NB_SIZE: .word 0x40038030
  1175. SF2_DDRB_CR: .word 0x40038034
  1176. SF2_EDAC_CR: .word 0x40038038
  1177. SF2_MDDR_MODE_CR: .word 0x40020818
  1178. .end