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/ktr.h>
33 #include <machine/pstate.h>
34 #include <machine/upa.h>
38 .register %g2, #ignore
39 .register %g3, #ignore
44 ldx [%l0 + (4f-1b)], %l1
50 ldx [%l2 + TTE_VPN], %l4
51 ldx [%l2 + TTE_DATA], %l5
52 srlx %l4, TV_SIZE_BITS, %l4
53 sllx %l4, PAGE_SHIFT_4M, %l4
54 wr %g0, ASI_DMMU, %asi
55 stxa %l4, [%g0 + AA_DMMU_TAR] %asi
56 stxa %l5, [%g0] ASI_DTLB_DATA_IN_REG
57 wr %g0, ASI_IMMU, %asi
58 stxa %l4, [%g0 + AA_IMMU_TAR] %asi
59 stxa %l5, [%g0] ASI_ITLB_DATA_IN_REG
62 add %l2, 1 << TTE_SHIFT, %l2
66 3: ldx [%l0 + (5f-1b)], %l1
76 DATA(mp_tramp_code_len)
78 DATA(mp_tramp_tlb_slots)
84 * void mp_startup(void)
87 wrpr %g0, PSTATE_NORMAL, %pstate
88 wrpr %g0, 0, %cleanwin
92 SET(cpu_start_args, %l1, %l0)
96 stw %l1, [%l0 + CSA_STATE]
98 1: ldx [%l0 + CSA_TICK], %l1
105 #if KTR_COMPILE & KTR_SMP
106 CATR(KTR_SMP, "mp_start: cpu %d entered kernel"
107 , %g1, %g2, %g3, 7, 8, 9)
108 stx %o0, [%g1 + KTR_PARM1]
113 stx %l1, [%l0 + CSA_VER]
116 * Inform the boot processor we have inited.
120 stw %l1, [%l0 + CSA_STATE]
123 * Wait till its our turn to bootstrap.
125 2: lduw [%l0 + CSA_MID], %l1
130 #if KTR_COMPILE & KTR_SMP
131 CATR(KTR_SMP, "_mp_start: cpu %d got start signal"
132 , %g1, %g2, %g3, 7, 8, 9)
133 stx %o0, [%g1 + KTR_PARM1]
137 add %l0, CSA_TTES, %l1
141 * Map the per-cpu pages.
143 3: sllx %l2, TTE_SHIFT, %l3
146 ldx [%l3 + TTE_VPN], %l4
147 ldx [%l3 + TTE_DATA], %l5
149 wr %g0, ASI_DMMU, %asi
150 srlx %l4, TV_SIZE_BITS, %l4
151 sllx %l4, PAGE_SHIFT_8K, %l4
152 stxa %l4, [%g0 + AA_DMMU_TAR] %asi
153 stxa %l5, [%g0] ASI_DTLB_DATA_IN_REG
162 * Get onto our per-cpu panic stack, which precedes the struct pcpu
163 * in the per-cpu page.
165 ldx [%l0 + CSA_PCPU], %l1
166 set PCPU_PAGES * PAGE_SIZE - PC_SIZEOF, %l2
168 sub %l1, SPOFF + CCFSZ, %sp
173 wrpr %g0, PSTATE_KERNEL, %pstate
175 #if KTR_COMPILE & KTR_SMP
177 "_mp_start: bootstrap cpuid=%d mid=%d pcpu=%#lx data=%#lx sp=%#lx"
178 , %g1, %g2, %g3, 7, 8, 9)
179 lduw [%l1 + PC_CPUID], %g2
180 stx %g2, [%g1 + KTR_PARM1]
181 lduw [%l1 + PC_MID], %g2
182 stx %g2, [%g1 + KTR_PARM2]
183 stx %l1, [%g1 + KTR_PARM3]
184 stx %sp, [%g1 + KTR_PARM5]
189 * And away we go. This doesn't return.
191 call cpu_mp_bootstrap