boot_ghs.s 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 SPC560Dxx/boot_ghs.s
  15. * @brief SPC560Dxx boot-related code.
  16. *
  17. * @addtogroup PPC_BOOT
  18. * @{
  19. */
  20. #include "boot.h"
  21. #if !defined(__DOXYGEN__)
  22. .vle
  23. /* BAM record.*/
  24. .section .boot, "axv"
  25. .long 0x015A0000
  26. .long _reset_address
  27. .align 2
  28. .globl _reset_address
  29. .type _reset_address, @function
  30. _reset_address:
  31. #if BOOT_PERFORM_CORE_INIT
  32. e_bl _coreinit
  33. #endif
  34. e_bl _ivinit
  35. #if BOOT_RELOCATE_IN_RAM
  36. /*
  37. * Image relocation in RAM.
  38. */
  39. e_lis r4, __ram_reloc_start__@h
  40. e_or2i r4, __ram_reloc_start__@l
  41. e_lis r5, __ram_reloc_dest__@h
  42. e_or2i r5, __ram_reloc_dest__@l
  43. e_lis r6, __ram_reloc_end__@h
  44. e_or2i r6, __ram_reloc_end__@l
  45. .relloop:
  46. se_cmpl r4, r6
  47. se_bge .relend
  48. se_lwz r7, 0(r4)
  49. se_addi r4, 4
  50. se_stw r7, 0(r5)
  51. se_addi r5, 4
  52. se_b .relloop
  53. .relend:
  54. e_lis r3, _boot_address@h
  55. e_or2i r3, _boot_address@l
  56. mtctr r3
  57. se_bctrl
  58. #else
  59. e_b _boot_address
  60. #endif
  61. #if BOOT_PERFORM_CORE_INIT
  62. .align 2
  63. _coreinit:
  64. /*
  65. * RAM clearing, this device requires a write to all RAM location in
  66. * order to initialize the ECC detection hardware, this is going to
  67. * slow down the startup but there is no way around.
  68. */
  69. xor r0, r0, r0
  70. xor r1, r1, r1
  71. xor r2, r2, r2
  72. xor r3, r3, r3
  73. xor r4, r4, r4
  74. xor r5, r5, r5
  75. xor r6, r6, r6
  76. xor r7, r7, r7
  77. xor r8, r8, r8
  78. xor r9, r9, r9
  79. xor r10, r10, r10
  80. xor r11, r11, r11
  81. xor r12, r12, r12
  82. xor r13, r13, r13
  83. xor r14, r14, r14
  84. xor r15, r15, r15
  85. xor r16, r16, r16
  86. xor r17, r17, r17
  87. xor r18, r18, r18
  88. xor r19, r19, r19
  89. xor r20, r20, r20
  90. xor r21, r21, r21
  91. xor r22, r22, r22
  92. xor r23, r23, r23
  93. xor r24, r24, r24
  94. xor r25, r25, r25
  95. xor r26, r26, r26
  96. xor r27, r27, r27
  97. xor r28, r28, r28
  98. xor r29, r29, r29
  99. xor r30, r30, r30
  100. xor r31, r31, r31
  101. e_lis r4, __ram_start__@h
  102. e_or2i r4, __ram_start__@l
  103. e_lis r5, __ram_end__@h
  104. e_or2i r5, __ram_end__@l
  105. .cleareccloop:
  106. se_cmpl r4, r5
  107. se_bge .cleareccend
  108. e_stmw r16, 0(r4)
  109. e_addi r4, r4, 64
  110. se_b .cleareccloop
  111. .cleareccend:
  112. /*
  113. * Branch prediction enabled.
  114. */
  115. e_li r3, BOOT_BUCSR_DEFAULT
  116. mtspr 1013, r3 /* BUCSR */
  117. se_blr
  118. #endif /* BOOT_PERFORM_CORE_INIT */
  119. /*
  120. * Exception vectors initialization.
  121. */
  122. .align 2
  123. _ivinit:
  124. /* MSR initialization.*/
  125. e_lis r3, BOOT_MSR_DEFAULT@h
  126. e_or2i r3, BOOT_MSR_DEFAULT@l
  127. mtMSR r3
  128. /* IVPR initialization.*/
  129. e_lis r3, __ivpr_base__@h
  130. e_or2i r3, __ivpr_base__@l
  131. mtIVPR r3
  132. se_blr
  133. .section .ivors, "axv"
  134. .globl IVORS
  135. IVORS:
  136. e_b _IVOR0
  137. .align 4
  138. e_b _IVOR1
  139. .align 4
  140. e_b _IVOR2
  141. .align 4
  142. e_b _IVOR3
  143. .align 4
  144. e_b _IVOR4
  145. .align 4
  146. e_b _IVOR5
  147. .align 4
  148. e_b _IVOR6
  149. .align 4
  150. e_b _IVOR7
  151. .align 4
  152. e_b _IVOR8
  153. .align 4
  154. e_b _IVOR9
  155. .align 4
  156. e_b _IVOR10
  157. .align 4
  158. e_b _IVOR11
  159. .align 4
  160. e_b _IVOR12
  161. .align 4
  162. e_b _IVOR13
  163. .align 4
  164. e_b _IVOR14
  165. .align 4
  166. e_b _IVOR15
  167. .section .handlers, "axv"
  168. /*
  169. * Default IVOR handlers.
  170. */
  171. .align 2
  172. .weak _IVOR0, _IVOR1, _IVOR2, _IVOR3, _IVOR4, _IVOR5
  173. .weak _IVOR6, _IVOR7, _IVOR8, _IVOR9, _IVOR10, _IVOR11
  174. .weak _IVOR12, _IVOR13, _IVOR14, _IVOR15
  175. _IVOR0:
  176. _IVOR1:
  177. _IVOR2:
  178. _IVOR3:
  179. _IVOR5:
  180. _IVOR6:
  181. _IVOR7:
  182. _IVOR8:
  183. _IVOR9:
  184. _IVOR11:
  185. _IVOR12:
  186. _IVOR13:
  187. _IVOR14:
  188. _IVOR15:
  189. .global _unhandled_exception
  190. _unhandled_exception:
  191. e_b _unhandled_exception
  192. #endif /* !defined(__DOXYGEN__) */
  193. /** @} */