Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/next68k next68k: Fix delay_divisor value for proper...



details:   https://anonhg.NetBSD.org/src/rev/7696e84c47b3
branches:  trunk
changeset: 373246:7696e84c47b3
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Fri Jan 27 15:21:52 2023 +0000

description:
next68k: Fix delay_divisor value for proper delay(9) on 68040.

diffstat:

 sys/arch/next68k/include/cpu.h     |   5 +----
 sys/arch/next68k/next68k/clock.c   |  36 ++----------------------------------
 sys/arch/next68k/next68k/machdep.c |  25 ++++++++++++++++++-------
 3 files changed, 21 insertions(+), 45 deletions(-)

diffs (153 lines):

diff -r a67e1f7da570 -r 7696e84c47b3 sys/arch/next68k/include/cpu.h
--- a/sys/arch/next68k/include/cpu.h    Fri Jan 27 09:33:43 2023 +0000
+++ b/sys/arch/next68k/include/cpu.h    Fri Jan 27 15:21:52 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.50 2019/11/23 19:40:36 ad Exp $      */
+/*     $NetBSD: cpu.h,v 1.51 2023/01/27 15:21:52 tsutsui Exp $ */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -120,9 +120,6 @@
 void   doboot(void) __attribute__((__noreturn__));
 int    nmihand(void *);
 
-/* clock.c functions */
-void   next68k_calibrate_delay(void);
-
 #endif /* _KERNEL */
 
 #define NEXT_RAMBASE  (0x4000000) /* really depends on slot, but... */
diff -r a67e1f7da570 -r 7696e84c47b3 sys/arch/next68k/next68k/clock.c
--- a/sys/arch/next68k/next68k/clock.c  Fri Jan 27 09:33:43 2023 +0000
+++ b/sys/arch/next68k/next68k/clock.c  Fri Jan 27 15:21:52 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.12 2010/04/24 19:58:13 dbj Exp $   */
+/*     $NetBSD: clock.c,v 1.13 2023/01/27 15:21:52 tsutsui Exp $       */
 /*
  * Copyright (c) 1998 Darrin B. Jewell
  * All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.12 2010/04/24 19:58:13 dbj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.13 2023/01/27 15:21:52 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -48,38 +48,6 @@
  * -- jewell%mit.edu@localhost
  */
 
-/*
- * Note that the value of delay_divisor is roughly
- * 2048 / cpuspeed (where cpuspeed is in MHz) on 68020
- * and 68030 systems.  See clock.c for the delay
- * calibration algorithm.
- */
-int    cpuspeed;                 /* relative cpu speed; XXX skewed on 68040 */
-int    delay_divisor = 2048/25;  /* delay constant */
-
-/*
- * Calibrate the delay constant.
- */
-void
-next68k_calibrate_delay(void)
-{
-       extern int delay_divisor;
-
-       /* @@@ write this once we know how to read
-        * a real time clock
-        */
-
-       /*
-        * Sanity check the delay_divisor value.  If we totally lost,
-        * assume a 25MHz CPU;
-        */
-       if (delay_divisor == 0)
-               delay_divisor = 2048 / 25;
-
-       /* Calculate CPU speed. */
-       cpuspeed = 2048 / delay_divisor;
-}
-
 int clock_intr(void *);
 
 int
diff -r a67e1f7da570 -r 7696e84c47b3 sys/arch/next68k/next68k/machdep.c
--- a/sys/arch/next68k/next68k/machdep.c        Fri Jan 27 09:33:43 2023 +0000
+++ b/sys/arch/next68k/next68k/machdep.c        Fri Jan 27 15:21:52 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.116 2021/10/09 20:00:42 tsutsui Exp $    */
+/*     $NetBSD: machdep.c,v 1.117 2023/01/27 15:21:52 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1998 Darrin B. Jewell
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.116 2021/10/09 20:00:42 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.117 2023/01/27 15:21:52 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -168,6 +168,17 @@
 phys_ram_seg_t mem_clusters[VM_PHYSSEG_MAX];
 int    mem_cluster_cnt;
 
+/*
+ * On the 68020/68030, the value of delay_divisor is roughly
+ * 2048 / cpuspeed (where cpuspeed is in MHz).
+ *
+ * On the 68040/68060(?), the value of delay_divisor is roughly
+ * 759 / cpuspeed (where cpuspeed is in MHz).
+ * XXX -- is the above formula correct?
+ */
+int    cpuspeed = 33;            /* relative cpu speed; XXX skewed on 68040 */
+int    delay_divisor = 759 / 33;  /* delay constant; assume fastest 33 MHz */
+
 /****************************************************************/
 
 /*
@@ -208,9 +219,6 @@
                }
        }
 
-       /* Calibrate the delay loop. */
-       next68k_calibrate_delay();
-
        /*
         * Initialize error message buffer (at end of core).
         */
@@ -256,8 +264,6 @@
                }
 
                init = 1;
-       } else {
-               next68k_calibrate_delay();
        }
 }
 
@@ -316,6 +322,7 @@
 identifycpu(void)
 {
        const char *mc, *mmu_str, *fpu_str, *cache_str;
+       extern int turbo;
 
        /*
         * ...and the CPU type.
@@ -323,9 +330,13 @@
        switch (cputype) {
        case CPU_68040:
                mc = "40";
+               cpuspeed = turbo ? 33 : 25;
+               delay_divisor = 759 / cpuspeed;
                break;
        case CPU_68030:
                mc = "30";
+               cpuspeed = 25;
+               delay_divisor = 2048 / cpuspeed;
                break;
        case CPU_68020:
                mc = "20";



Home | Main Index | Thread Index | Old Index