Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc set machine_model[] earlier, so that bootstra...



details:   https://anonhg.NetBSD.org/src/rev/b53170210312
branches:  trunk
changeset: 949798:b53170210312
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Jan 17 01:02:28 2021 +0000

description:
set machine_model[] earlier, so that bootstrap can use it.

also, avoid "extern <variable>" in .c files, and add
idempotency to autoconf.h.

diffstat:

 sys/arch/sparc/include/autoconf.h |  10 ++++++++-
 sys/arch/sparc/sparc/autoconf.c   |  43 +++++++++++++++++++++++++++++---------
 sys/arch/sparc/sparc/cpu.c        |   5 +--
 3 files changed, 44 insertions(+), 14 deletions(-)

diffs (132 lines):

diff -r 2f15d52b2012 -r b53170210312 sys/arch/sparc/include/autoconf.h
--- a/sys/arch/sparc/include/autoconf.h Sun Jan 17 00:35:46 2021 +0000
+++ b/sys/arch/sparc/include/autoconf.h Sun Jan 17 01:02:28 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.h,v 1.48 2012/10/27 17:18:11 chs Exp $ */
+/*     $NetBSD: autoconf.h,v 1.49 2021/01/17 01:02:28 mrg Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -69,6 +69,9 @@
  *     @(#)autoconf.h  8.2 (Berkeley) 9/30/93
  */
 
+#ifndef        _MACHINE_AUTOCONF_H_
+#define        _MACHINE_AUTOCONF_H_
+
 /*
  * Autoconfiguration information.
  */
@@ -173,3 +176,8 @@
 
 void   bootstrap(void);
 int    romgetcursoraddr(int **, int **);
+
+/* Exported from autoconf.c for other consumers.  */
+extern char    machine_model[100];
+
+#endif /* !_MACHINE_AUTOCONF_H_ */
diff -r 2f15d52b2012 -r b53170210312 sys/arch/sparc/sparc/autoconf.c
--- a/sys/arch/sparc/sparc/autoconf.c   Sun Jan 17 00:35:46 2021 +0000
+++ b/sys/arch/sparc/sparc/autoconf.c   Sun Jan 17 01:02:28 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.261 2020/08/14 10:34:22 martin Exp $ */
+/*     $NetBSD: autoconf.c,v 1.262 2021/01/17 01:02:28 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.261 2020/08/14 10:34:22 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.262 2021/01/17 01:02:28 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -169,6 +169,33 @@
 }
 
 /*
+ * Set machine_model[] to something useful.  If late is set, then
+ * have now probed the sun4 class and can finish it.  Other systems
+ * are complete with the first call with late=false out of bootstrap.
+ */
+static void
+set_machine_model(bool late)
+{
+       char namebuf[32];
+
+       if (!CPU_ISSUN4) {
+               if (late) {
+                       KASSERT(machine_model[0] != '\0');
+               } else {
+                       snprintf(machine_model, sizeof machine_model, "%s",
+                           prom_getpropstringA(findroot(), "name", namebuf,
+                           sizeof(namebuf)));
+               }
+               return;
+       }
+       if (late)
+               snprintf(machine_model, sizeof machine_model, "SUN-4/%d series",
+                   cpuinfo.classlvl);
+       else
+               snprintf(machine_model, sizeof machine_model, "SUN-4 series");
+}
+
+/*
  * Get the number of CPUs in the system and the CPUs' SPARC architecture
  * version. We need this information early in the boot process.
  */
@@ -188,6 +215,9 @@
         */
        cpu_arch = 7;
 
+       /* Initialise machine_model, early phase. */
+       set_machine_model(false);
+
        /* On sun4 and sun4c we support only one CPU */
        if (!CPU_ISSUN4M && !CPU_ISSUN4D)
                return (1);
@@ -1181,14 +1211,7 @@
 #define        openboot_special4d      ((void *)0)
 #endif
 
-
-       if (CPU_ISSUN4)
-               snprintf(machine_model, sizeof machine_model, "SUN-4/%d series",
-                   cpuinfo.classlvl);
-       else
-               snprintf(machine_model, sizeof machine_model, "%s",
-                   prom_getpropstringA(findroot(), "name", namebuf,
-                   sizeof(namebuf)));
+       set_machine_model(true);
 
        prom_getidprom();
        printf(": %s: hostid %lx\n", machine_model, hostid);
diff -r 2f15d52b2012 -r b53170210312 sys/arch/sparc/sparc/cpu.c
--- a/sys/arch/sparc/sparc/cpu.c        Sun Jan 17 00:35:46 2021 +0000
+++ b/sys/arch/sparc/sparc/cpu.c        Sun Jan 17 01:02:28 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.257 2020/12/05 08:04:51 mrg Exp $ */
+/*     $NetBSD: cpu.c,v 1.258 2021/01/17 01:02:28 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.257 2020/12/05 08:04:51 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.258 2021/01/17 01:02:28 mrg Exp $");
 
 #include "opt_multiprocessor.h"
 #include "opt_lockdebug.h"
@@ -115,7 +115,6 @@
 char   machine[] = MACHINE;            /* from <machine/param.h> */
 char   machine_arch[] = MACHINE_ARCH;  /* from <machine/param.h> */
 int    cpu_arch;                       /* sparc architecture version */
-extern char machine_model[];
 
 int    sparc_ncpus;                    /* # of CPUs detected by PROM */
 struct cpu_info *cpus[_MAXNCPU+1];     /* we only support 4 CPUs. */



Home | Main Index | Thread Index | Old Index