mpboot.S revision 210038
1203697Sneel/*- 2203697Sneel * Copyright (c) 2010 Neelkanth Natu 3203697Sneel * All rights reserved. 4203697Sneel * 5203697Sneel * Redistribution and use in source and binary forms, with or without 6203697Sneel * modification, are permitted provided that the following conditions 7203697Sneel * are met: 8203697Sneel * 1. Redistributions of source code must retain the above copyright 9203697Sneel * notice, this list of conditions and the following disclaimer. 10203697Sneel * 2. Redistributions in binary form must reproduce the above copyright 11203697Sneel * notice, this list of conditions and the following disclaimer in the 12203697Sneel * documentation and/or other materials provided with the distribution. 13203697Sneel * 14203697Sneel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15203697Sneel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16203697Sneel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17203697Sneel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18203697Sneel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19203697Sneel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20203697Sneel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21203697Sneel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22203697Sneel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23203697Sneel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24203697Sneel * SUCH DAMAGE. 25203697Sneel * 26203697Sneel * $FreeBSD: head/sys/mips/mips/mpboot.S 210038 2010-07-14 00:41:22Z imp $ 27203697Sneel */ 28203697Sneel 29203697Sneel#include <machine/asm.h> 30203697Sneel#include <machine/cpu.h> 31203697Sneel#include <machine/cpuregs.h> 32203697Sneel 33203697Sneel#include "assym.s" 34203697Sneel 35203697Sneel .text 36203697Sneel .set noat 37203697Sneel .set noreorder 38203697Sneel 39206721Sjmallett#ifdef TARGET_OCTEON 40206721Sjmallett#define CLEAR_STATUS \ 41210038Simp mfc0 a0, MIPS_COP_0_STATUS ;\ 42206721Sjmallett li a2, (MIPS_SR_KX | MIPS_SR_SX | MIPS_SR_UX) ; \ 43206721Sjmallett or a0, a0, a2 ; \ 44210038Simp li a2, ~(MIPS_SR_INT_IE | MIPS_SR_EXL | SR_KSU_USER | MIPS_SR_BEV) ; \ 45206721Sjmallett and a0, a0, a2 ; \ 46210038Simp mtc0 a0, MIPS_COP_0_STATUS 47206721Sjmallett#else 48206721Sjmallett#define CLEAR_STATUS \ 49210038Simp mtc0 zero, MIPS_COP_0_STATUS 50206721Sjmallett#endif 51206721Sjmallett 52203697SneelGLOBAL(mpentry) 53206721Sjmallett CLEAR_STATUS /* disable interrupts */ 54203697Sneel 55210038Simp mtc0 zero, MIPS_COP_0_CAUSE /* clear soft interrupts */ 56203697Sneel 57210038Simp li t0, MIPS_CCA_CNC /* make sure kseg0 is cached */ 58203697Sneel mtc0 t0, MIPS_COP_0_CONFIG 59203697Sneel COP0_SYNC 60203697Sneel 61203697Sneel jal platform_processor_id /* get the processor number */ 62203697Sneel nop 63203697Sneel move s0, v0 64203697Sneel 65203697Sneel /* 66203697Sneel * Initialize stack and call machine startup 67203697Sneel */ 68203697Sneel PTR_LA sp, _C_LABEL(pcpu_space) 69206746Sjmallett addiu sp, (PAGE_SIZE * 2) - CALLFRAME_SIZ 70203697Sneel sll t0, s0, PAGE_SHIFT + 1 71203697Sneel addu sp, sp, t0 72203697Sneel 73203697Sneel /* Zero out old ra and old fp for debugger */ 74204617Simp sw zero, CALLFRAME_SIZ - 4(sp) 75204617Simp sw zero, CALLFRAME_SIZ - 8(sp) 76203697Sneel 77203697Sneel PTR_LA gp, _C_LABEL(_gp) 78203697Sneel 79203697Sneel jal platform_init_ap 80203697Sneel move a0, s0 81203697Sneel jal smp_init_secondary 82203697Sneel move a0, s0 83203697Sneel 84203697Sneel PANIC("AP startup failed!") 85