mp_locore.S revision 89051
189051Sjake/*- 289051Sjake * Copyright (c) 2002 Jake Burkholder. 389051Sjake * All rights reserved. 489051Sjake * 589051Sjake * Redistribution and use in source and binary forms, with or without 689051Sjake * modification, are permitted provided that the following conditions 789051Sjake * are met: 889051Sjake * 1. Redistributions of source code must retain the above copyright 989051Sjake * notice, this list of conditions and the following disclaimer. 1089051Sjake * 2. Redistributions in binary form must reproduce the above copyright 1189051Sjake * notice, this list of conditions and the following disclaimer in the 1289051Sjake * documentation and/or other materials provided with the distribution. 1389051Sjake * 1489051Sjake * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1589051Sjake * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1689051Sjake * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1789051Sjake * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1889051Sjake * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1989051Sjake * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2089051Sjake * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2189051Sjake * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2289051Sjake * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2389051Sjake * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2489051Sjake * SUCH DAMAGE. 2589051Sjake * 2689051Sjake * $FreeBSD: head/sys/sparc64/sparc64/mp_locore.S 89051 2002-01-08 05:50:26Z jake $ 2789051Sjake */ 2889051Sjake 2989051Sjake#include <machine/asi.h> 3089051Sjake#include <machine/asmacros.h> 3189051Sjake#include <machine/ktr.h> 3289051Sjake#include <machine/pstate.h> 3389051Sjake 3489051Sjake#include "assym.s" 3589051Sjake 3689051Sjake .register %g2, #ignore 3789051Sjake .register %g3, #ignore 3889051Sjake 3989051Sjake/* 4089051Sjake * void _mp_start(u_long o0, u_int *state, u_int mid, u_long o3, u_long o4) 4189051Sjake */ 4289051SjakeENTRY(_mp_start) 4389051Sjake /* 4489051Sjake * Give away our stack to another processor that may be starting in the 4589051Sjake * loader. 4689051Sjake */ 4789051Sjake clr %sp 4889051Sjake 4989051Sjake /* 5089051Sjake * Inform the boot processor which is waiting in the loader that we 5189051Sjake * made it. 5289051Sjake */ 5389051Sjake mov CPU_INITED, %l0 5489051Sjake stw %l0, [%o1] 5589051Sjake membar #StoreLoad 5689051Sjake 5789051Sjake#if KTR_COMPILE & KTR_SMP 5889051Sjake CATR(KTR_SMP, "_mp_start: cpu %d entered kernel" 5989051Sjake , %g1, %g2, %g3, 7, 8, 9) 6089051Sjake stx %o2, [%g1 + KTR_PARM1] 6189051Sjake9: 6289051Sjake#endif 6389051Sjake 6489051Sjake SET(cpu_start_args, %l1, %l0) 6589051Sjake 6689051Sjake /* 6789051Sjake * Wait till its our turn to start. 6889051Sjake */ 6989051Sjake1: membar #StoreLoad 7089051Sjake lduw [%l0 + CSA_MID], %l1 7189051Sjake cmp %l1, %o2 7289051Sjake bne %xcc, 1b 7389051Sjake nop 7489051Sjake 7589051Sjake#if KTR_COMPILE & KTR_SMP 7689051Sjake CATR(KTR_SMP, "_mp_start: cpu %d got start signal" 7789051Sjake , %g1, %g2, %g3, 7, 8, 9) 7889051Sjake stx %o2, [%g1 + KTR_PARM1] 7989051Sjake9: 8089051Sjake#endif 8189051Sjake 8289051Sjake /* 8389051Sjake * Find our per-cpu page and the tte data that we will use to map it. 8489051Sjake */ 8589051Sjake ldx [%l0 + CSA_DATA], %l1 8689051Sjake ldx [%l0 + CSA_VA], %l2 8789051Sjake 8889051Sjake /* 8989051Sjake * Map the per-cpu page. It uses a locked tlb entry. 9089051Sjake */ 9189051Sjake wr %g0, ASI_DMMU, %asi 9289051Sjake stxa %l2, [%g0 + AA_DMMU_TAR] %asi 9389051Sjake stxa %l1, [%g0] ASI_DTLB_DATA_IN_REG 9489051Sjake membar #Sync 9589051Sjake 9689051Sjake /* 9789051Sjake * Get onto our per-cpu panic stack, which precedes the struct pcpu 9889051Sjake * in the per-cpu page. 9989051Sjake */ 10089051Sjake set PAGE_SIZE - PC_SIZEOF, %l3 10189051Sjake add %l2, %l3, %l2 10289051Sjake sub %l2, SPOFF + CCFSZ, %sp 10389051Sjake 10489051Sjake /* 10589051Sjake * Inform the boot processor that we're about to start. 10689051Sjake */ 10789051Sjake mov CPU_STARTED, %l3 10889051Sjake stw %l3, [%l0 + CSA_STATE] 10989051Sjake membar #StoreLoad 11089051Sjake 11189051Sjake /* 11289051Sjake * Enable interrupts. 11389051Sjake */ 11489051Sjake wrpr %g0, PSTATE_KERNEL, %pstate 11589051Sjake 11689051Sjake#if KTR_COMPILE & KTR_SMP 11789051Sjake CATR(KTR_SMP, 11889051Sjake "_mp_start: bootstrap cpuid=%d mid=%d pcpu=%#lx data=%#lx sp=%#lx" 11989051Sjake , %g1, %g2, %g3, 7, 8, 9) 12089051Sjake lduw [%l2 + PC_CPUID], %g2 12189051Sjake stx %g2, [%g1 + KTR_PARM1] 12289051Sjake lduw [%l2 + PC_MID], %g2 12389051Sjake stx %g2, [%g1 + KTR_PARM2] 12489051Sjake stx %l2, [%g1 + KTR_PARM3] 12589051Sjake stx %l1, [%g1 + KTR_PARM4] 12689051Sjake stx %sp, [%g1 + KTR_PARM5] 12789051Sjake9: 12889051Sjake#endif 12989051Sjake 13089051Sjake /* 13189051Sjake * And away we go. This doesn't return. 13289051Sjake */ 13389051Sjake call cpu_mp_bootstrap 13489051Sjake mov %l2, %o0 13589051Sjake sir 13689051Sjake ! NOTREACHED 13789051SjakeEND(_mp_start) 138