boot.S 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file SPC560BCxx/boot.s
  15. * @brief SPC560BCxx boot-related code.
  16. *
  17. * @addtogroup PPC_BOOT
  18. * @{
  19. */
  20. #include "boot.h"
  21. #if defined(__HIGHTEC__)
  22. #define se_bge bge
  23. #endif
  24. #if !defined(__DOXYGEN__)
  25. /* BAM record.*/
  26. .section .boot, "ax"
  27. .long 0x015A0000
  28. .long _reset_address
  29. .align 2
  30. .globl _reset_address
  31. .type _reset_address, @function
  32. _reset_address:
  33. #if BOOT_PERFORM_CORE_INIT
  34. e_bl _coreinit
  35. #endif
  36. e_bl _ivinit
  37. #if BOOT_RELOCATE_IN_RAM
  38. /*
  39. * Image relocation in RAM.
  40. */
  41. e_lis r4, __ram_reloc_start__@h
  42. e_or2i r4, __ram_reloc_start__@l
  43. e_lis r5, __ram_reloc_dest__@h
  44. e_or2i r5, __ram_reloc_dest__@l
  45. e_lis r6, __ram_reloc_end__@h
  46. e_or2i r6, r6, __ram_reloc_end__@l
  47. .relloop:
  48. se_cmpl r4, r6
  49. se_bge .relend
  50. se_lwz r7, 0(r4)
  51. se_addi r4, 4
  52. se_stw r7, 0(r5)
  53. se_addi r5, 4
  54. se_b .relloop
  55. .relend:
  56. e_lis r3, _boot_address@h
  57. e_or2i r3, _boot_address@l
  58. mtctr r3
  59. se_bctrl
  60. #else
  61. e_b _boot_address
  62. #endif
  63. #if BOOT_PERFORM_CORE_INIT
  64. .align 2
  65. _coreinit:
  66. /*
  67. * RAM clearing, this device requires a write to all RAM location in
  68. * order to initialize the ECC detection hardware, this is going to
  69. * slow down the startup but there is no way around.
  70. */
  71. xor r0, r0, r0
  72. xor r1, r1, r1
  73. xor r2, r2, r2
  74. xor r3, r3, r3
  75. xor r4, r4, r4
  76. xor r5, r5, r5
  77. xor r6, r6, r6
  78. xor r7, r7, r7
  79. xor r8, r8, r8
  80. xor r9, r9, r9
  81. xor r10, r10, r10
  82. xor r11, r11, r11
  83. xor r12, r12, r12
  84. xor r13, r13, r13
  85. xor r14, r14, r14
  86. xor r15, r15, r15
  87. xor r16, r16, r16
  88. xor r17, r17, r17
  89. xor r18, r18, r18
  90. xor r19, r19, r19
  91. xor r20, r20, r20
  92. xor r21, r21, r21
  93. xor r22, r22, r22
  94. xor r23, r23, r23
  95. xor r24, r24, r24
  96. xor r25, r25, r25
  97. xor r26, r26, r26
  98. xor r27, r27, r27
  99. xor r28, r28, r28
  100. xor r29, r29, r29
  101. xor r30, r30, r30
  102. xor r31, r31, r31
  103. e_lis r4, __ram_start__@h
  104. e_or2i r4, __ram_start__@l
  105. e_lis r5, __ram_end__@h
  106. e_or2i r5, __ram_end__@l
  107. .cleareccloop:
  108. se_cmpl r4, r5
  109. se_bge .cleareccend
  110. e_stmw r16, 0(r4)
  111. e_addi r4, r4, 64
  112. se_b .cleareccloop
  113. .cleareccend:
  114. /*
  115. * Branch prediction enabled.
  116. */
  117. e_li r3, BOOT_BUCSR_DEFAULT
  118. mtspr 1013, r3 /* BUCSR */
  119. se_blr
  120. #endif /* BOOT_PERFORM_CORE_INIT */
  121. /*
  122. * Exception vectors initialization.
  123. */
  124. .align 2
  125. _ivinit:
  126. /* MSR initialization.*/
  127. e_lis r3, BOOT_MSR_DEFAULT@h
  128. e_or2i r3, BOOT_MSR_DEFAULT@l
  129. mtMSR r3
  130. /* IVPR initialization.*/
  131. e_lis r3, __ivpr_base__@h
  132. e_or2i r3, __ivpr_base__@l
  133. mtIVPR r3
  134. se_blr
  135. .section .ivors, "ax"
  136. .globl IVORS
  137. IVORS:
  138. e_b _IVOR0
  139. .align 4
  140. e_b _IVOR1
  141. .align 4
  142. e_b _IVOR2
  143. .align 4
  144. e_b _IVOR3
  145. .align 4
  146. e_b _IVOR4
  147. .align 4
  148. e_b _IVOR5
  149. .align 4
  150. e_b _IVOR6
  151. .align 4
  152. e_b _IVOR7
  153. .align 4
  154. e_b _IVOR8
  155. .align 4
  156. e_b _IVOR9
  157. .align 4
  158. e_b _IVOR10
  159. .align 4
  160. e_b _IVOR11
  161. .align 4
  162. e_b _IVOR12
  163. .align 4
  164. e_b _IVOR13
  165. .align 4
  166. e_b _IVOR14
  167. .align 4
  168. e_b _IVOR15
  169. .section .handlers, "ax"
  170. /*
  171. * Default IVOR handlers.
  172. */
  173. .align 2
  174. .weak _IVOR0, _IVOR1, _IVOR2, _IVOR3, _IVOR4, _IVOR5
  175. .weak _IVOR6, _IVOR7, _IVOR8, _IVOR9, _IVOR10, _IVOR11
  176. .weak _IVOR12, _IVOR13, _IVOR14, _IVOR15
  177. _IVOR0:
  178. _IVOR1:
  179. _IVOR2:
  180. _IVOR3:
  181. _IVOR5:
  182. _IVOR6:
  183. _IVOR7:
  184. _IVOR8:
  185. _IVOR9:
  186. _IVOR11:
  187. _IVOR12:
  188. _IVOR13:
  189. _IVOR14:
  190. _IVOR15:
  191. .global _unhandled_exception
  192. _unhandled_exception:
  193. se_b _unhandled_exception
  194. #endif /* !defined(__DOXYGEN__) */
  195. /** @} */