Module Name: src
Committed By: mrg
Date: Sun Jan 17 01:02:28 UTC 2021
Modified Files:
src/sys/arch/sparc/include: autoconf.h
src/sys/arch/sparc/sparc: autoconf.c cpu.c
Log Message:
set machine_model[] earlier, so that bootstrap can use it.
also, avoid "extern <variable>" in .c files, and add
idempotency to autoconf.h.
To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/sparc/include/autoconf.h
cvs rdiff -u -r1.261 -r1.262 src/sys/arch/sparc/sparc/autoconf.c
cvs rdiff -u -r1.257 -r1.258 src/sys/arch/sparc/sparc/cpu.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/include/autoconf.h
diff -u src/sys/arch/sparc/include/autoconf.h:1.48 src/sys/arch/sparc/include/autoconf.h:1.49
--- src/sys/arch/sparc/include/autoconf.h:1.48 Sat Oct 27 17:18:11 2012
+++ src/sys/arch/sparc/include/autoconf.h Sun Jan 17 01:02:28 2021
@@ -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 mountroot_hook_establish(void (*)(d
void bootstrap(void);
int romgetcursoraddr(int **, int **);
+
+/* Exported from autoconf.c for other consumers. */
+extern char machine_model[100];
+
+#endif /* !_MACHINE_AUTOCONF_H_ */
Index: src/sys/arch/sparc/sparc/autoconf.c
diff -u src/sys/arch/sparc/sparc/autoconf.c:1.261 src/sys/arch/sparc/sparc/autoconf.c:1.262
--- src/sys/arch/sparc/sparc/autoconf.c:1.261 Fri Aug 14 10:34:22 2020
+++ src/sys/arch/sparc/sparc/autoconf.c Sun Jan 17 01:02:28 2021
@@ -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 @@ matchbyname(device_t parent, cfdata_t cf
}
/*
+ * 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 @@ find_cpus(void)
*/
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 @@ extern struct sparc_bus_space_tag mainbu
#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);
Index: src/sys/arch/sparc/sparc/cpu.c
diff -u src/sys/arch/sparc/sparc/cpu.c:1.257 src/sys/arch/sparc/sparc/cpu.c:1.258
--- src/sys/arch/sparc/sparc/cpu.c:1.257 Sat Dec 5 08:04:51 2020
+++ src/sys/arch/sparc/sparc/cpu.c Sun Jan 17 01:02:28 2021
@@ -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 @@ struct cpu_softc {
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. */