2 * Copyright (c) 2002 Jake Burkholder.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <machine/asm.h>
28 __FBSDID("$FreeBSD$");
30 #include <machine/asi.h>
31 #include <machine/asmacros.h>
32 #include <machine/hypervisorvar.h>
33 #include <machine/intr_machdep.h>
34 #include <machine/ktr.h>
35 #include <machine/pstate.h>
36 #include <machine/smp.h>
40 .register %g2, #ignore
41 .register %g3, #ignore
46 1: rd %pc, %l0 ! startpc
47 mov %o0, %g1 ! save arg to to mp_tramp_func
48 ldx [%l0 + (6f-1b)], %l1 ! read mp_tramp_tte_slots
49 add %l0, (7f-1b), %l2 ! %l2 points to start of slot area
51 2: cmp %l3, %l1 ! number of slots entered == total?
56 ldx [%l2 + 8], %o2 ! TTE
57 mov MAP_ITLB|MAP_DTLB, %o3
58 mov MMU_MAP_PERM_ADDR, %o5
67 add %l2, 16, %l2 ! point %l2 at next slot
72 ldx [%l0 + (4f-1b)], %o1 ! read mp_tramp_tsb_ra
74 mov MMU_TSB_CTX0, %o5 ! set ctx0 TSBs
83 ldx [%l0 + (5f-1b)], %l1 ! fetch mp_tramp_func
84 jmpl %l1, %g0 ! and off we go
94 DATA(mp_tramp_code_len)
96 DATA(mp_tramp_tsb_desc_ra)
100 DATA(mp_tramp_tte_slots)
106 mov CONS_WRITE, %o5 ; \
109 * void mp_startup(void)
112 wrpr %g0, PSTATE_NORMAL, %pstate
113 wrpr %g0, 0, %cleanwin
117 SET(cpu_start_args, %l1, %l0)
118 #if KTR_COMPILE & KTR_SMP
119 CATR(KTR_SMP, "mp_start: cpu %d entered kernel"
120 , %g1, %g2, %g3, 7, 8, 9)
121 stx %o0, [%g1 + KTR_PARM1]
126 * Inform the boot processor we have inited.
130 stw %l1, [%l0 + CSA_STATE]
132 #if KTR_COMPILE & KTR_SMP
133 CATR(KTR_SMP, "_mp_start: cpu %d got start signal"
134 , %g1, %g2, %g3, 7, 8, 9)
135 stx %o0, [%g1 + KTR_PARM1]
139 ld [%l0 + CSA_CPUID], %l1
145 * Get onto our per-cpu panic stack, which precedes the struct pcpu
146 * in the per-cpu page.
148 ldx [%l0 + CSA_PCPU], %l1
149 set PCPU_PAGES * PAGE_SIZE - PC_SIZEOF, %l2
151 sub %l1, SPOFF + CCFSZ, %sp
152 wrpr %g0, PIL_TICK, %pil
153 #if KTR_COMPILE & KTR_SMP
155 "_mp_start: bootstrap cpuid=%d mid=%d pcpu=%#lx data=%#lx sp=%#lx"
156 , %g1, %g2, %g3, 7, 8, 9)
157 lduw [%l1 + PC_CPUID], %g2
158 stx %g2, [%g1 + KTR_PARM1]
159 lduw [%l1 + PC_MID], %g2
160 stx %g2, [%g1 + KTR_PARM2]
161 stx %l1, [%g1 + KTR_PARM3]
162 stx %sp, [%g1 + KTR_PARM5]
167 * And away we go. This doesn't return.
169 call cpu_mp_bootstrap