trampoline.S 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /* $Id: trampoline.S,v 1.26 2002/02/09 19:49:30 davem Exp $
  2. * trampoline.S: Jump start slave processors on sparc64.
  3. *
  4. * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #include <asm/head.h>
  7. #include <asm/asi.h>
  8. #include <asm/lsu.h>
  9. #include <asm/dcr.h>
  10. #include <asm/dcu.h>
  11. #include <asm/pstate.h>
  12. #include <asm/page.h>
  13. #include <asm/pgtable.h>
  14. #include <asm/spitfire.h>
  15. #include <asm/processor.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/mmu.h>
  18. .data
  19. .align 8
  20. call_method:
  21. .asciz "call-method"
  22. .align 8
  23. itlb_load:
  24. .asciz "SUNW,itlb-load"
  25. .align 8
  26. dtlb_load:
  27. .asciz "SUNW,dtlb-load"
  28. .text
  29. .align 8
  30. .globl sparc64_cpu_startup, sparc64_cpu_startup_end
  31. sparc64_cpu_startup:
  32. flushw
  33. BRANCH_IF_CHEETAH_BASE(g1,g5,cheetah_startup)
  34. BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g5,cheetah_plus_startup)
  35. ba,pt %xcc, spitfire_startup
  36. nop
  37. cheetah_plus_startup:
  38. /* Preserve OBP chosen DCU and DCR register settings. */
  39. ba,pt %xcc, cheetah_generic_startup
  40. nop
  41. cheetah_startup:
  42. mov DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1
  43. wr %g1, %asr18
  44. sethi %uhi(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
  45. or %g5, %ulo(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
  46. sllx %g5, 32, %g5
  47. or %g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5
  48. stxa %g5, [%g0] ASI_DCU_CONTROL_REG
  49. membar #Sync
  50. cheetah_generic_startup:
  51. mov TSB_EXTENSION_P, %g3
  52. stxa %g0, [%g3] ASI_DMMU
  53. stxa %g0, [%g3] ASI_IMMU
  54. membar #Sync
  55. mov TSB_EXTENSION_S, %g3
  56. stxa %g0, [%g3] ASI_DMMU
  57. membar #Sync
  58. mov TSB_EXTENSION_N, %g3
  59. stxa %g0, [%g3] ASI_DMMU
  60. stxa %g0, [%g3] ASI_IMMU
  61. membar #Sync
  62. /* Disable STICK_INT interrupts. */
  63. sethi %hi(0x80000000), %g5
  64. sllx %g5, 32, %g5
  65. wr %g5, %asr25
  66. ba,pt %xcc, startup_continue
  67. nop
  68. spitfire_startup:
  69. mov (LSU_CONTROL_IC | LSU_CONTROL_DC | LSU_CONTROL_IM | LSU_CONTROL_DM), %g1
  70. stxa %g1, [%g0] ASI_LSU_CONTROL
  71. membar #Sync
  72. startup_continue:
  73. wrpr %g0, 15, %pil
  74. sethi %hi(0x80000000), %g2
  75. sllx %g2, 32, %g2
  76. wr %g2, 0, %tick_cmpr
  77. /* Call OBP by hand to lock KERNBASE into i/d tlbs.
  78. * We lock 2 consequetive entries if we are 'bigkernel'.
  79. */
  80. mov %o0, %l0
  81. sethi %hi(prom_entry_lock), %g2
  82. 1: ldstub [%g2 + %lo(prom_entry_lock)], %g1
  83. brnz,pn %g1, 1b
  84. membar #StoreLoad | #StoreStore
  85. sethi %hi(p1275buf), %g2
  86. or %g2, %lo(p1275buf), %g2
  87. ldx [%g2 + 0x10], %l2
  88. mov %sp, %l1
  89. add %l2, -(192 + 128), %sp
  90. flushw
  91. sethi %hi(call_method), %g2
  92. or %g2, %lo(call_method), %g2
  93. stx %g2, [%sp + 2047 + 128 + 0x00]
  94. mov 5, %g2
  95. stx %g2, [%sp + 2047 + 128 + 0x08]
  96. mov 1, %g2
  97. stx %g2, [%sp + 2047 + 128 + 0x10]
  98. sethi %hi(itlb_load), %g2
  99. or %g2, %lo(itlb_load), %g2
  100. stx %g2, [%sp + 2047 + 128 + 0x18]
  101. sethi %hi(mmu_ihandle_cache), %g2
  102. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  103. stx %g2, [%sp + 2047 + 128 + 0x20]
  104. sethi %hi(KERNBASE), %g2
  105. stx %g2, [%sp + 2047 + 128 + 0x28]
  106. sethi %hi(kern_locked_tte_data), %g2
  107. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  108. stx %g2, [%sp + 2047 + 128 + 0x30]
  109. mov 15, %g2
  110. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  111. mov 63, %g2
  112. 1:
  113. stx %g2, [%sp + 2047 + 128 + 0x38]
  114. sethi %hi(p1275buf), %g2
  115. or %g2, %lo(p1275buf), %g2
  116. ldx [%g2 + 0x08], %o1
  117. call %o1
  118. add %sp, (2047 + 128), %o0
  119. sethi %hi(bigkernel), %g2
  120. lduw [%g2 + %lo(bigkernel)], %g2
  121. cmp %g2, 0
  122. be,pt %icc, do_dtlb
  123. nop
  124. sethi %hi(call_method), %g2
  125. or %g2, %lo(call_method), %g2
  126. stx %g2, [%sp + 2047 + 128 + 0x00]
  127. mov 5, %g2
  128. stx %g2, [%sp + 2047 + 128 + 0x08]
  129. mov 1, %g2
  130. stx %g2, [%sp + 2047 + 128 + 0x10]
  131. sethi %hi(itlb_load), %g2
  132. or %g2, %lo(itlb_load), %g2
  133. stx %g2, [%sp + 2047 + 128 + 0x18]
  134. sethi %hi(mmu_ihandle_cache), %g2
  135. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  136. stx %g2, [%sp + 2047 + 128 + 0x20]
  137. sethi %hi(KERNBASE + 0x400000), %g2
  138. stx %g2, [%sp + 2047 + 128 + 0x28]
  139. sethi %hi(kern_locked_tte_data), %g2
  140. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  141. sethi %hi(0x400000), %g1
  142. add %g2, %g1, %g2
  143. stx %g2, [%sp + 2047 + 128 + 0x30]
  144. mov 14, %g2
  145. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  146. mov 62, %g2
  147. 1:
  148. stx %g2, [%sp + 2047 + 128 + 0x38]
  149. sethi %hi(p1275buf), %g2
  150. or %g2, %lo(p1275buf), %g2
  151. ldx [%g2 + 0x08], %o1
  152. call %o1
  153. add %sp, (2047 + 128), %o0
  154. do_dtlb:
  155. sethi %hi(call_method), %g2
  156. or %g2, %lo(call_method), %g2
  157. stx %g2, [%sp + 2047 + 128 + 0x00]
  158. mov 5, %g2
  159. stx %g2, [%sp + 2047 + 128 + 0x08]
  160. mov 1, %g2
  161. stx %g2, [%sp + 2047 + 128 + 0x10]
  162. sethi %hi(dtlb_load), %g2
  163. or %g2, %lo(dtlb_load), %g2
  164. stx %g2, [%sp + 2047 + 128 + 0x18]
  165. sethi %hi(mmu_ihandle_cache), %g2
  166. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  167. stx %g2, [%sp + 2047 + 128 + 0x20]
  168. sethi %hi(KERNBASE), %g2
  169. stx %g2, [%sp + 2047 + 128 + 0x28]
  170. sethi %hi(kern_locked_tte_data), %g2
  171. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  172. stx %g2, [%sp + 2047 + 128 + 0x30]
  173. mov 15, %g2
  174. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  175. mov 63, %g2
  176. 1:
  177. stx %g2, [%sp + 2047 + 128 + 0x38]
  178. sethi %hi(p1275buf), %g2
  179. or %g2, %lo(p1275buf), %g2
  180. ldx [%g2 + 0x08], %o1
  181. call %o1
  182. add %sp, (2047 + 128), %o0
  183. sethi %hi(bigkernel), %g2
  184. lduw [%g2 + %lo(bigkernel)], %g2
  185. cmp %g2, 0
  186. be,pt %icc, do_unlock
  187. nop
  188. sethi %hi(call_method), %g2
  189. or %g2, %lo(call_method), %g2
  190. stx %g2, [%sp + 2047 + 128 + 0x00]
  191. mov 5, %g2
  192. stx %g2, [%sp + 2047 + 128 + 0x08]
  193. mov 1, %g2
  194. stx %g2, [%sp + 2047 + 128 + 0x10]
  195. sethi %hi(dtlb_load), %g2
  196. or %g2, %lo(dtlb_load), %g2
  197. stx %g2, [%sp + 2047 + 128 + 0x18]
  198. sethi %hi(mmu_ihandle_cache), %g2
  199. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  200. stx %g2, [%sp + 2047 + 128 + 0x20]
  201. sethi %hi(KERNBASE + 0x400000), %g2
  202. stx %g2, [%sp + 2047 + 128 + 0x28]
  203. sethi %hi(kern_locked_tte_data), %g2
  204. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  205. sethi %hi(0x400000), %g1
  206. add %g2, %g1, %g2
  207. stx %g2, [%sp + 2047 + 128 + 0x30]
  208. mov 14, %g2
  209. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  210. mov 62, %g2
  211. 1:
  212. stx %g2, [%sp + 2047 + 128 + 0x38]
  213. sethi %hi(p1275buf), %g2
  214. or %g2, %lo(p1275buf), %g2
  215. ldx [%g2 + 0x08], %o1
  216. call %o1
  217. add %sp, (2047 + 128), %o0
  218. do_unlock:
  219. sethi %hi(prom_entry_lock), %g2
  220. stb %g0, [%g2 + %lo(prom_entry_lock)]
  221. membar #StoreStore | #StoreLoad
  222. mov %l1, %sp
  223. flushw
  224. mov %l0, %o0
  225. wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
  226. wr %g0, 0, %fprs
  227. /* XXX Buggy PROM... */
  228. srl %o0, 0, %o0
  229. ldx [%o0], %g6
  230. wr %g0, ASI_P, %asi
  231. mov PRIMARY_CONTEXT, %g7
  232. stxa %g0, [%g7] ASI_DMMU
  233. membar #Sync
  234. mov SECONDARY_CONTEXT, %g7
  235. stxa %g0, [%g7] ASI_DMMU
  236. membar #Sync
  237. mov 1, %g5
  238. sllx %g5, THREAD_SHIFT, %g5
  239. sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
  240. add %g6, %g5, %sp
  241. mov 0, %fp
  242. wrpr %g0, 0, %wstate
  243. wrpr %g0, 0, %tl
  244. /* Setup the trap globals, then we can resurface. */
  245. rdpr %pstate, %o1
  246. mov %g6, %o2
  247. wrpr %o1, PSTATE_AG, %pstate
  248. sethi %hi(sparc64_ttable_tl0), %g5
  249. wrpr %g5, %tba
  250. mov %o2, %g6
  251. wrpr %o1, PSTATE_MG, %pstate
  252. #define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
  253. #define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
  254. mov TSB_REG, %g1
  255. stxa %g0, [%g1] ASI_DMMU
  256. membar #Sync
  257. mov TLB_SFSR, %g1
  258. sethi %uhi(KERN_HIGHBITS), %g2
  259. or %g2, %ulo(KERN_HIGHBITS), %g2
  260. sllx %g2, 32, %g2
  261. or %g2, KERN_LOWBITS, %g2
  262. BRANCH_IF_ANY_CHEETAH(g3,g7,9f)
  263. ba,pt %xcc, 1f
  264. nop
  265. 9:
  266. sethi %uhi(VPTE_BASE_CHEETAH), %g3
  267. or %g3, %ulo(VPTE_BASE_CHEETAH), %g3
  268. ba,pt %xcc, 2f
  269. sllx %g3, 32, %g3
  270. 1:
  271. sethi %uhi(VPTE_BASE_SPITFIRE), %g3
  272. or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3
  273. sllx %g3, 32, %g3
  274. 2:
  275. clr %g7
  276. #undef KERN_HIGHBITS
  277. #undef KERN_LOWBITS
  278. wrpr %o1, 0x0, %pstate
  279. ldx [%g6 + TI_TASK], %g4
  280. wrpr %g0, 0, %wstate
  281. call init_irqwork_curcpu
  282. nop
  283. BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f)
  284. ba,pt %xcc, 2f
  285. nop
  286. 1: /* Start using proper page size encodings in ctx register. */
  287. sethi %uhi(CTX_CHEETAH_PLUS_NUC), %g3
  288. mov PRIMARY_CONTEXT, %g1
  289. sllx %g3, 32, %g3
  290. sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
  291. or %g3, %g2, %g3
  292. stxa %g3, [%g1] ASI_DMMU
  293. membar #Sync
  294. 2:
  295. rdpr %pstate, %o1
  296. or %o1, PSTATE_IE, %o1
  297. wrpr %o1, 0, %pstate
  298. call prom_set_trap_table
  299. sethi %hi(sparc64_ttable_tl0), %o0
  300. call smp_callin
  301. nop
  302. call cpu_idle
  303. mov 0, %o0
  304. call cpu_panic
  305. nop
  306. 1: b,a,pt %xcc, 1b
  307. .align 8
  308. sparc64_cpu_startup_end: