Module Name: src
Committed By: tsutsui
Date: Sat Sep 8 02:33:34 UTC 2018
Modified Files:
src/sys/arch/sgimips/sgimips: machdep.c
Log Message:
Initialize ci_divisor_delay by temporary cpufreq for early delay(9) calls.
This is actually required for Indigo R3k.
Reported by Naruaki Etomi in PR port-sgimips/53520.
To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/arch/sgimips/sgimips/machdep.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/sgimips/sgimips/machdep.c
diff -u src/sys/arch/sgimips/sgimips/machdep.c:1.146 src/sys/arch/sgimips/sgimips/machdep.c:1.147
--- src/sys/arch/sgimips/sgimips/machdep.c:1.146 Sun Sep 2 09:57:33 2018
+++ src/sys/arch/sgimips/sgimips/machdep.c Sat Sep 8 02:33:33 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.146 2018/09/02 09:57:33 tsutsui Exp $ */
+/* $NetBSD: machdep.c,v 1.147 2018/09/08 02:33:33 tsutsui Exp $ */
/*
* Copyright (c) 2000 Soren S. Jorvang
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.146 2018/09/02 09:57:33 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.147 2018/09/08 02:33:33 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -334,6 +334,25 @@ mach_init(int argc, int32_t argv32[], ui
curcpu()->ci_cpu_freq = strtoul(cpufreq, NULL, 10) * 1000000;
/*
+ * Also initialize ci members for delay and clock by the temporary
+ * ci_cpu_freq value for early use of delay(9).
+ * These values will be calibrated later in MD code:
+ * - int_attach() in dev/int.c for IP6/10/12/20/22
+ * - crime_attach() in dev/crime.c for IP32
+ *
+ * XXX: ci_divisor_delay is for mips3_delay() in mips/mips3_clock.c
+ * but sgimips abuse it as "instructions per microsecond"
+ * for traditional delay(9) implementation derived from
+ * 4.4BSD/mips (also used in pmax and news3400).
+ * (see sys/arch/mips/mips/mips_mcclock.c etc.)
+ *
+ * Note ci_cycles_per_hz is for mips3_clockintr.c for MIPS3 so
+ * there is no early use, but initialize it as a sane default.
+ */
+ curcpu()->ci_cycles_per_hz = curcpu()->ci_cpu_freq / (2 * hz);
+ curcpu()->ci_divisor_delay = curcpu()->ci_cpu_freq / (2 * 1000000);
+
+ /*
* Check machine (IPn) type.
*
* Note even on IP12 (which doesn't have ARCBIOS),