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

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

diff -u --recursive --new-file v2.1.8/linux/arch/sparc/prom/console.c linux/arch/sparc/prom/console.c
@@ -1,4 +1,4 @@
-/* $Id: console.c,v 1.8 1996/04/05 07:44:35 tridge Exp $
+/* $Id: console.c,v 1.9 1996/09/19 20:27:17 davem Exp $
  * console.c: Routines that deal with sending and receiving IO
  *            to/from the current console device using the PROM.
  *
@@ -6,8 +6,12 @@
  */
 
 #include <linux/config.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
 #include <asm/openprom.h>
 #include <asm/oplib.h>
+#include <asm/system.h>
 #include <linux/string.h>
 
 /* Non blocking get character from console input device, returns -1
@@ -17,23 +21,32 @@
 prom_nbgetchar(void)
 {
 	static char inc;
+	int i = -1;
+	unsigned long flags;
 
+	save_flags(flags); cli();
 	switch(prom_vers) {
 	case PROM_V0:
-		return (*(romvec->pv_nbgetchar))();
+		i = (*(romvec->pv_nbgetchar))();
 		break;
 	case PROM_V2:
 	case PROM_V3:
 	case PROM_P1275:
-		if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1)
-			return inc;
-		return -1;
+		if( (*(romvec->pv_v2devops).v2_dev_read)(*romvec->pv_v2bootargs.fd_stdin , &inc, 0x1) == 1) {
+			i = inc;
+		} else {
+			i = -1;
+		}
 		break;
 	case PROM_AP1000:
-		return -1;
+		i = -1;
 		break;
 	};
-	return 0; /* Ugh, we could spin forever on unsupported proms ;( */
+	__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+			     "r" (&current_set[smp_processor_id()]) :
+			     "memory");
+	restore_flags(flags);
+	return i; /* Ugh, we could spin forever on unsupported proms ;( */
 }
 
 /* Non blocking put character to console device, returns -1 if
@@ -43,30 +56,41 @@
 prom_nbputchar(char c)
 {
 	static char outc;
+	unsigned long flags;
+	int i = -1;
 
+	save_flags(flags); cli();
 	switch(prom_vers) {
 	case PROM_V0:
-		return (*(romvec->pv_nbputchar))(c);
+		i = (*(romvec->pv_nbputchar))(c);
 		break;
 	case PROM_V2:
 	case PROM_V3:
 	case PROM_P1275:
 		outc = c;
 		if( (*(romvec->pv_v2devops).v2_dev_write)(*romvec->pv_v2bootargs.fd_stdout, &outc, 0x1) == 1)
-			return 0;
-		return -1;
+			i = 0;
+		else
+			i = -1;
 		break;
 	case PROM_AP1000:
 #if CONFIG_AP1000
 		{
 		  extern void ap_putchar(char );
 		  ap_putchar(c);
-		  return 0;
+		  i = 0;
 		}
+#else
+                i = -1;
 #endif
+	
 		break;
 	};
-	return 0; /* Ugh, we could spin forever on unsupported proms ;( */
+	__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+			     "r" (&current_set[smp_processor_id()]) :
+			     "memory");
+	restore_flags(flags);
+	return i; /* Ugh, we could spin forever on unsupported proms ;( */
 }
 
 /* Blocking version of get character routine above. */
@@ -90,6 +114,7 @@
 enum prom_input_device
 prom_query_input_device()
 {
+	unsigned long flags;
 	int st_p;
 	char propb[64];
 	char *p;
@@ -107,7 +132,12 @@
 		};
 	case PROM_V3:
 	case PROM_P1275:
+		save_flags(flags); cli();
 		st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdin);
+		__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+				     "r" (&current_set[smp_processor_id()]) :
+				     "memory");
+		restore_flags(flags);
 		if(prom_node_has_property(st_p, "keyboard"))
 			return PROMDEV_IKBD;
 		prom_getproperty(st_p, "device_type", propb, sizeof(propb));
@@ -133,6 +163,7 @@
 enum prom_output_device
 prom_query_output_device()
 {
+	unsigned long flags;
 	int st_p;
 	char propb[64];
 	char *p;
@@ -149,7 +180,12 @@
 	case PROM_V2:
 	case PROM_V3:
 	case PROM_P1275:
+		save_flags(flags); cli();
 		st_p = (*romvec->pv_v2devops.v2_inst2pkg)(*romvec->pv_v2bootargs.fd_stdout);
+		__asm__ __volatile__("ld [%0], %%g6\n\t" : :
+				     "r" (&current_set[smp_processor_id()]) :
+				     "memory");
+		restore_flags(flags);
 		propl = prom_getproperty(st_p, "device_type", propb, sizeof(propb));
 		if (propl >= 0 && propl == sizeof("display") &&
 			strncmp("display", propb, sizeof("display")) == 0)

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