release.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. #include <config.h>
  2. #include <mpc85xx.h>
  3. #include <version.h>
  4. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  5. #include <ppc_asm.tmpl>
  6. #include <ppc_defs.h>
  7. #include <asm/cache.h>
  8. #include <asm/mmu.h>
  9. /* To boot secondary cpus, we need a place for them to start up.
  10. * Normally, they start at 0xfffffffc, but that's usually the
  11. * firmware, and we don't want to have to run the firmware again.
  12. * Instead, the primary cpu will set the BPTR to point here to
  13. * this page. We then set up the core, and head to
  14. * start_secondary. Note that this means that the code below
  15. * must never exceed 1023 instructions (the branch at the end
  16. * would then be the 1024th).
  17. */
  18. .globl __secondary_start_page
  19. .align 12
  20. __secondary_start_page:
  21. /* First do some preliminary setup */
  22. lis r3, HID0_EMCP@h /* enable machine check */
  23. #ifndef CONFIG_E500MC
  24. ori r3,r3,HID0_TBEN@l /* enable Timebase */
  25. #endif
  26. #ifdef CONFIG_PHYS_64BIT
  27. ori r3,r3,HID0_ENMAS7@l /* enable MAS7 updates */
  28. #endif
  29. mtspr SPRN_HID0,r3
  30. #ifndef CONFIG_E500MC
  31. li r3,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
  32. mtspr SPRN_HID1,r3
  33. #endif
  34. /* Enable branch prediction */
  35. li r3,0x201
  36. mtspr SPRN_BUCSR,r3
  37. /* Ensure TB is 0 */
  38. li r3,0
  39. mttbl r3
  40. mttbu r3
  41. /* Enable/invalidate the I-Cache */
  42. mfspr r0,SPRN_L1CSR1
  43. ori r0,r0,(L1CSR1_ICFI|L1CSR1_ICE)
  44. mtspr SPRN_L1CSR1,r0
  45. isync
  46. /* Enable/invalidate the D-Cache */
  47. mfspr r0,SPRN_L1CSR0
  48. ori r0,r0,(L1CSR0_DCFI|L1CSR0_DCE)
  49. msync
  50. isync
  51. mtspr SPRN_L1CSR0,r0
  52. isync
  53. #define toreset(x) (x - __secondary_start_page + 0xfffff000)
  54. /* get our PIR to figure out our table entry */
  55. lis r3,toreset(__spin_table)@h
  56. ori r3,r3,toreset(__spin_table)@l
  57. /* r10 has the base address for the entry */
  58. mfspr r0,SPRN_PIR
  59. #ifdef CONFIG_E500MC
  60. rlwinm r4,r0,27,27,31
  61. #else
  62. mr r4,r0
  63. #endif
  64. slwi r8,r4,5
  65. add r10,r3,r8
  66. #ifdef CONFIG_BACKSIDE_L2_CACHE
  67. /* Enable/invalidate the L2 cache */
  68. msync
  69. lis r3,L2CSR0_L2FI@h
  70. mtspr SPRN_L2CSR0,r3
  71. 1:
  72. mfspr r3,SPRN_L2CSR0
  73. andis. r1,r3,L2CSR0_L2FI@h
  74. bne 1b
  75. lis r3,CONFIG_SYS_INIT_L2CSR0@h
  76. ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l
  77. mtspr SPRN_L2CSR0,r3
  78. isync
  79. #endif
  80. #define EPAPR_MAGIC (0x45504150)
  81. #define ENTRY_ADDR_UPPER 0
  82. #define ENTRY_ADDR_LOWER 4
  83. #define ENTRY_R3_UPPER 8
  84. #define ENTRY_R3_LOWER 12
  85. #define ENTRY_RESV 16
  86. #define ENTRY_PIR 20
  87. #define ENTRY_R6_UPPER 24
  88. #define ENTRY_R6_LOWER 28
  89. #define ENTRY_SIZE 32
  90. /* setup the entry */
  91. li r3,0
  92. li r8,1
  93. stw r0,ENTRY_PIR(r10)
  94. stw r3,ENTRY_ADDR_UPPER(r10)
  95. stw r8,ENTRY_ADDR_LOWER(r10)
  96. stw r3,ENTRY_R3_UPPER(r10)
  97. stw r4,ENTRY_R3_LOWER(r10)
  98. stw r3,ENTRY_R6_UPPER(r10)
  99. stw r3,ENTRY_R6_LOWER(r10)
  100. /* setup mapping for AS = 1, and jump there */
  101. lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h
  102. mtspr SPRN_MAS0,r11
  103. lis r11,(MAS1_VALID|MAS1_IPROT)@h
  104. ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
  105. mtspr SPRN_MAS1,r11
  106. lis r11,(0xfffff000|MAS2_I)@h
  107. ori r11,r11,(0xfffff000|MAS2_I)@l
  108. mtspr SPRN_MAS2,r11
  109. lis r11,(0xfffff000|MAS3_SX|MAS3_SW|MAS3_SR)@h
  110. ori r11,r11,(0xfffff000|MAS3_SX|MAS3_SW|MAS3_SR)@l
  111. mtspr SPRN_MAS3,r11
  112. tlbwe
  113. bl 1f
  114. 1: mflr r11
  115. addi r11,r11,28
  116. mfmsr r13
  117. ori r12,r13,MSR_IS|MSR_DS@l
  118. mtspr SPRN_SRR0,r11
  119. mtspr SPRN_SRR1,r12
  120. rfi
  121. /* spin waiting for addr */
  122. 2:
  123. lwz r4,ENTRY_ADDR_LOWER(r10)
  124. andi. r11,r4,1
  125. bne 2b
  126. isync
  127. /* get the upper bits of the addr */
  128. lwz r11,ENTRY_ADDR_UPPER(r10)
  129. /* setup branch addr */
  130. mtspr SPRN_SRR0,r4
  131. /* mark the entry as released */
  132. li r8,3
  133. stw r8,ENTRY_ADDR_LOWER(r10)
  134. /* mask by ~64M to setup our tlb we will jump to */
  135. rlwinm r12,r4,0,0,5
  136. /* setup r3, r4, r5, r6, r7, r8, r9 */
  137. lwz r3,ENTRY_R3_LOWER(r10)
  138. li r4,0
  139. li r5,0
  140. lwz r6,ENTRY_R6_LOWER(r10)
  141. lis r7,(64*1024*1024)@h
  142. li r8,0
  143. li r9,0
  144. /* load up the pir */
  145. lwz r0,ENTRY_PIR(r10)
  146. mtspr SPRN_PIR,r0
  147. mfspr r0,SPRN_PIR
  148. stw r0,ENTRY_PIR(r10)
  149. mtspr IVPR,r12
  150. /*
  151. * Coming here, we know the cpu has one TLB mapping in TLB1[0]
  152. * which maps 0xfffff000-0xffffffff one-to-one. We set up a
  153. * second mapping that maps addr 1:1 for 64M, and then we jump to
  154. * addr
  155. */
  156. lis r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h
  157. mtspr SPRN_MAS0,r10
  158. lis r10,(MAS1_VALID|MAS1_IPROT)@h
  159. ori r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l
  160. mtspr SPRN_MAS1,r10
  161. /* WIMGE = 0b00000 for now */
  162. mtspr SPRN_MAS2,r12
  163. ori r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR)
  164. mtspr SPRN_MAS3,r12
  165. #ifdef CONFIG_ENABLE_36BIT_PHYS
  166. mtspr SPRN_MAS7,r11
  167. #endif
  168. tlbwe
  169. /* Now we have another mapping for this page, so we jump to that
  170. * mapping
  171. */
  172. mtspr SPRN_SRR1,r13
  173. rfi
  174. .align L1_CACHE_SHIFT
  175. .globl __spin_table
  176. __spin_table:
  177. .space CONFIG_NUM_CPUS*ENTRY_SIZE
  178. /* Fill in the empty space. The actual reset vector is
  179. * the last word of the page */
  180. __secondary_start_code_end:
  181. .space 4092 - (__secondary_start_code_end - __secondary_start_page)
  182. __secondary_reset_vector:
  183. b __secondary_start_page