Module Name: src Committed By: tsutsui Date: Fri Jan 27 15:21:52 UTC 2023
Modified Files: src/sys/arch/next68k/include: cpu.h src/sys/arch/next68k/next68k: clock.c machdep.c Log Message: next68k: Fix delay_divisor value for proper delay(9) on 68040. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/arch/next68k/include/cpu.h cvs rdiff -u -r1.12 -r1.13 src/sys/arch/next68k/next68k/clock.c cvs rdiff -u -r1.116 -r1.117 src/sys/arch/next68k/next68k/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/next68k/include/cpu.h diff -u src/sys/arch/next68k/include/cpu.h:1.50 src/sys/arch/next68k/include/cpu.h:1.51 --- src/sys/arch/next68k/include/cpu.h:1.50 Sat Nov 23 19:40:36 2019 +++ src/sys/arch/next68k/include/cpu.h Fri Jan 27 15:21:52 2023 @@ -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 loadustp(int); 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... */ Index: src/sys/arch/next68k/next68k/clock.c diff -u src/sys/arch/next68k/next68k/clock.c:1.12 src/sys/arch/next68k/next68k/clock.c:1.13 --- src/sys/arch/next68k/next68k/clock.c:1.12 Sat Apr 24 19:58:13 2010 +++ src/sys/arch/next68k/next68k/clock.c Fri Jan 27 15:21:52 2023 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1. * -- jew...@mit.edu */ -/* - * 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 Index: src/sys/arch/next68k/next68k/machdep.c diff -u src/sys/arch/next68k/next68k/machdep.c:1.116 src/sys/arch/next68k/next68k/machdep.c:1.117 --- src/sys/arch/next68k/next68k/machdep.c:1.116 Sat Oct 9 20:00:42 2021 +++ src/sys/arch/next68k/next68k/machdep.c Fri Jan 27 15:21:52 2023 @@ -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_seg_list_t phys_seg_list[VM_PHYSSEG 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 @@ next68k_init(void) } } - /* Calibrate the delay loop. */ - next68k_calibrate_delay(); - /* * Initialize error message buffer (at end of core). */ @@ -256,8 +264,6 @@ consinit(void) } init = 1; - } else { - next68k_calibrate_delay(); } } @@ -316,6 +322,7 @@ void identifycpu(void) { const char *mc, *mmu_str, *fpu_str, *cache_str; + extern int turbo; /* * ...and the CPU type. @@ -323,9 +330,13 @@ identifycpu(void) 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";