trampoline.S 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. #include <asm/hypervisor.h>
  19. .data
  20. .align 8
  21. call_method:
  22. .asciz "call-method"
  23. .align 8
  24. itlb_load:
  25. .asciz "SUNW,itlb-load"
  26. .align 8
  27. dtlb_load:
  28. .asciz "SUNW,dtlb-load"
  29. .text
  30. .align 8
  31. .globl sparc64_cpu_startup, sparc64_cpu_startup_end
  32. sparc64_cpu_startup:
  33. flushw
  34. BRANCH_IF_SUN4V(g1, niagara_startup)
  35. BRANCH_IF_CHEETAH_BASE(g1, g5, cheetah_startup)
  36. BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1, g5, cheetah_plus_startup)
  37. ba,pt %xcc, spitfire_startup
  38. nop
  39. cheetah_plus_startup:
  40. /* Preserve OBP chosen DCU and DCR register settings. */
  41. ba,pt %xcc, cheetah_generic_startup
  42. nop
  43. cheetah_startup:
  44. mov DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1
  45. wr %g1, %asr18
  46. sethi %uhi(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
  47. or %g5, %ulo(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
  48. sllx %g5, 32, %g5
  49. or %g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5
  50. stxa %g5, [%g0] ASI_DCU_CONTROL_REG
  51. membar #Sync
  52. cheetah_generic_startup:
  53. mov TSB_EXTENSION_P, %g3
  54. stxa %g0, [%g3] ASI_DMMU
  55. stxa %g0, [%g3] ASI_IMMU
  56. membar #Sync
  57. mov TSB_EXTENSION_S, %g3
  58. stxa %g0, [%g3] ASI_DMMU
  59. membar #Sync
  60. mov TSB_EXTENSION_N, %g3
  61. stxa %g0, [%g3] ASI_DMMU
  62. stxa %g0, [%g3] ASI_IMMU
  63. membar #Sync
  64. /* fallthru */
  65. niagara_startup:
  66. /* Disable STICK_INT interrupts. */
  67. sethi %hi(0x80000000), %g5
  68. sllx %g5, 32, %g5
  69. wr %g5, %asr25
  70. ba,pt %xcc, startup_continue
  71. nop
  72. spitfire_startup:
  73. mov (LSU_CONTROL_IC | LSU_CONTROL_DC | LSU_CONTROL_IM | LSU_CONTROL_DM), %g1
  74. stxa %g1, [%g0] ASI_LSU_CONTROL
  75. membar #Sync
  76. startup_continue:
  77. wrpr %g0, 15, %pil
  78. sethi %hi(0x80000000), %g2
  79. sllx %g2, 32, %g2
  80. wr %g2, 0, %tick_cmpr
  81. BRANCH_IF_SUN4V(g1, niagara_lock_tlb)
  82. /* Call OBP by hand to lock KERNBASE into i/d tlbs.
  83. * We lock 2 consequetive entries if we are 'bigkernel'.
  84. */
  85. mov %o0, %l0
  86. sethi %hi(prom_entry_lock), %g2
  87. 1: ldstub [%g2 + %lo(prom_entry_lock)], %g1
  88. membar #StoreLoad | #StoreStore
  89. brnz,pn %g1, 1b
  90. nop
  91. sethi %hi(p1275buf), %g2
  92. or %g2, %lo(p1275buf), %g2
  93. ldx [%g2 + 0x10], %l2
  94. mov %sp, %l1
  95. add %l2, -(192 + 128), %sp
  96. flushw
  97. sethi %hi(call_method), %g2
  98. or %g2, %lo(call_method), %g2
  99. stx %g2, [%sp + 2047 + 128 + 0x00]
  100. mov 5, %g2
  101. stx %g2, [%sp + 2047 + 128 + 0x08]
  102. mov 1, %g2
  103. stx %g2, [%sp + 2047 + 128 + 0x10]
  104. sethi %hi(itlb_load), %g2
  105. or %g2, %lo(itlb_load), %g2
  106. stx %g2, [%sp + 2047 + 128 + 0x18]
  107. sethi %hi(prom_mmu_ihandle_cache), %g2
  108. lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
  109. stx %g2, [%sp + 2047 + 128 + 0x20]
  110. sethi %hi(KERNBASE), %g2
  111. stx %g2, [%sp + 2047 + 128 + 0x28]
  112. sethi %hi(kern_locked_tte_data), %g2
  113. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  114. stx %g2, [%sp + 2047 + 128 + 0x30]
  115. mov 15, %g2
  116. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  117. mov 63, %g2
  118. 1:
  119. stx %g2, [%sp + 2047 + 128 + 0x38]
  120. sethi %hi(p1275buf), %g2
  121. or %g2, %lo(p1275buf), %g2
  122. ldx [%g2 + 0x08], %o1
  123. call %o1
  124. add %sp, (2047 + 128), %o0
  125. sethi %hi(bigkernel), %g2
  126. lduw [%g2 + %lo(bigkernel)], %g2
  127. brz,pt %g2, do_dtlb
  128. nop
  129. sethi %hi(call_method), %g2
  130. or %g2, %lo(call_method), %g2
  131. stx %g2, [%sp + 2047 + 128 + 0x00]
  132. mov 5, %g2
  133. stx %g2, [%sp + 2047 + 128 + 0x08]
  134. mov 1, %g2
  135. stx %g2, [%sp + 2047 + 128 + 0x10]
  136. sethi %hi(itlb_load), %g2
  137. or %g2, %lo(itlb_load), %g2
  138. stx %g2, [%sp + 2047 + 128 + 0x18]
  139. sethi %hi(prom_mmu_ihandle_cache), %g2
  140. lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
  141. stx %g2, [%sp + 2047 + 128 + 0x20]
  142. sethi %hi(KERNBASE + 0x400000), %g2
  143. stx %g2, [%sp + 2047 + 128 + 0x28]
  144. sethi %hi(kern_locked_tte_data), %g2
  145. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  146. sethi %hi(0x400000), %g1
  147. add %g2, %g1, %g2
  148. stx %g2, [%sp + 2047 + 128 + 0x30]
  149. mov 14, %g2
  150. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  151. mov 62, %g2
  152. 1:
  153. stx %g2, [%sp + 2047 + 128 + 0x38]
  154. sethi %hi(p1275buf), %g2
  155. or %g2, %lo(p1275buf), %g2
  156. ldx [%g2 + 0x08], %o1
  157. call %o1
  158. add %sp, (2047 + 128), %o0
  159. do_dtlb:
  160. sethi %hi(call_method), %g2
  161. or %g2, %lo(call_method), %g2
  162. stx %g2, [%sp + 2047 + 128 + 0x00]
  163. mov 5, %g2
  164. stx %g2, [%sp + 2047 + 128 + 0x08]
  165. mov 1, %g2
  166. stx %g2, [%sp + 2047 + 128 + 0x10]
  167. sethi %hi(dtlb_load), %g2
  168. or %g2, %lo(dtlb_load), %g2
  169. stx %g2, [%sp + 2047 + 128 + 0x18]
  170. sethi %hi(prom_mmu_ihandle_cache), %g2
  171. lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
  172. stx %g2, [%sp + 2047 + 128 + 0x20]
  173. sethi %hi(KERNBASE), %g2
  174. stx %g2, [%sp + 2047 + 128 + 0x28]
  175. sethi %hi(kern_locked_tte_data), %g2
  176. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  177. stx %g2, [%sp + 2047 + 128 + 0x30]
  178. mov 15, %g2
  179. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  180. mov 63, %g2
  181. 1:
  182. stx %g2, [%sp + 2047 + 128 + 0x38]
  183. sethi %hi(p1275buf), %g2
  184. or %g2, %lo(p1275buf), %g2
  185. ldx [%g2 + 0x08], %o1
  186. call %o1
  187. add %sp, (2047 + 128), %o0
  188. sethi %hi(bigkernel), %g2
  189. lduw [%g2 + %lo(bigkernel)], %g2
  190. brz,pt %g2, do_unlock
  191. nop
  192. sethi %hi(call_method), %g2
  193. or %g2, %lo(call_method), %g2
  194. stx %g2, [%sp + 2047 + 128 + 0x00]
  195. mov 5, %g2
  196. stx %g2, [%sp + 2047 + 128 + 0x08]
  197. mov 1, %g2
  198. stx %g2, [%sp + 2047 + 128 + 0x10]
  199. sethi %hi(dtlb_load), %g2
  200. or %g2, %lo(dtlb_load), %g2
  201. stx %g2, [%sp + 2047 + 128 + 0x18]
  202. sethi %hi(prom_mmu_ihandle_cache), %g2
  203. lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
  204. stx %g2, [%sp + 2047 + 128 + 0x20]
  205. sethi %hi(KERNBASE + 0x400000), %g2
  206. stx %g2, [%sp + 2047 + 128 + 0x28]
  207. sethi %hi(kern_locked_tte_data), %g2
  208. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  209. sethi %hi(0x400000), %g1
  210. add %g2, %g1, %g2
  211. stx %g2, [%sp + 2047 + 128 + 0x30]
  212. mov 14, %g2
  213. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  214. mov 62, %g2
  215. 1:
  216. stx %g2, [%sp + 2047 + 128 + 0x38]
  217. sethi %hi(p1275buf), %g2
  218. or %g2, %lo(p1275buf), %g2
  219. ldx [%g2 + 0x08], %o1
  220. call %o1
  221. add %sp, (2047 + 128), %o0
  222. do_unlock:
  223. sethi %hi(prom_entry_lock), %g2
  224. stb %g0, [%g2 + %lo(prom_entry_lock)]
  225. membar #StoreStore | #StoreLoad
  226. ba,pt %xcc, after_lock_tlb
  227. nop
  228. niagara_lock_tlb:
  229. mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
  230. sethi %hi(KERNBASE), %o0
  231. clr %o1
  232. sethi %hi(kern_locked_tte_data), %o2
  233. ldx [%o2 + %lo(kern_locked_tte_data)], %o2
  234. mov HV_MMU_IMMU, %o3
  235. ta HV_FAST_TRAP
  236. mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
  237. sethi %hi(KERNBASE), %o0
  238. clr %o1
  239. sethi %hi(kern_locked_tte_data), %o2
  240. ldx [%o2 + %lo(kern_locked_tte_data)], %o2
  241. mov HV_MMU_DMMU, %o3
  242. ta HV_FAST_TRAP
  243. sethi %hi(bigkernel), %g2
  244. lduw [%g2 + %lo(bigkernel)], %g2
  245. brz,pt %g2, after_lock_tlb
  246. nop
  247. mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
  248. sethi %hi(KERNBASE + 0x400000), %o0
  249. clr %o1
  250. sethi %hi(kern_locked_tte_data), %o2
  251. ldx [%o2 + %lo(kern_locked_tte_data)], %o2
  252. sethi %hi(0x400000), %o3
  253. add %o2, %o3, %o2
  254. mov HV_MMU_IMMU, %o3
  255. ta HV_FAST_TRAP
  256. mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
  257. sethi %hi(KERNBASE + 0x400000), %o0
  258. clr %o1
  259. sethi %hi(kern_locked_tte_data), %o2
  260. ldx [%o2 + %lo(kern_locked_tte_data)], %o2
  261. sethi %hi(0x400000), %o3
  262. add %o2, %o3, %o2
  263. mov HV_MMU_DMMU, %o3
  264. ta HV_FAST_TRAP
  265. after_lock_tlb:
  266. mov %l1, %sp
  267. flushw
  268. mov %l0, %o0
  269. wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
  270. wr %g0, 0, %fprs
  271. /* XXX Buggy PROM... */
  272. srl %o0, 0, %o0
  273. ldx [%o0], %g6
  274. wr %g0, ASI_P, %asi
  275. mov PRIMARY_CONTEXT, %g7
  276. 661: stxa %g0, [%g7] ASI_DMMU
  277. .section .sun4v_1insn_patch, "ax"
  278. .word 661b
  279. stxa %g0, [%g7] ASI_MMU
  280. .previous
  281. membar #Sync
  282. mov SECONDARY_CONTEXT, %g7
  283. 661: stxa %g0, [%g7] ASI_DMMU
  284. .section .sun4v_1insn_patch, "ax"
  285. .word 661b
  286. stxa %g0, [%g7] ASI_MMU
  287. .previous
  288. membar #Sync
  289. mov 1, %g5
  290. sllx %g5, THREAD_SHIFT, %g5
  291. sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
  292. add %g6, %g5, %sp
  293. mov 0, %fp
  294. wrpr %g0, 0, %wstate
  295. wrpr %g0, 0, %tl
  296. /* Load TBA, then we can resurface. */
  297. sethi %hi(sparc64_ttable_tl0), %g5
  298. wrpr %g5, %tba
  299. ldx [%g6 + TI_TASK], %g4
  300. wrpr %g0, 0, %wstate
  301. call init_irqwork_curcpu
  302. nop
  303. sethi %hi(tlb_type), %g3
  304. lduw [%g3 + %lo(tlb_type)], %g2
  305. cmp %g2, 3
  306. bne,pt %icc, 1f
  307. nop
  308. call sun4v_init_mondo_queues
  309. nop
  310. 1: call init_cur_cpu_trap
  311. nop
  312. /* Start using proper page size encodings in ctx register. */
  313. sethi %hi(sparc64_kern_pri_context), %g3
  314. ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
  315. mov PRIMARY_CONTEXT, %g1
  316. 661: stxa %g2, [%g1] ASI_DMMU
  317. .section .sun4v_1insn_patch, "ax"
  318. .word 661b
  319. stxa %g2, [%g1] ASI_MMU
  320. .previous
  321. membar #Sync
  322. rdpr %pstate, %o1
  323. or %o1, PSTATE_IE, %o1
  324. wrpr %o1, 0, %pstate
  325. sethi %hi(is_sun4v), %o0
  326. lduw [%o0 + %lo(is_sun4v)], %o0
  327. brz,pt %o0, 1f
  328. nop
  329. TRAP_LOAD_TRAP_BLOCK(%g2, %g3)
  330. add %g2, TRAP_PER_CPU_FAULT_INFO, %g2
  331. stxa %g2, [%g0] ASI_SCRATCHPAD
  332. /* Compute physical address:
  333. *
  334. * paddr = kern_base + (mmfsa_vaddr - KERNBASE)
  335. */
  336. sethi %hi(KERNBASE), %g3
  337. sub %g2, %g3, %g2
  338. sethi %hi(kern_base), %g3
  339. ldx [%g3 + %lo(kern_base)], %g3
  340. add %g2, %g3, %o1
  341. call prom_set_trap_table_sun4v
  342. sethi %hi(sparc64_ttable_tl0), %o0
  343. ba,pt %xcc, 2f
  344. nop
  345. 1: call prom_set_trap_table
  346. sethi %hi(sparc64_ttable_tl0), %o0
  347. 2: call smp_callin
  348. nop
  349. call cpu_idle
  350. mov 0, %o0
  351. call cpu_panic
  352. nop
  353. 1: b,a,pt %xcc, 1b
  354. .align 8
  355. sparc64_cpu_startup_end: