startup.S 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /******************************************************************************
  17. * @file startup.S
  18. * @brief startup file for smartl. Should use with
  19. * GCC for CSKY Embedded Processors
  20. * @version V1.0
  21. * @date 02. June 2017
  22. ******************************************************************************/
  23. #include <csi_config.h>
  24. .section .vectors
  25. .align 10
  26. .globl __Vectors
  27. .type __Vectors, @object
  28. __Vectors:
  29. .long Reset_Handler
  30. .long Default_Handler
  31. .long Default_Handler
  32. .long Default_Handler
  33. .long Default_Handler
  34. .long Default_Handler
  35. .long Default_Handler
  36. .long Default_Handler
  37. .long Default_Handler
  38. .long Default_Handler
  39. .long Default_Handler
  40. .long Default_Handler
  41. .long Default_Handler
  42. .long Default_Handler
  43. .long Default_Handler
  44. .long Default_Handler
  45. .long Default_Handler
  46. .long Default_Handler
  47. .long Default_Handler
  48. .long Default_Handler
  49. .long Default_Handler
  50. .long Default_Handler
  51. .long tspend_handler
  52. .long Default_Handler
  53. .long Default_Handler
  54. .long Default_Handler
  55. .long Default_Handler
  56. .long Default_Handler
  57. .long Default_Handler
  58. .long Default_Handler
  59. .long Default_Handler
  60. .long Default_Handler
  61. /* External interrupts */
  62. .long SDIO_IRQHandler /* 0: SDIO */
  63. .long MAC_IRQHandler /* 1: MAC */
  64. .long RF_Cfg_IRQHandler /* 2: RF Cfg */
  65. .long SEC_IRQHandler /* 3: SEC */
  66. .long DMA_Channel0_IRQHandler /* 4: DMA_Channel0 */
  67. .long DMA_Channel1_IRQHandler /* 5: DMA_Channel1 */
  68. .long DMA_Channel2_IRQHandler /* 6: DMA_Channel2 */
  69. .long DMA_Channel3_IRQHandler /* 7: DMA_Channel3 */
  70. .long DMA_Channel4_7_IRQHandler /* 8: DMA_Channel4_7 */
  71. .long DMA_BRUST_IRQHandler /* 9: DMA_BRUST */
  72. .long I2C_IRQHandler /* 10: IIC */
  73. .long ADC_IRQHandler /* 11: SD ADC */
  74. .long SPI_LS_IRQHandler /* 12: LS SPI */
  75. .long SPI_HS_IRQHandler /* 13: HS SPI */
  76. .long GPIOA_IRQHandler /* 14: GPIOA */
  77. .long GPIOB_IRQHandler /* 15: GPIOB */
  78. .long USART_IRQHandler /* 16: UART0 */
  79. .long USART1_IRQHandler /* 17: UART1 */
  80. .long USART2_IRQHandler /* 18: UART2&7816 */
  81. .long USART3_5_IRQHandler /* 19: USART3_5 */
  82. .long BLE_IRQHandler /* 20: BLE */
  83. .long BT_IRQHandler /* 21: BT */
  84. .long PWM_IRQHandler /* 22: PWM */
  85. .long I2S_IRQHandler /* 23: I2S */
  86. .long SDIO_HOST_IRQHandler /* 24: SDIO HOST */
  87. .long CORET_IRQHandler /* 25: CoreTIM */
  88. .long RSA_IRQHandler /* 26: RSA */
  89. .long GPSEC_IRQHandler /* 27: GPSEC */
  90. .long FLASH_IRQHandler /* 28: Flash */
  91. .long PMU_IRQHandler /* 29: PMU */
  92. .long TIM0_5_IRQHandler /* 30: Timer0_5 */
  93. .long WDG_IRQHandler /* 31: Watch dog */
  94. .size __Vectors, . - __Vectors
  95. .text
  96. .align 2
  97. _start:
  98. .text
  99. .align 2
  100. .globl Reset_Handler
  101. .type Reset_Handler, %function
  102. Reset_Handler:
  103. #ifdef CONFIG_KERNEL_NONE
  104. lrw r0, 0xe0000200
  105. #else
  106. lrw r0, 0x80000200
  107. mtcr r0, psr
  108. #endif
  109. mtcr r0, psr
  110. lrw r0, g_top_irqstack
  111. mov sp, r0
  112. /*
  113. * move __Vectors to irq_vectors
  114. */
  115. lrw r1, __Vectors
  116. lrw r2, __vdata_start__
  117. lrw r3, __vdata_end__
  118. subu r3, r2
  119. cmpnei r3, 0
  120. bf .L_loopv0_done
  121. .L_loopv0:
  122. ldw r0, (r1, 0)
  123. stw r0, (r2, 0)
  124. addi r1, 4
  125. addi r2, 4
  126. subi r3, 4
  127. cmpnei r3, 0
  128. bt .L_loopv0
  129. .L_loopv0_done:
  130. /*
  131. * The ranges of copy from/to are specified by following symbols
  132. * __etext: LMA of start of the section to copy from. Usually end of text
  133. * __data_start__: VMA of start of the section to copy to
  134. * __data_end__: VMA of end of the section to copy to
  135. *
  136. * All addresses must be aligned to 4 bytes boundary.
  137. */
  138. lrw r1, __erodata
  139. lrw r2, __data_start__
  140. lrw r3, __data_end__
  141. subu r3, r2
  142. cmpnei r3, 0
  143. bf .L_loop0_done
  144. .L_loop0:
  145. ldw r0, (r1, 0)
  146. stw r0, (r2, 0)
  147. addi r1, 4
  148. addi r2, 4
  149. subi r3, 4
  150. cmpnei r3, 0
  151. bt .L_loop0
  152. .L_loop0_done:
  153. /*
  154. * The BSS section is specified by following symbols
  155. * __bss_start__: start of the BSS section.
  156. * __bss_end__: end of the BSS section.
  157. *
  158. * Both addresses must be aligned to 4 bytes boundary.
  159. */
  160. #if 1
  161. lrw r1, __bss_start__
  162. lrw r2, __bss_end__
  163. movi r0, 0
  164. subu r2, r1
  165. cmpnei r2, 0
  166. bf .L_loop1_done
  167. .L_loop1:
  168. stw r0, (r1, 0)
  169. addi r1, 4
  170. subi r2, 4
  171. cmpnei r2, 0
  172. bt .L_loop1
  173. .L_loop1_done:
  174. #endif
  175. #ifndef __NO_SYSTEM_INIT
  176. jbsr SystemInit
  177. #endif
  178. #ifndef __NO_BOARD_INIT
  179. jbsr board_init
  180. #endif
  181. jbsr main
  182. .size Reset_Handler, . - Reset_Handler
  183. __exit:
  184. br __exit
  185. .section .bss
  186. .align 2
  187. .globl g_intstackalloc
  188. .global g_intstackbase
  189. .global g_top_irqstack
  190. g_intstackalloc:
  191. g_intstackbase:
  192. .space CONFIG_ARCH_INTERRUPTSTACK
  193. g_top_irqstack:
  194. .section .vdata
  195. .align 10
  196. .globl irq_vectors
  197. .type irq_vectors, @object
  198. irq_vectors:
  199. .space CONFIG_IRQ_VECTOR_SIZE
  200. .size irq_vectors, . - irq_vectors
  201. .globl irq_vectors_end
  202. irq_vectors_end: