1 /* $Id: trampoline.S,v 1.26 2002/02/09 19:49:30 davem Exp $
2 * trampoline.S: Jump start slave processors on sparc64.
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
12 #include <asm/pstate.h>
14 #include <asm/pgtable.h>
15 #include <asm/spitfire.h>
16 #include <asm/processor.h>
17 #include <asm/thread_info.h>
26 .asciz "SUNW,itlb-load"
29 .asciz "SUNW,dtlb-load"
33 .globl sparc64_cpu_startup, sparc64_cpu_startup_end
37 BRANCH_IF_CHEETAH_BASE(g1,g5,cheetah_startup)
38 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1,g5,cheetah_plus_startup)
40 ba,pt %xcc, spitfire_startup
44 /* Preserve OBP chosen DCU and DCR register settings. */
45 ba,pt %xcc, cheetah_generic_startup
49 mov DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1
52 sethi %uhi(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
53 or %g5, %ulo(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
55 or %g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5
56 stxa %g5, [%g0] ASI_DCU_CONTROL_REG
59 cheetah_generic_startup:
60 mov TSB_EXTENSION_P, %g3
61 stxa %g0, [%g3] ASI_DMMU
62 stxa %g0, [%g3] ASI_IMMU
65 mov TSB_EXTENSION_S, %g3
66 stxa %g0, [%g3] ASI_DMMU
69 mov TSB_EXTENSION_N, %g3
70 stxa %g0, [%g3] ASI_DMMU
71 stxa %g0, [%g3] ASI_IMMU
74 /* Disable STICK_INT interrupts. */
75 sethi %hi(0x80000000), %g5
79 ba,pt %xcc, startup_continue
83 mov (LSU_CONTROL_IC | LSU_CONTROL_DC | LSU_CONTROL_IM | LSU_CONTROL_DM), %g1
84 stxa %g1, [%g0] ASI_LSU_CONTROL
90 sethi %hi(0x80000000), %g2
94 /* Call OBP by hand to lock KERNBASE into i/d tlbs.
95 * We lock 2 consequetive entries if we are 'bigkernel'.
99 sethi %hi(prom_entry_lock), %g2
100 1: ldstub [%g2 + %lo(prom_entry_lock)], %g1
101 membar #StoreLoad | #StoreStore
105 sethi %hi(p1275buf), %g2
106 or %g2, %lo(p1275buf), %g2
107 ldx [%g2 + 0x10], %l2
109 add %l2, -(192 + 128), %sp
112 sethi %hi(call_method), %g2
113 or %g2, %lo(call_method), %g2
114 stx %g2, [%sp + 2047 + 128 + 0x00]
116 stx %g2, [%sp + 2047 + 128 + 0x08]
118 stx %g2, [%sp + 2047 + 128 + 0x10]
119 sethi %hi(itlb_load), %g2
120 or %g2, %lo(itlb_load), %g2
121 stx %g2, [%sp + 2047 + 128 + 0x18]
122 sethi %hi(prom_mmu_ihandle_cache), %g2
123 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
124 stx %g2, [%sp + 2047 + 128 + 0x20]
125 sethi %hi(KERNBASE), %g2
126 stx %g2, [%sp + 2047 + 128 + 0x28]
127 sethi %hi(kern_locked_tte_data), %g2
128 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
129 stx %g2, [%sp + 2047 + 128 + 0x30]
132 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
136 stx %g2, [%sp + 2047 + 128 + 0x38]
137 sethi %hi(p1275buf), %g2
138 or %g2, %lo(p1275buf), %g2
139 ldx [%g2 + 0x08], %o1
141 add %sp, (2047 + 128), %o0
143 sethi %hi(bigkernel), %g2
144 lduw [%g2 + %lo(bigkernel)], %g2
149 sethi %hi(call_method), %g2
150 or %g2, %lo(call_method), %g2
151 stx %g2, [%sp + 2047 + 128 + 0x00]
153 stx %g2, [%sp + 2047 + 128 + 0x08]
155 stx %g2, [%sp + 2047 + 128 + 0x10]
156 sethi %hi(itlb_load), %g2
157 or %g2, %lo(itlb_load), %g2
158 stx %g2, [%sp + 2047 + 128 + 0x18]
159 sethi %hi(prom_mmu_ihandle_cache), %g2
160 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
161 stx %g2, [%sp + 2047 + 128 + 0x20]
162 sethi %hi(KERNBASE + 0x400000), %g2
163 stx %g2, [%sp + 2047 + 128 + 0x28]
164 sethi %hi(kern_locked_tte_data), %g2
165 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
166 sethi %hi(0x400000), %g1
168 stx %g2, [%sp + 2047 + 128 + 0x30]
171 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
175 stx %g2, [%sp + 2047 + 128 + 0x38]
176 sethi %hi(p1275buf), %g2
177 or %g2, %lo(p1275buf), %g2
178 ldx [%g2 + 0x08], %o1
180 add %sp, (2047 + 128), %o0
183 sethi %hi(call_method), %g2
184 or %g2, %lo(call_method), %g2
185 stx %g2, [%sp + 2047 + 128 + 0x00]
187 stx %g2, [%sp + 2047 + 128 + 0x08]
189 stx %g2, [%sp + 2047 + 128 + 0x10]
190 sethi %hi(dtlb_load), %g2
191 or %g2, %lo(dtlb_load), %g2
192 stx %g2, [%sp + 2047 + 128 + 0x18]
193 sethi %hi(prom_mmu_ihandle_cache), %g2
194 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
195 stx %g2, [%sp + 2047 + 128 + 0x20]
196 sethi %hi(KERNBASE), %g2
197 stx %g2, [%sp + 2047 + 128 + 0x28]
198 sethi %hi(kern_locked_tte_data), %g2
199 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
200 stx %g2, [%sp + 2047 + 128 + 0x30]
203 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
208 stx %g2, [%sp + 2047 + 128 + 0x38]
209 sethi %hi(p1275buf), %g2
210 or %g2, %lo(p1275buf), %g2
211 ldx [%g2 + 0x08], %o1
213 add %sp, (2047 + 128), %o0
215 sethi %hi(bigkernel), %g2
216 lduw [%g2 + %lo(bigkernel)], %g2
218 be,pt %icc, do_unlock
221 sethi %hi(call_method), %g2
222 or %g2, %lo(call_method), %g2
223 stx %g2, [%sp + 2047 + 128 + 0x00]
225 stx %g2, [%sp + 2047 + 128 + 0x08]
227 stx %g2, [%sp + 2047 + 128 + 0x10]
228 sethi %hi(dtlb_load), %g2
229 or %g2, %lo(dtlb_load), %g2
230 stx %g2, [%sp + 2047 + 128 + 0x18]
231 sethi %hi(prom_mmu_ihandle_cache), %g2
232 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
233 stx %g2, [%sp + 2047 + 128 + 0x20]
234 sethi %hi(KERNBASE + 0x400000), %g2
235 stx %g2, [%sp + 2047 + 128 + 0x28]
236 sethi %hi(kern_locked_tte_data), %g2
237 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
238 sethi %hi(0x400000), %g1
240 stx %g2, [%sp + 2047 + 128 + 0x30]
243 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
248 stx %g2, [%sp + 2047 + 128 + 0x38]
249 sethi %hi(p1275buf), %g2
250 or %g2, %lo(p1275buf), %g2
251 ldx [%g2 + 0x08], %o1
253 add %sp, (2047 + 128), %o0
256 sethi %hi(prom_entry_lock), %g2
257 stb %g0, [%g2 + %lo(prom_entry_lock)]
258 membar #StoreStore | #StoreLoad
265 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
268 /* XXX Buggy PROM... */
274 mov PRIMARY_CONTEXT, %g7
275 stxa %g0, [%g7] ASI_DMMU
277 mov SECONDARY_CONTEXT, %g7
278 stxa %g0, [%g7] ASI_DMMU
282 sllx %g5, THREAD_SHIFT, %g5
283 sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
290 /* Setup the trap globals, then we can resurface. */
293 wrpr %o1, PSTATE_AG, %pstate
294 sethi %hi(sparc64_ttable_tl0), %g5
298 wrpr %o1, PSTATE_MG, %pstate
299 #define KERN_HIGHBITS ((_PAGE_VALID|_PAGE_SZ4MB)^0xfffff80000000000)
300 #define KERN_LOWBITS (_PAGE_CP | _PAGE_CV | _PAGE_P | _PAGE_W)
303 stxa %g0, [%g1] ASI_DMMU
306 sethi %uhi(KERN_HIGHBITS), %g2
307 or %g2, %ulo(KERN_HIGHBITS), %g2
309 or %g2, KERN_LOWBITS, %g2
311 BRANCH_IF_ANY_CHEETAH(g3,g7,9f)
317 sethi %uhi(VPTE_BASE_CHEETAH), %g3
318 or %g3, %ulo(VPTE_BASE_CHEETAH), %g3
322 sethi %uhi(VPTE_BASE_SPITFIRE), %g3
323 or %g3, %ulo(VPTE_BASE_SPITFIRE), %g3
331 wrpr %o1, 0x0, %pstate
332 ldx [%g6 + TI_TASK], %g4
336 call init_irqwork_curcpu
339 /* Start using proper page size encodings in ctx register. */
340 sethi %hi(sparc64_kern_pri_context), %g3
341 ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
342 mov PRIMARY_CONTEXT, %g1
343 stxa %g2, [%g1] ASI_DMMU
347 or %o1, PSTATE_IE, %o1
350 call prom_set_trap_table
351 sethi %hi(sparc64_ttable_tl0), %o0
362 sparc64_cpu_startup_end: