patch-2.1.9 linux/arch/sparc/prom/mp.c

Next file: linux/arch/sparc/prom/ranges.c
Previous file: linux/arch/sparc/prom/misc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.8/linux/arch/sparc/prom/mp.c linux/arch/sparc/prom/mp.c
@@ -1,10 +1,14 @@
-/* $Id: mp.c,v 1.5 1996/04/04 16:31:06 tridge Exp $
+/* $Id: mp.c,v 1.6 1996/09/19 20:27:25 davem Exp $
  * mp.c:  OpenBoot Prom Multiprocessor support routines.  Don't call
  *        these on a UP or else you will halt and catch fire. ;)
  *
  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  */
 
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+
 #include <asm/openprom.h>
 #include <asm/oplib.h>
 
@@ -16,18 +20,28 @@
 int
 prom_startcpu(int cpunode, struct linux_prom_registers *ctable_reg, int ctx, char *pc)
 {
+	int ret;
+	unsigned long flags;
+
+	save_flags(flags); cli();
 	switch(prom_vers) {
 	case PROM_V0:
 	case PROM_V2:
 	case PROM_AP1000:
+	default:
+		ret = -1;
 		break;
 	case PROM_V3:
 	case PROM_P1275:
-		return (*(romvec->v3_cpustart))(cpunode, (int) ctable_reg, ctx, pc);
+		ret = (*(romvec->v3_cpustart))(cpunode, (int) ctable_reg, ctx, pc);
 		break;
 	};
+	__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+			     "r" (&current_set[smp_processor_id()]) :
+			     "memory");
+	restore_flags(flags);
 
-	return -1;
+	return ret;
 }
 
 /* Stop CPU with device prom-tree node 'cpunode'.
@@ -36,18 +50,28 @@
 int
 prom_stopcpu(int cpunode)
 {
+	int ret;
+	unsigned long flags;
+
+	save_flags(flags); cli();
 	switch(prom_vers) {
 	case PROM_V0:
 	case PROM_V2:
 	case PROM_AP1000:
+	default:
+		ret = -1;
 		break;
 	case PROM_V3:
 	case PROM_P1275:
-		return (*(romvec->v3_cpustop))(cpunode);
+		ret = (*(romvec->v3_cpustop))(cpunode);
 		break;
 	};
+	__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+			     "r" (&current_set[smp_processor_id()]) :
+			     "memory");
+	restore_flags(flags);
 
-	return -1;
+	return ret;
 }
 
 /* Make CPU with device prom-tree node 'cpunode' idle.
@@ -56,18 +80,28 @@
 int
 prom_idlecpu(int cpunode)
 {
+	int ret;
+	unsigned long flags;
+
+	save_flags(flags); cli();
 	switch(prom_vers) {
 	case PROM_V0:
 	case PROM_V2:
 	case PROM_AP1000:
+	default:
+		ret = -1;
 		break;
 	case PROM_V3:
 	case PROM_P1275:
-		return (*(romvec->v3_cpuidle))(cpunode);
+		ret = (*(romvec->v3_cpuidle))(cpunode);
 		break;
 	};
+	__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+			     "r" (&current_set[smp_processor_id()]) :
+			     "memory");
+	restore_flags(flags);
 
-	return -1;
+	return ret;
 }
 
 /* Resume the execution of CPU with nodeid 'cpunode'.
@@ -76,16 +110,26 @@
 int
 prom_restartcpu(int cpunode)
 {
+	int ret;
+	unsigned long flags;
+
+	save_flags(flags); cli();
 	switch(prom_vers) {
 	case PROM_V0:
 	case PROM_V2:
 	case PROM_AP1000:
+	default:
+		ret = -1;
 		break;
 	case PROM_V3:
 	case PROM_P1275:
-		return (*(romvec->v3_cpuresume))(cpunode);
+		ret = (*(romvec->v3_cpuresume))(cpunode);
 		break;
 	};
+	__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+			     "r" (&current_set[smp_processor_id()]) :
+			     "memory");
+	restore_flags(flags);
 
-	return -1;
+	return ret;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov