Detect FPU by checking CPUID features.
authorAlexander Polakov <polachok@gmail.com>
Thu, 26 Nov 2009 17:17:34 +0000 (20:17 +0300)
committerAlexander Polakov <polachok@gmail.com>
Thu, 26 Nov 2009 17:17:34 +0000 (20:17 +0300)
Fixes problems on AMD Geode LX-800.

Reported-by: bleader <bleader@ratonland.org>
Obtained-from: FreeBSD

sys/platform/pc32/isa/npx.c

index 6f99b4f..858f7c4 100644 (file)
@@ -310,18 +310,19 @@ npx_probe1(device_t dev)
         */
        fninit();
 
-#ifdef SMP
+       device_set_desc(dev, "math processor");
        /*
-        * Exception 16 MUST work for SMP.
+        * Modern CPUs all have an FPU that uses the INT16 interface
+        * and provide a simple way to verify that, so handle the
+        * common case right away.
         */
-       npx_irq13 = 0;
-       npx_ex16 = hw_float = npx_exists = 1;
-       device_set_desc(dev, "math processor");
-       return (0);
-
-#else /* !SMP */
-       device_set_desc(dev, "math processor");
+       if (cpu_feature & CPUID_FPU) {
+               npx_irq13 = 0;
+               npx_ex16 = hw_float = npx_exists = 1;
+               return (0);
+       }
 
+#ifndef SMP
        /*
         * Don't use fwait here because it might hang.
         * Don't use fnop here because it usually hangs if there is no FPU.