trampoline_32.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * trampoline.S: SMP cpu boot-up trampoline code.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
  6. */
  7. #include <linux/init.h>
  8. #include <asm/head.h>
  9. #include <asm/psr.h>
  10. #include <asm/page.h>
  11. #include <asm/asi.h>
  12. #include <asm/ptrace.h>
  13. #include <asm/vaddrs.h>
  14. #include <asm/contregs.h>
  15. #include <asm/thread_info.h>
  16. .globl sun4m_cpu_startup, __smp4m_processor_id, __leon_processor_id
  17. .globl sun4d_cpu_startup, __smp4d_processor_id
  18. __CPUINIT
  19. .align 4
  20. /* When we start up a cpu for the first time it enters this routine.
  21. * This initializes the chip from whatever state the prom left it
  22. * in and sets PIL in %psr to 15, no irqs.
  23. */
  24. sun4m_cpu_startup:
  25. cpu1_startup:
  26. sethi %hi(trapbase_cpu1), %g3
  27. b 1f
  28. or %g3, %lo(trapbase_cpu1), %g3
  29. cpu2_startup:
  30. sethi %hi(trapbase_cpu2), %g3
  31. b 1f
  32. or %g3, %lo(trapbase_cpu2), %g3
  33. cpu3_startup:
  34. sethi %hi(trapbase_cpu3), %g3
  35. b 1f
  36. or %g3, %lo(trapbase_cpu3), %g3
  37. 1:
  38. /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
  39. set (PSR_PIL | PSR_S | PSR_PS), %g1
  40. wr %g1, 0x0, %psr ! traps off though
  41. WRITE_PAUSE
  42. /* Our %wim is one behind CWP */
  43. mov 2, %g1
  44. wr %g1, 0x0, %wim
  45. WRITE_PAUSE
  46. /* This identifies "this cpu". */
  47. wr %g3, 0x0, %tbr
  48. WRITE_PAUSE
  49. /* Give ourselves a stack and curptr. */
  50. set current_set, %g5
  51. srl %g3, 10, %g4
  52. and %g4, 0xc, %g4
  53. ld [%g5 + %g4], %g6
  54. sethi %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
  55. or %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
  56. add %g6, %sp, %sp
  57. /* Turn on traps (PSR_ET). */
  58. rd %psr, %g1
  59. wr %g1, PSR_ET, %psr ! traps on
  60. WRITE_PAUSE
  61. /* Init our caches, etc. */
  62. set poke_srmmu, %g5
  63. ld [%g5], %g5
  64. call %g5
  65. nop
  66. /* Start this processor. */
  67. call smp4m_callin
  68. nop
  69. b,a smp_do_cpu_idle
  70. .text
  71. .align 4
  72. smp_do_cpu_idle:
  73. call cpu_idle
  74. mov 0, %o0
  75. call cpu_panic
  76. nop
  77. __smp4m_processor_id:
  78. rd %tbr, %g2
  79. srl %g2, 12, %g2
  80. and %g2, 3, %g2
  81. retl
  82. mov %g1, %o7
  83. __smp4d_processor_id:
  84. lda [%g0] ASI_M_VIKING_TMP1, %g2
  85. retl
  86. mov %g1, %o7
  87. __leon_processor_id:
  88. rd %asr17,%g2
  89. srl %g2,28,%g2
  90. retl
  91. mov %g1, %o7
  92. /* CPUID in bootbus can be found at PA 0xff0140000 */
  93. #define SUN4D_BOOTBUS_CPUID 0xf0140000
  94. __CPUINIT
  95. .align 4
  96. sun4d_cpu_startup:
  97. /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
  98. set (PSR_PIL | PSR_S | PSR_PS), %g1
  99. wr %g1, 0x0, %psr ! traps off though
  100. WRITE_PAUSE
  101. /* Our %wim is one behind CWP */
  102. mov 2, %g1
  103. wr %g1, 0x0, %wim
  104. WRITE_PAUSE
  105. /* Set tbr - we use just one trap table. */
  106. set trapbase, %g1
  107. wr %g1, 0x0, %tbr
  108. WRITE_PAUSE
  109. /* Get our CPU id out of bootbus */
  110. set SUN4D_BOOTBUS_CPUID, %g3
  111. lduba [%g3] ASI_M_CTL, %g3
  112. and %g3, 0xf8, %g3
  113. srl %g3, 3, %g1
  114. sta %g1, [%g0] ASI_M_VIKING_TMP1
  115. /* Give ourselves a stack and curptr. */
  116. set current_set, %g5
  117. srl %g3, 1, %g4
  118. ld [%g5 + %g4], %g6
  119. sethi %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
  120. or %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
  121. add %g6, %sp, %sp
  122. /* Turn on traps (PSR_ET). */
  123. rd %psr, %g1
  124. wr %g1, PSR_ET, %psr ! traps on
  125. WRITE_PAUSE
  126. /* Init our caches, etc. */
  127. set poke_srmmu, %g5
  128. ld [%g5], %g5
  129. call %g5
  130. nop
  131. /* Start this processor. */
  132. call smp4d_callin
  133. nop
  134. b,a smp_do_cpu_idle
  135. #ifdef CONFIG_SPARC_LEON
  136. __CPUINIT
  137. .align 4
  138. .global leon_smp_cpu_startup, smp_penguin_ctable
  139. leon_smp_cpu_startup:
  140. set smp_penguin_ctable,%g1
  141. ld [%g1+4],%g1
  142. srl %g1,4,%g1
  143. set 0x00000100,%g5 /* SRMMU_CTXTBL_PTR */
  144. sta %g1, [%g5] ASI_M_MMUREGS
  145. /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
  146. set (PSR_PIL | PSR_S | PSR_PS), %g1
  147. wr %g1, 0x0, %psr ! traps off though
  148. WRITE_PAUSE
  149. /* Our %wim is one behind CWP */
  150. mov 2, %g1
  151. wr %g1, 0x0, %wim
  152. WRITE_PAUSE
  153. /* Set tbr - we use just one trap table. */
  154. set trapbase, %g1
  155. wr %g1, 0x0, %tbr
  156. WRITE_PAUSE
  157. /* Get our CPU id */
  158. rd %asr17,%g3
  159. /* Give ourselves a stack and curptr. */
  160. set current_set, %g5
  161. srl %g3, 28, %g4
  162. sll %g4, 2, %g4
  163. ld [%g5 + %g4], %g6
  164. sethi %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
  165. or %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
  166. add %g6, %sp, %sp
  167. /* Turn on traps (PSR_ET). */
  168. rd %psr, %g1
  169. wr %g1, PSR_ET, %psr ! traps on
  170. WRITE_PAUSE
  171. /* Init our caches, etc. */
  172. set poke_srmmu, %g5
  173. ld [%g5], %g5
  174. call %g5
  175. nop
  176. /* Start this processor. */
  177. call leon_callin
  178. nop
  179. b,a smp_do_cpu_idle
  180. #endif