Resent-Date: Fri, 10 Sep 1999 19:24:05 +0200 (MET DST)
Date: Fri, 10 Sep 1999 19:23:35 +0200 (MET DST)
From: Roman Zippel <zippel@fh-brandenburg.de>
X-Sender: zippel@zeus
To: Linux/m68k <linux-m68k@lists.linux-m68k.org>
Subject: fpu detection patch
Resent-From: linux-m68k@phil.uni-sb.de

Hi,

here is a simple fpu detection, the patch is against my current
2.3.16 sources.

bye, Roman

--- arch/m68k/kernel/setup.c.org	Fri Sep 10 18:58:31 1999
+++ arch/m68k/kernel/setup.c	Fri Sep 10 19:13:53 1999
@@ -217,18 +217,28 @@
 
 	base_trap_init();
 
-	/* FIXME: m68k_fputype is passed in by Penguin booter, which can
-	 * be confused by software FPU emulation. BEWARE.
-	 * We should really do our own FPU check at startup.
-	 * [what do we do with buggy 68LC040s? if we have problems
-	 *  with them, we should add a test to check_bugs() below] */
-#ifndef CONFIG_M68KFPU_EMU_ONLY
-	/* clear the fpu if we have one */
+	/* Check if we have a fpu and clear it, we do now our own FPU check at
+	 * startup. (The Penguin booter can be confused by software FPU emulation.)
+	 */
 	if (m68k_fputype & (FPU_68881|FPU_68882|FPU_68040|FPU_68060)) {
+		e_vector oldvec = vectors[VEC_LINE11];
+		extern void fpu_check(void);
 		volatile int zero = 0;
-		asm __volatile__ ("frestore %0" : : "m" (zero));
+
+		vectors[VEC_LINE11] = fpu_check;
+
+		asm volatile (
+			"	frestore %0\n"
+			"	jra 1f\n"
+			SYMBOL_NAME_STR(fpu_check)":\n"
+			"	clrl "SYMBOL_NAME_STR(m68k_fputype)"\n"
+			"	movel #1f,%%sp@(2)\n"
+			"	rte\n"
+			"1:"
+			: : "m" (zero) : "memory");
+
+		vectors[VEC_LINE11] = oldvec;
 	}
-#endif	
 
 	init_mm.start_code = PAGE_OFFSET;
 	init_mm.end_code = (unsigned long) &_etext;


