1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 2013 Cavium, Inc
7  */
8 #ifndef __ASM_MACH_PARAVIRT_KERNEL_ENTRY_H
9 #define __ASM_MACH_PARAVIRT_KERNEL_ENTRY_H
10 
11 #define CP0_EBASE $15, 1
12 
13 	.macro  kernel_entry_setup
14 	mfc0	t0, CP0_EBASE
15 	andi	t0, t0, 0x3ff		# CPUNum
16 	beqz	t0, 1f
17 	# CPUs other than zero goto smp_bootstrap
18 	j	smp_bootstrap
19 
20 1:
21 	.endm
22 
23 /*
24  * Do SMP slave processor setup necessary before we can safely execute
25  * C code.
26  */
27 	.macro  smp_slave_setup
28 	mfc0	t0, CP0_EBASE
29 	andi	t0, t0, 0x3ff		# CPUNum
30 	slti	t1, t0, NR_CPUS
31 	bnez	t1, 1f
32 2:
33 	di
34 	wait
35 	b	2b			# Unknown CPU, loop forever.
36 1:
37 	PTR_LA	t1, paravirt_smp_sp
38 	PTR_SLL	t0, PTR_SCALESHIFT
39 	PTR_ADDU t1, t1, t0
40 3:
41 	PTR_L	sp, 0(t1)
42 	beqz	sp, 3b			# Spin until told to proceed.
43 
44 	PTR_LA	t1, paravirt_smp_gp
45 	PTR_ADDU t1, t1, t0
46 	sync
47 	PTR_L	gp, 0(t1)
48 	.endm
49 
50 #endif /* __ASM_MACH_PARAVIRT_KERNEL_ENTRY_H */
51