trampoline.S 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* $Id: trampoline.S,v 1.14 2002/01/11 08:45:38 davem Exp $
  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
  17. .globl sun4d_cpu_startup, __smp4d_processor_id
  18. __INIT
  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. /* CPUID in bootbus can be found at PA 0xff0140000 */
  88. #define SUN4D_BOOTBUS_CPUID 0xf0140000
  89. __INIT
  90. .align 4
  91. sun4d_cpu_startup:
  92. /* Set up a sane %psr -- PIL<0xf> S<0x1> PS<0x1> CWP<0x0> */
  93. set (PSR_PIL | PSR_S | PSR_PS), %g1
  94. wr %g1, 0x0, %psr ! traps off though
  95. WRITE_PAUSE
  96. /* Our %wim is one behind CWP */
  97. mov 2, %g1
  98. wr %g1, 0x0, %wim
  99. WRITE_PAUSE
  100. /* Set tbr - we use just one trap table. */
  101. set trapbase, %g1
  102. wr %g1, 0x0, %tbr
  103. WRITE_PAUSE
  104. /* Get our CPU id out of bootbus */
  105. set SUN4D_BOOTBUS_CPUID, %g3
  106. lduba [%g3] ASI_M_CTL, %g3
  107. and %g3, 0xf8, %g3
  108. srl %g3, 3, %g1
  109. sta %g1, [%g0] ASI_M_VIKING_TMP1
  110. /* Give ourselves a stack and curptr. */
  111. set current_set, %g5
  112. srl %g3, 1, %g4
  113. ld [%g5 + %g4], %g6
  114. sethi %hi(THREAD_SIZE - STACKFRAME_SZ), %sp
  115. or %sp, %lo(THREAD_SIZE - STACKFRAME_SZ), %sp
  116. add %g6, %sp, %sp
  117. /* Turn on traps (PSR_ET). */
  118. rd %psr, %g1
  119. wr %g1, PSR_ET, %psr ! traps on
  120. WRITE_PAUSE
  121. /* Init our caches, etc. */
  122. set poke_srmmu, %g5
  123. ld [%g5], %g5
  124. call %g5
  125. nop
  126. /* Start this processor. */
  127. call smp4d_callin
  128. nop
  129. b,a smp_do_cpu_idle