Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x68k Use mvme68k-derived delay routine.
details: https://anonhg.NetBSD.org/src/rev/915f4d76817d
branches: trunk
changeset: 472717:915f4d76817d
user: minoura <minoura%NetBSD.org@localhost>
date: Wed May 05 13:46:20 1999 +0000
description:
Use mvme68k-derived delay routine.
Now that we support various models, the old constant-loop delay routine
may cause problems.
diffstat:
sys/arch/x68k/dev/mfp.c | 37 ++++++++++++++++++++++++++++--
sys/arch/x68k/include/cpu.h | 9 +------
sys/arch/x68k/include/param.h | 9 ++++---
sys/arch/x68k/x68k/locore.s | 19 ++++++++++++++-
sys/arch/x68k/x68k/machdep.c | 52 +++++++++++++++++++++++-------------------
5 files changed, 87 insertions(+), 39 deletions(-)
diffs (256 lines):
diff -r 2659a51224fe -r 915f4d76817d sys/arch/x68k/dev/mfp.c
--- a/sys/arch/x68k/dev/mfp.c Wed May 05 13:41:44 1999 +0000
+++ b/sys/arch/x68k/dev/mfp.c Wed May 05 13:46:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mfp.c,v 1.3 1999/03/18 12:27:59 minoura Exp $ */
+/* $NetBSD: mfp.c,v 1.4 1999/05/05 13:46:20 minoura Exp $ */
/*
*
@@ -55,13 +55,12 @@
static int mfp_match __P((struct device *, struct cfdata *, void *));
static void mfp_attach __P((struct device *, struct device *, void *));
static void mfp_init __P((void));
+static void mfp_calibrate_delay __P((void));
struct cfattach mfp_ca = {
sizeof(struct mfp_softc), mfp_match, mfp_attach
};
-extern int x68k_realconfig;
-extern struct cfdriver mfp_cd;
static int
mfp_match(parent, cf, aux)
@@ -120,6 +119,12 @@
config_found (self, "kbd", NULL);
config_found (self, "clock", NULL);
config_found (self, "pow", NULL);
+ } else {
+ /*
+ * Called from config_console;
+ * calibrate the DELAY loop counter
+ */
+ mfp_calibrate_delay();
}
}
@@ -144,6 +149,32 @@
mfp_set_tcdcr(0);
}
+extern int delay_divisor;
+void _delay __P((u_int));
+
+static void
+mfp_calibrate_delay(void)
+{
+ /*
+ * Stolen from mvme68k.
+ */
+ /*
+ * X68k provides 4MHz clock (= 0.25usec) for MFP timer C.
+ * 10000usec = 0.25usec * 200 * 200
+ * Our slowest clock is 20MHz (?). Its delay_divisor value
+ * should be about 102. Start from 140 here.
+ */
+ for (delay_divisor = 140; delay_divisor > 0; delay_divisor--) {
+ mfp_set_tcdr(255-0);
+ mfp_set_tcdcr(0x70); /* 1/200 delay mode */
+ _delay(10000 << 8);
+ mfp_set_tcdcr(0); /* stop timer */
+ if ((255 - mfp_get_tcdr()) > 200)
+ break; /* got it! */
+ /* retry! */
+ }
+}
+
/*
* MFP utility functions
*/
diff -r 2659a51224fe -r 915f4d76817d sys/arch/x68k/include/cpu.h
--- a/sys/arch/x68k/include/cpu.h Wed May 05 13:41:44 1999 +0000
+++ b/sys/arch/x68k/include/cpu.h Wed May 05 13:46:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.17 1999/03/24 14:07:39 minoura Exp $ */
+/* $NetBSD: cpu.h,v 1.18 1999/05/05 13:46:20 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -130,13 +130,6 @@
* although some of it could probably be put into generic 68k headers.
*/
-/* values for cpuspeed (not really related to clock speed due to caches) */
-#define MHZ_8 1
-#define MHZ_16 2
-#define MHZ_25 3
-#define MHZ_33 4
-#define MHZ_50 6
-
#ifdef _KERNEL
extern int machineid;
extern char *intiolimit;
diff -r 2659a51224fe -r 915f4d76817d sys/arch/x68k/include/param.h
--- a/sys/arch/x68k/include/param.h Wed May 05 13:41:44 1999 +0000
+++ b/sys/arch/x68k/include/param.h Wed May 05 13:46:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.11 1998/12/13 15:04:01 minoura Exp $ */
+/* $NetBSD: param.h,v 1.12 1999/05/05 13:46:20 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -82,9 +82,10 @@
#if defined(_KERNEL) && !defined(_LOCORE)
-extern int cpuspeed;
-#define delay(n) do { register int N = cpuspeed * (n); while (--N > 0); } while(0)
-#define DELAY(n) delay(n)
+#define delay(us) _delay((us) << 8)
+#define DELAY(us) delay(us)
+
+void _delay __P((u_int));
#endif /* _KERNEL && !_LOCORE */
#if defined(_KERNEL) && !defined(_LKM)
diff -r 2659a51224fe -r 915f4d76817d sys/arch/x68k/x68k/locore.s
--- a/sys/arch/x68k/x68k/locore.s Wed May 05 13:41:44 1999 +0000
+++ b/sys/arch/x68k/x68k/locore.s Wed May 05 13:46:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.45 1999/04/30 16:50:44 christos Exp $ */
+/* $NetBSD: locore.s,v 1.46 1999/05/05 13:46:20 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -1652,6 +1652,23 @@
rts
/*
+ * _delay(u_int N)
+ *
+ * Delay for at least (N/256) microsecends.
+ * This routine depends on the variable: delay_divisor
+ * which should be set based on the CPU clock rate.
+ */
+ENTRY_NOPROFILE(_delay)
+ | d0 = arg = (usecs << 8)
+ movl sp@(4),d0
+ | d1 = delay_divisor
+ movl _C_LABEL(delay_divisor),d1
+L_delay:
+ subl d1,d0
+ jgt L_delay
+ rts
+
+/*
* Save and restore 68881 state.
*/
ENTRY(m68881_save)
diff -r 2659a51224fe -r 915f4d76817d sys/arch/x68k/x68k/machdep.c
--- a/sys/arch/x68k/x68k/machdep.c Wed May 05 13:41:44 1999 +0000
+++ b/sys/arch/x68k/x68k/machdep.c Wed May 05 13:46:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.66 1999/05/05 13:41:20 minoura Exp $ */
+/* $NetBSD: machdep.c,v 1.67 1999/05/05 13:46:20 minoura Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -128,8 +128,6 @@
/* the following is used externally (sysctl_hw) */
char machine[] = MACHINE; /* from <machine/param.h> */
-int cpuspeed; /* XXX */
-
vm_map_t exec_map = NULL;
vm_map_t mb_map = NULL;
vm_map_t phys_map = NULL;
@@ -191,6 +189,16 @@
void intrhand __P((int));
/*
+ * 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).
+ */
+int delay_divisor = 140; /* assume some reasonable value to start */
+static int cpuspeed; /* MPU clock (in MHz) */
+
+/*
* Machine-dependent crash dump header info.
*/
cpu_kcore_hdr_t cpu_kcore_hdr;
@@ -204,20 +212,17 @@
consinit()
{
/*
- * Set cpuspeed immediately since cninit() called routines
- * might use delay. Note that we only set it if a custom value
- * has not already been specified.
+ * bring graphics layer up.
*/
-
- cpuspeed = MHZ_25; /* XXX */
+ config_console();
- if (mmutype == MMU_68040)
- cpuspeed *= 2; /* XXX */
-
- /*
- * bring graphics layer up.
- */
- config_console();
+ /*
+ * cpuspeed is now used only for print.
+ */
+ if (mmutype == MMU_68040) /* 68040/060 */
+ cpuspeed = (759 / delay_divisor);
+ else /* 68030 */
+ cpuspeed = (2048 / delay_divisor);
/*
* Initialize the console before we print anything out.
@@ -530,12 +535,12 @@
extern char version[];
static char *fpu_descr[] = {
#ifdef FPU_EMULATE
- " emulator FPU", /* 0 */
+ ", emulator FPU", /* 0 */
#else
- " no math support", /* 0 */
+ ", no math support", /* 0 */
#endif
- " m68881 FPU", /* 1 */
- " m68882 FPU", /* 2 */
+ ", m68881 FPU", /* 1 */
+ ", m68882 FPU", /* 2 */
"/FPU", /* 3 */
"/FPU", /* 4 */
};
@@ -591,19 +596,20 @@
break;
case CPU_68020:
cpu_type = "m68020";
- mmu = " m68851 MMU";
+ mmu = ", m68851 MMU";
break;
default:
cpu_type = "unknown";
- mmu = " unknown MMU";
+ mmu = ", unknown MMU";
break;
}
fputype = fpu_probe();
if (fputype >= 0 && fputype < sizeof(fpu_descr)/sizeof(fpu_descr[0]))
fpu = fpu_descr[fputype];
else
- fpu = " unknown FPU";
- sprintf(cpu_model, "X68%s (%s CPU%s%s)", mach, cpu_type, mmu, fpu);
+ fpu = ", unknown FPU";
+ sprintf(cpu_model, "X68%s (%s CPU%s%s, %dMHz clock)",
+ mach, cpu_type, mmu, fpu, cpuspeed);
printf("%s\n", cpu_model);
}
Home |
Main Index |
Thread Index |
Old Index