trampoline.S 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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. membar #StoreLoad | #StoreStore
  84. brnz,pn %g1, 1b
  85. nop
  86. sethi %hi(p1275buf), %g2
  87. or %g2, %lo(p1275buf), %g2
  88. ldx [%g2 + 0x10], %l2
  89. mov %sp, %l1
  90. add %l2, -(192 + 128), %sp
  91. flushw
  92. sethi %hi(call_method), %g2
  93. or %g2, %lo(call_method), %g2
  94. stx %g2, [%sp + 2047 + 128 + 0x00]
  95. mov 5, %g2
  96. stx %g2, [%sp + 2047 + 128 + 0x08]
  97. mov 1, %g2
  98. stx %g2, [%sp + 2047 + 128 + 0x10]
  99. sethi %hi(itlb_load), %g2
  100. or %g2, %lo(itlb_load), %g2
  101. stx %g2, [%sp + 2047 + 128 + 0x18]
  102. sethi %hi(mmu_ihandle_cache), %g2
  103. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  104. stx %g2, [%sp + 2047 + 128 + 0x20]
  105. sethi %hi(KERNBASE), %g2
  106. stx %g2, [%sp + 2047 + 128 + 0x28]
  107. sethi %hi(kern_locked_tte_data), %g2
  108. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  109. stx %g2, [%sp + 2047 + 128 + 0x30]
  110. mov 15, %g2
  111. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  112. mov 63, %g2
  113. 1:
  114. stx %g2, [%sp + 2047 + 128 + 0x38]
  115. sethi %hi(p1275buf), %g2
  116. or %g2, %lo(p1275buf), %g2
  117. ldx [%g2 + 0x08], %o1
  118. call %o1
  119. add %sp, (2047 + 128), %o0
  120. sethi %hi(bigkernel), %g2
  121. lduw [%g2 + %lo(bigkernel)], %g2
  122. cmp %g2, 0
  123. be,pt %icc, do_dtlb
  124. nop
  125. sethi %hi(call_method), %g2
  126. or %g2, %lo(call_method), %g2
  127. stx %g2, [%sp + 2047 + 128 + 0x00]
  128. mov 5, %g2
  129. stx %g2, [%sp + 2047 + 128 + 0x08]
  130. mov 1, %g2
  131. stx %g2, [%sp + 2047 + 128 + 0x10]
  132. sethi %hi(itlb_load), %g2
  133. or %g2, %lo(itlb_load), %g2
  134. stx %g2, [%sp + 2047 + 128 + 0x18]
  135. sethi %hi(mmu_ihandle_cache), %g2
  136. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  137. stx %g2, [%sp + 2047 + 128 + 0x20]
  138. sethi %hi(KERNBASE + 0x400000), %g2
  139. stx %g2, [%sp + 2047 + 128 + 0x28]
  140. sethi %hi(kern_locked_tte_data), %g2
  141. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  142. sethi %hi(0x400000), %g1
  143. add %g2, %g1, %g2
  144. stx %g2, [%sp + 2047 + 128 + 0x30]
  145. mov 14, %g2
  146. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  147. mov 62, %g2
  148. 1:
  149. stx %g2, [%sp + 2047 + 128 + 0x38]
  150. sethi %hi(p1275buf), %g2
  151. or %g2, %lo(p1275buf), %g2
  152. ldx [%g2 + 0x08], %o1
  153. call %o1
  154. add %sp, (2047 + 128), %o0
  155. do_dtlb:
  156. sethi %hi(call_method), %g2
  157. or %g2, %lo(call_method), %g2
  158. stx %g2, [%sp + 2047 + 128 + 0x00]
  159. mov 5, %g2
  160. stx %g2, [%sp + 2047 + 128 + 0x08]
  161. mov 1, %g2
  162. stx %g2, [%sp + 2047 + 128 + 0x10]
  163. sethi %hi(dtlb_load), %g2
  164. or %g2, %lo(dtlb_load), %g2
  165. stx %g2, [%sp + 2047 + 128 + 0x18]
  166. sethi %hi(mmu_ihandle_cache), %g2
  167. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  168. stx %g2, [%sp + 2047 + 128 + 0x20]
  169. sethi %hi(KERNBASE), %g2
  170. stx %g2, [%sp + 2047 + 128 + 0x28]
  171. sethi %hi(kern_locked_tte_data), %g2
  172. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  173. stx %g2, [%sp + 2047 + 128 + 0x30]
  174. mov 15, %g2
  175. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  176. mov 63, %g2
  177. 1:
  178. stx %g2, [%sp + 2047 + 128 + 0x38]
  179. sethi %hi(p1275buf), %g2
  180. or %g2, %lo(p1275buf), %g2
  181. ldx [%g2 + 0x08], %o1
  182. call %o1
  183. add %sp, (2047 + 128), %o0
  184. sethi %hi(bigkernel), %g2
  185. lduw [%g2 + %lo(bigkernel)], %g2
  186. cmp %g2, 0
  187. be,pt %icc, do_unlock
  188. nop
  189. sethi %hi(call_method), %g2
  190. or %g2, %lo(call_method), %g2
  191. stx %g2, [%sp + 2047 + 128 + 0x00]
  192. mov 5, %g2
  193. stx %g2, [%sp + 2047 + 128 + 0x08]
  194. mov 1, %g2
  195. stx %g2, [%sp + 2047 + 128 + 0x10]
  196. sethi %hi(dtlb_load), %g2
  197. or %g2, %lo(dtlb_load), %g2
  198. stx %g2, [%sp + 2047 + 128 + 0x18]
  199. sethi %hi(mmu_ihandle_cache), %g2
  200. lduw [%g2 + %lo(mmu_ihandle_cache)], %g2
  201. stx %g2, [%sp + 2047 + 128 + 0x20]
  202. sethi %hi(KERNBASE + 0x400000), %g2
  203. stx %g2, [%sp + 2047 + 128 + 0x28]
  204. sethi %hi(kern_locked_tte_data), %g2
  205. ldx [%g2 + %lo(kern_locked_tte_data)], %g2
  206. sethi %hi(0x400000), %g1
  207. add %g2, %g1, %g2
  208. stx %g2, [%sp + 2047 + 128 + 0x30]
  209. mov 14, %g2
  210. BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
  211. mov 62, %g2
  212. 1:
  213. stx %g2, [%sp + 2047 + 128 + 0x38]
  214. sethi %hi(p1275buf), %g2
  215. or %g2, %lo(p1275buf), %g2
  216. ldx [%g2 + 0x08], %o1
  217. call %o1
  218. add %sp, (2047 + 128), %o0
  219. do_unlock:
  220. sethi %hi(prom_entry_lock), %g2
  221. stb %g0, [%g2 + %lo(prom_entry_lock)]
  222. membar #StoreStore | #StoreLoad
  223. mov %l1, %sp
  224. flushw
  225. mov %l0, %o0
  226. wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
  227. wr %g0, 0, %fprs
  228. /* XXX Buggy PROM... */
  229. srl %o0, 0, %o0
  230. ldx [%o0], %g6
  231. wr %g0, ASI_P, %asi
  232. mov PRIMARY_CONTEXT, %g7
  233. stxa %g0, [%g7] ASI_DMMU
  234. membar #Sync
  235. mov SECONDARY_CONTEXT, %g7
  236. stxa %g0, [%g7] ASI_DMMU
  237. membar #Sync
  238. mov 1, %g5
  239. sllx %g5, THREAD_SHIFT, %g5
  240. sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
  241. add %g6, %g5, %sp
  242. mov 0, %fp
  243. wrpr %g0, 0, %wstate
  244. wrpr %g0, 0, %tl
  245. /* Setup the trap globals, then we can resurface. */
  246. rdpr %pstate, %o1
  247. mov %g6, %o2
  248. wrpr %o1, PSTATE_AG, %pstate
  249. sethi %hi(sparc64_ttable_tl0), %g5
  250. wrpr %g5, %tba
  251. mov %o2, %g6
  252. wrpr %o1, PSTATE_MG, %pstate
  253. #define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
  254. #define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
  255. mov TSB_REG, %g1
  256. stxa %g0, [%g1] ASI_DMMU
  257. membar #Sync
  258. mov TLB_SFSR, %g1
  259. sethi %uhi(KERN_HIGHBITS), %g2
  260. or %g2, %ulo(KERN_HIGHBITS), %g2
  261. sllx %g2, 32, %g2
  262. or %g2, KERN_LOWBITS, %g2
  263. BRANCH_IF_ANY_CHEETAH(g3,g7,9f)
  264. ba,pt %xcc, 1f
  265. nop
  266. 9:
  267. sethi %uhi(VPTE_BASE_CHEETAH), %g3
  268. or %g3, %ulo(VPTE_BASE_CHEETAH), %g3
  269. ba,pt %xcc, 2f
  270. sllx %g3, 32, %g3
  271. 1:
  272. sethi %uhi(VPTE_BASE_SPITFIRE), %g3
  273. or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3
  274. sllx %g3, 32, %g3
  275. 2:
  276. clr %g7
  277. #undef KERN_HIGHBITS
  278. #undef KERN_LOWBITS
  279. wrpr %o1, 0x0, %pstate
  280. ldx [%g6 + TI_TASK], %g4
  281. wrpr %g0, 0, %wstate
  282. call init_irqwork_curcpu
  283. nop
  284. BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g2,g3,1f)
  285. ba,pt %xcc, 2f
  286. nop
  287. 1: /* Start using proper page size encodings in ctx register. */
  288. sethi %uhi(CTX_CHEETAH_PLUS_NUC), %g3
  289. mov PRIMARY_CONTEXT, %g1
  290. sllx %g3, 32, %g3
  291. sethi %hi(CTX_CHEETAH_PLUS_CTX0), %g2
  292. or %g3, %g2, %g3
  293. stxa %g3, [%g1] ASI_DMMU
  294. membar #Sync
  295. 2:
  296. rdpr %pstate, %o1
  297. or %o1, PSTATE_IE, %o1
  298. wrpr %o1, 0, %pstate
  299. call prom_set_trap_table
  300. sethi %hi(sparc64_ttable_tl0), %o0
  301. call smp_callin
  302. nop
  303. call cpu_idle
  304. mov 0, %o0
  305. call cpu_panic
  306. nop
  307. 1: b,a,pt %xcc, 1b
  308. .align 8
  309. sparc64_cpu_startup_end: