boot_cw.s 5.4 KB

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