Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc/sparc Find the CPU architecture version early...



details:   https://anonhg.NetBSD.org/src/rev/cf881dde1d28
branches:  trunk
changeset: 539904:cf881dde1d28
user:      pk <pk%NetBSD.org@localhost>
date:      Fri Nov 29 08:02:05 2002 +0000

description:
Find the CPU architecture version early in the bootstrap phase, and switch
to the V8 specific .mul/.div/.rem routines while we still have a writable
.text section.

diffstat:

 sys/arch/sparc/sparc/autoconf.c |  43 ++++++++++++++++++++++++++++++----------
 sys/arch/sparc/sparc/cpu.c      |   9 ++++++-
 2 files changed, 39 insertions(+), 13 deletions(-)

diffs (101 lines):

diff -r bbadf7099d57 -r cf881dde1d28 sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c   Fri Nov 29 07:56:50 2002 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c   Fri Nov 29 08:02:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.182 2002/10/27 18:39:17 chs Exp $ */
+/*     $NetBSD: autoconf.c,v 1.183 2002/11/29 08:02:05 pk Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -160,26 +160,47 @@
        return (0);
 }
 
+/*
+ * Get the number of CPUs in the system and the CPUs' SPARC architecture
+ * version. We need this information early in the boot process.
+ */
 int
 find_cpus()
 {
-#if defined(MULTIPROCESSOR)
-       int node, n;
+       int n;
+#if defined(SUN4M) || defined(SUN4D)
+       int node;
+#endif
 
-       /* We only consider sun4m class multi-processor machines */
-       if (!CPU_ISSUN4M)
+       /*
+        * Set default processor architecture version
+        *
+        * All sun4 and sun4c platforms have v7 CPUs;
+        * sun4m may have v7 (Cyrus CY7C601 modules) or v8 CPUs (all
+        * other models, presumably).
+        */
+       cpu_arch = 7;
+
+       if (!CPU_ISSUN4M && !CPU_ISSUN4D)
                return (1);
 
        n = 0;
+#if defined(SUN4M) || defined(SUN4D)
        node = findroot();
        for (node = firstchild(node); node; node = nextsibling(node)) {
-               if (strcmp(PROM_getpropstring(node, "device_type"), "cpu") == 0)
-                       n++;
+               if (strcmp(PROM_getpropstring(node, "device_type"), "cpu") != 0)
+                       continue;
+               if (n++ == 0)
+                       cpu_arch = PROM_getpropint(node, "sparc-version", 7);
        }
+
+       /* Switch to sparc v8 multiply/divide functions on v8 machines */
+       if (cpu_arch == 8) {
+               extern void sparc_v8_muldiv(void);
+               sparc_v8_muldiv();
+       }
+#endif /* SUN4M || SUN4D */
        return (n);
-#else
-       return (1);
-#endif
 }
 
 /*
@@ -1333,7 +1354,7 @@
 
                (void) config_found(dev, (void *)&ma, mbprint);
        }
-#endif /* SUN4C || SUN4M */
+#endif /* SUN4C || SUN4M || SUN4D */
 }
 
 CFATTACH_DECL(mainbus, sizeof(struct device),
diff -r bbadf7099d57 -r cf881dde1d28 sys/arch/sparc/sparc/cpu.c
--- a/sys/arch/sparc/sparc/cpu.c        Fri Nov 29 07:56:50 2002 +0000
+++ b/sys/arch/sparc/sparc/cpu.c        Fri Nov 29 08:02:05 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.135 2002/11/28 15:29:53 pk Exp $ */
+/*     $NetBSD: cpu.c,v 1.136 2002/11/29 08:02:05 pk Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -1730,10 +1730,15 @@
                        mmu_vers = ANY;
                }
 
-               /* Get sparc architecture version */
+#if 0
+               /*
+                * Get sparc architecture version
+                * NOTE: This is now done much earlier in autoconf.c:find_cpus()
+                */
                cpu_arch = (node == 0)
                        ? 7
                        : PROM_getpropint(node, "sparc-version", 7);
+#endif
        } else {
                /*
                 * Get CPU version/implementation from ROM. If not



Home | Main Index | Thread Index | Old Index