xref: /OK3568_Linux_fs/kernel/arch/sparc/prom/mp.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * mp.c:  OpenBoot Prom Multiprocessor support routines.  Don't call
4*4882a593Smuzhiyun  *        these on a UP or else you will halt and catch fire. ;)
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/types.h>
10*4882a593Smuzhiyun #include <linux/kernel.h>
11*4882a593Smuzhiyun #include <linux/sched.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <asm/openprom.h>
14*4882a593Smuzhiyun #include <asm/oplib.h>
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun extern void restore_current(void);
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /* Start cpu with prom-tree node 'cpunode' using context described
19*4882a593Smuzhiyun  * by 'ctable_reg' in context 'ctx' at program counter 'pc'.
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * XXX Have to look into what the return values mean. XXX
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun int
prom_startcpu(int cpunode,struct linux_prom_registers * ctable_reg,int ctx,char * pc)24*4882a593Smuzhiyun prom_startcpu(int cpunode, struct linux_prom_registers *ctable_reg, int ctx, char *pc)
25*4882a593Smuzhiyun {
26*4882a593Smuzhiyun 	int ret;
27*4882a593Smuzhiyun 	unsigned long flags;
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun 	spin_lock_irqsave(&prom_lock, flags);
30*4882a593Smuzhiyun 	switch(prom_vers) {
31*4882a593Smuzhiyun 	case PROM_V0:
32*4882a593Smuzhiyun 	case PROM_V2:
33*4882a593Smuzhiyun 	default:
34*4882a593Smuzhiyun 		ret = -1;
35*4882a593Smuzhiyun 		break;
36*4882a593Smuzhiyun 	case PROM_V3:
37*4882a593Smuzhiyun 		ret = (*(romvec->v3_cpustart))(cpunode, (int) ctable_reg, ctx, pc);
38*4882a593Smuzhiyun 		break;
39*4882a593Smuzhiyun 	}
40*4882a593Smuzhiyun 	restore_current();
41*4882a593Smuzhiyun 	spin_unlock_irqrestore(&prom_lock, flags);
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun 	return ret;
44*4882a593Smuzhiyun }
45