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)
7 <<<<<<< HEAD:arch/sparc64/kernel/trampoline.S
9 #include <linux/init.h>
11 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/trampoline.S
17 #include <asm/pstate.h>
19 #include <asm/pgtable.h>
20 #include <asm/spitfire.h>
21 #include <asm/processor.h>
22 #include <asm/thread_info.h>
24 #include <asm/hypervisor.h>
25 #include <asm/cpudata.h>
33 .asciz "SUNW,itlb-load"
36 .asciz "SUNW,dtlb-load"
38 /* XXX __cpuinit this thing XXX */
39 #define TRAMP_STACK_SIZE 1024
42 .skip TRAMP_STACK_SIZE
44 <<<<<<< HEAD:arch/sparc64/kernel/trampoline.S
48 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:arch/sparc64/kernel/trampoline.S
50 .globl sparc64_cpu_startup, sparc64_cpu_startup_end
52 BRANCH_IF_SUN4V(g1, niagara_startup)
53 BRANCH_IF_CHEETAH_BASE(g1, g5, cheetah_startup)
54 BRANCH_IF_CHEETAH_PLUS_OR_FOLLOWON(g1, g5, cheetah_plus_startup)
56 ba,pt %xcc, spitfire_startup
60 /* Preserve OBP chosen DCU and DCR register settings. */
61 ba,pt %xcc, cheetah_generic_startup
65 mov DCR_BPE | DCR_RPE | DCR_SI | DCR_IFPOE | DCR_MS, %g1
68 sethi %uhi(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
69 or %g5, %ulo(DCU_ME|DCU_RE|DCU_HPE|DCU_SPE|DCU_SL|DCU_WE), %g5
71 or %g5, DCU_DM | DCU_IM | DCU_DC | DCU_IC, %g5
72 stxa %g5, [%g0] ASI_DCU_CONTROL_REG
76 cheetah_generic_startup:
77 mov TSB_EXTENSION_P, %g3
78 stxa %g0, [%g3] ASI_DMMU
79 stxa %g0, [%g3] ASI_IMMU
82 mov TSB_EXTENSION_S, %g3
83 stxa %g0, [%g3] ASI_DMMU
86 mov TSB_EXTENSION_N, %g3
87 stxa %g0, [%g3] ASI_DMMU
88 stxa %g0, [%g3] ASI_IMMU
93 /* Disable STICK_INT interrupts. */
94 sethi %hi(0x80000000), %g5
98 ba,pt %xcc, startup_continue
102 mov (LSU_CONTROL_IC | LSU_CONTROL_DC | LSU_CONTROL_IM | LSU_CONTROL_DM), %g1
103 stxa %g1, [%g0] ASI_LSU_CONTROL
108 BRANCH_IF_SUN4V(g1, niagara_lock_tlb)
110 sethi %hi(0x80000000), %g2
112 wr %g2, 0, %tick_cmpr
114 /* Call OBP by hand to lock KERNBASE into i/d tlbs.
115 * We lock 2 consequetive entries if we are 'bigkernel'.
117 sethi %hi(prom_entry_lock), %g2
118 1: ldstub [%g2 + %lo(prom_entry_lock)], %g1
119 membar #StoreLoad | #StoreStore
123 sethi %hi(p1275buf), %g2
124 or %g2, %lo(p1275buf), %g2
125 ldx [%g2 + 0x10], %l2
126 add %l2, -(192 + 128), %sp
129 sethi %hi(call_method), %g2
130 or %g2, %lo(call_method), %g2
131 stx %g2, [%sp + 2047 + 128 + 0x00]
133 stx %g2, [%sp + 2047 + 128 + 0x08]
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), %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 stx %g2, [%sp + 2047 + 128 + 0x30]
149 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
153 stx %g2, [%sp + 2047 + 128 + 0x38]
154 sethi %hi(p1275buf), %g2
155 or %g2, %lo(p1275buf), %g2
156 ldx [%g2 + 0x08], %o1
158 add %sp, (2047 + 128), %o0
160 sethi %hi(bigkernel), %g2
161 lduw [%g2 + %lo(bigkernel)], %g2
165 sethi %hi(call_method), %g2
166 or %g2, %lo(call_method), %g2
167 stx %g2, [%sp + 2047 + 128 + 0x00]
169 stx %g2, [%sp + 2047 + 128 + 0x08]
171 stx %g2, [%sp + 2047 + 128 + 0x10]
172 sethi %hi(itlb_load), %g2
173 or %g2, %lo(itlb_load), %g2
174 stx %g2, [%sp + 2047 + 128 + 0x18]
175 sethi %hi(prom_mmu_ihandle_cache), %g2
176 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
177 stx %g2, [%sp + 2047 + 128 + 0x20]
178 sethi %hi(KERNBASE + 0x400000), %g2
179 stx %g2, [%sp + 2047 + 128 + 0x28]
180 sethi %hi(kern_locked_tte_data), %g2
181 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
182 sethi %hi(0x400000), %g1
184 stx %g2, [%sp + 2047 + 128 + 0x30]
187 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
191 stx %g2, [%sp + 2047 + 128 + 0x38]
192 sethi %hi(p1275buf), %g2
193 or %g2, %lo(p1275buf), %g2
194 ldx [%g2 + 0x08], %o1
196 add %sp, (2047 + 128), %o0
199 sethi %hi(call_method), %g2
200 or %g2, %lo(call_method), %g2
201 stx %g2, [%sp + 2047 + 128 + 0x00]
203 stx %g2, [%sp + 2047 + 128 + 0x08]
205 stx %g2, [%sp + 2047 + 128 + 0x10]
206 sethi %hi(dtlb_load), %g2
207 or %g2, %lo(dtlb_load), %g2
208 stx %g2, [%sp + 2047 + 128 + 0x18]
209 sethi %hi(prom_mmu_ihandle_cache), %g2
210 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
211 stx %g2, [%sp + 2047 + 128 + 0x20]
212 sethi %hi(KERNBASE), %g2
213 stx %g2, [%sp + 2047 + 128 + 0x28]
214 sethi %hi(kern_locked_tte_data), %g2
215 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
216 stx %g2, [%sp + 2047 + 128 + 0x30]
219 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
224 stx %g2, [%sp + 2047 + 128 + 0x38]
225 sethi %hi(p1275buf), %g2
226 or %g2, %lo(p1275buf), %g2
227 ldx [%g2 + 0x08], %o1
229 add %sp, (2047 + 128), %o0
231 sethi %hi(bigkernel), %g2
232 lduw [%g2 + %lo(bigkernel)], %g2
233 brz,pt %g2, do_unlock
236 sethi %hi(call_method), %g2
237 or %g2, %lo(call_method), %g2
238 stx %g2, [%sp + 2047 + 128 + 0x00]
240 stx %g2, [%sp + 2047 + 128 + 0x08]
242 stx %g2, [%sp + 2047 + 128 + 0x10]
243 sethi %hi(dtlb_load), %g2
244 or %g2, %lo(dtlb_load), %g2
245 stx %g2, [%sp + 2047 + 128 + 0x18]
246 sethi %hi(prom_mmu_ihandle_cache), %g2
247 lduw [%g2 + %lo(prom_mmu_ihandle_cache)], %g2
248 stx %g2, [%sp + 2047 + 128 + 0x20]
249 sethi %hi(KERNBASE + 0x400000), %g2
250 stx %g2, [%sp + 2047 + 128 + 0x28]
251 sethi %hi(kern_locked_tte_data), %g2
252 ldx [%g2 + %lo(kern_locked_tte_data)], %g2
253 sethi %hi(0x400000), %g1
255 stx %g2, [%sp + 2047 + 128 + 0x30]
258 BRANCH_IF_ANY_CHEETAH(g1,g5,1f)
263 stx %g2, [%sp + 2047 + 128 + 0x38]
264 sethi %hi(p1275buf), %g2
265 or %g2, %lo(p1275buf), %g2
266 ldx [%g2 + 0x08], %o1
268 add %sp, (2047 + 128), %o0
271 sethi %hi(prom_entry_lock), %g2
272 stb %g0, [%g2 + %lo(prom_entry_lock)]
273 membar #StoreStore | #StoreLoad
275 ba,pt %xcc, after_lock_tlb
279 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
280 sethi %hi(KERNBASE), %o0
282 sethi %hi(kern_locked_tte_data), %o2
283 ldx [%o2 + %lo(kern_locked_tte_data)], %o2
287 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
288 sethi %hi(KERNBASE), %o0
290 sethi %hi(kern_locked_tte_data), %o2
291 ldx [%o2 + %lo(kern_locked_tte_data)], %o2
295 sethi %hi(bigkernel), %g2
296 lduw [%g2 + %lo(bigkernel)], %g2
297 brz,pt %g2, after_lock_tlb
300 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
301 sethi %hi(KERNBASE + 0x400000), %o0
303 sethi %hi(kern_locked_tte_data), %o2
304 ldx [%o2 + %lo(kern_locked_tte_data)], %o2
305 sethi %hi(0x400000), %o3
310 mov HV_FAST_MMU_MAP_PERM_ADDR, %o5
311 sethi %hi(KERNBASE + 0x400000), %o0
313 sethi %hi(kern_locked_tte_data), %o2
314 ldx [%o2 + %lo(kern_locked_tte_data)], %o2
315 sethi %hi(0x400000), %o3
321 wrpr %g0, (PSTATE_PRIV | PSTATE_PEF), %pstate
326 mov PRIMARY_CONTEXT, %g7
328 661: stxa %g0, [%g7] ASI_DMMU
329 .section .sun4v_1insn_patch, "ax"
331 stxa %g0, [%g7] ASI_MMU
335 mov SECONDARY_CONTEXT, %g7
337 661: stxa %g0, [%g7] ASI_DMMU
338 .section .sun4v_1insn_patch, "ax"
340 stxa %g0, [%g7] ASI_MMU
345 /* Everything we do here, until we properly take over the
346 * trap table, must be done with extreme care. We cannot
347 * make any references to %g6 (current thread pointer),
348 * %g4 (current task pointer), or %g5 (base of current cpu's
349 * per-cpu area) until we properly take over the trap table
350 * from the firmware and hypervisor.
352 * Get onto temporary stack which is in the locked kernel image.
354 sethi %hi(tramp_stack), %g1
355 or %g1, %lo(tramp_stack), %g1
356 add %g1, TRAMP_STACK_SIZE, %g1
357 sub %g1, STACKFRAME_SZ + STACK_BIAS + 256, %sp
360 /* Put garbage in these registers to trap any access to them. */
365 call init_irqwork_curcpu
368 sethi %hi(tlb_type), %g3
369 lduw [%g3 + %lo(tlb_type)], %g2
374 call hard_smp_processor_id
377 call sun4v_register_mondo_queues
380 1: call init_cur_cpu_trap
383 /* Start using proper page size encodings in ctx register. */
384 sethi %hi(sparc64_kern_pri_context), %g3
385 ldx [%g3 + %lo(sparc64_kern_pri_context)], %g2
386 mov PRIMARY_CONTEXT, %g1
388 661: stxa %g2, [%g1] ASI_DMMU
389 .section .sun4v_1insn_patch, "ax"
391 stxa %g2, [%g1] ASI_MMU
398 /* As a hack, put &init_thread_union into %g6.
399 * prom_world() loads from here to restore the %asi
402 sethi %hi(init_thread_union), %g6
403 or %g6, %lo(init_thread_union), %g6
405 sethi %hi(is_sun4v), %o0
406 lduw [%o0 + %lo(is_sun4v)], %o0
410 TRAP_LOAD_TRAP_BLOCK(%g2, %g3)
411 add %g2, TRAP_PER_CPU_FAULT_INFO, %g2
412 stxa %g2, [%g0] ASI_SCRATCHPAD
414 /* Compute physical address:
416 * paddr = kern_base + (mmfsa_vaddr - KERNBASE)
418 sethi %hi(KERNBASE), %g3
420 sethi %hi(kern_base), %g3
421 ldx [%g3 + %lo(kern_base)], %g3
423 sethi %hi(sparc64_ttable_tl0), %o0
425 set prom_set_trap_table_name, %g2
426 stx %g2, [%sp + 2047 + 128 + 0x00]
428 stx %g2, [%sp + 2047 + 128 + 0x08]
430 stx %g2, [%sp + 2047 + 128 + 0x10]
431 stx %o0, [%sp + 2047 + 128 + 0x18]
432 stx %o1, [%sp + 2047 + 128 + 0x20]
433 sethi %hi(p1275buf), %g2
434 or %g2, %lo(p1275buf), %g2
435 ldx [%g2 + 0x08], %o1
437 add %sp, (2047 + 128), %o0
442 1: sethi %hi(sparc64_ttable_tl0), %o0
443 set prom_set_trap_table_name, %g2
444 stx %g2, [%sp + 2047 + 128 + 0x00]
446 stx %g2, [%sp + 2047 + 128 + 0x08]
448 stx %g2, [%sp + 2047 + 128 + 0x10]
449 stx %o0, [%sp + 2047 + 128 + 0x18]
450 sethi %hi(p1275buf), %g2
451 or %g2, %lo(p1275buf), %g2
452 ldx [%g2 + 0x08], %o1
454 add %sp, (2047 + 128), %o0
457 ldx [%g6 + TI_TASK], %g4
460 sllx %g5, THREAD_SHIFT, %g5
461 sub %g5, (STACKFRAME_SZ + STACK_BIAS), %g5
466 or %o1, PSTATE_IE, %o1
478 sparc64_cpu_startup_end: