1195333Simp/*-
2195333Simp * Copyright (c) 2009 Neelkanth Natu
3195333Simp * All rights reserved.
4195333Simp *
5195333Simp * Redistribution and use in source and binary forms, with or without
6195333Simp * modification, are permitted provided that the following conditions
7195333Simp * are met:
8195333Simp * 1. Redistributions of source code must retain the above copyright
9195333Simp *    notice, this list of conditions and the following disclaimer.
10195333Simp * 2. Redistributions in binary form must reproduce the above copyright
11195333Simp *    notice, this list of conditions and the following disclaimer in the
12195333Simp *    documentation and/or other materials provided with the distribution.
13195333Simp *
14195333Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15195333Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16195333Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17195333Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18195333Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19195333Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20195333Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21195333Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22195333Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23195333Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24195333Simp * SUCH DAMAGE.
25203509Sneel *
26203509Sneel * $FreeBSD: releng/10.2/sys/mips/sibyte/sb_asm.S 205675 2010-03-26 07:15:27Z neel $
27195333Simp */
28195333Simp
29195333Simp#include <machine/asm.h>
30203697Sneel#include <machine/cpuregs.h>
31195333Simp
32195333Simp.set	mips64
33195333Simp.set	noat
34195333Simp.set	noreorder
35195333Simp
36203697Sneel#ifdef SMP
37203697Sneel/*
38203697Sneel * This function must be implemented in assembly because it is called early
39203697Sneel * in AP boot without a valid stack.
40203697Sneel *
41203697Sneel * This cpu number is available in bits 25 to 27 of the coprocessor 0 PRID
42203697Sneel * register. This is not documented in the BCM1250 user manual but can be
43203697Sneel * gleaned from the CFE source code - see sb1250_altcpu.S
44203697Sneel */
45203697SneelLEAF(platform_processor_id)
46203697Sneel	mfc0	v0, MIPS_COP_0_PRID
47203697Sneel	srl	v0, v0, 25
48203697Sneel	jr	ra
49203697Sneel	and	v0, v0, 7
50203697SneelEND(platform_processor_id)
51203697Sneel#endif	/* SMP */
52