summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-02-28 17:23:26 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-02-28 17:23:26 +0000
commit7a6bbf6ce25b030e97ab419c7ed559af5b797d07 (patch)
tree1a4599b0be3682880892308b9ac1472460acef8d /sys
parented08b3f5b8e2ae1799e826b3b443f0291e06fe88 (diff)
Add an explicit `delay constant' member to struct cpu_info, so that it can
be decoupled from the nominal processor speed. While there, make sure delay() gets a proper delay constant if invoked before cpu0 attaches (how could I miss that when introducing struct cpu_hwinfo?!?)
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mips64/include/cpu.h3
-rw-r--r--sys/arch/mips64/mips64/clock.c9
2 files changed, 9 insertions, 3 deletions
diff --git a/sys/arch/mips64/include/cpu.h b/sys/arch/mips64/include/cpu.h
index 51e50b8383a..634b772aa98 100644
--- a/sys/arch/mips64/include/cpu.h
+++ b/sys/arch/mips64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.55 2010/01/18 16:59:22 miod Exp $ */
+/* $OpenBSD: cpu.h,v 1.56 2010/02/28 17:23:23 miod Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -378,6 +378,7 @@ struct cpu_info {
struct proc *ci_curproc;
struct user *ci_curprocpaddr;
struct proc *ci_fpuproc; /* pointer to last proc to use FP */
+ uint32_t ci_delayconst;
struct cpu_hwinfo
ci_hw;
diff --git a/sys/arch/mips64/mips64/clock.c b/sys/arch/mips64/mips64/clock.c
index a0f7f530d06..0107a74ca6b 100644
--- a/sys/arch/mips64/mips64/clock.c
+++ b/sys/arch/mips64/mips64/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.32 2010/01/09 20:33:16 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.33 2010/02/28 17:23:25 miod Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -190,9 +190,13 @@ delay(int n)
int dly;
int p, c;
struct cpu_info *ci = curcpu();
+ uint32_t delayconst;
+ delayconst = ci->ci_delayconst;
+ if (delayconst == 0)
+ delayconst = bootcpu_hwinfo.clock / 2;
p = cp0_get_count();
- dly = (ci->ci_hw.clock / 1000000) * n / 2;
+ dly = (delayconst / 1000000) * n;
while (dly > 0) {
c = cp0_get_count();
dly -= c - p;
@@ -237,6 +241,7 @@ clock_calibrate(struct cpu_info *ci)
cycles_per_sec = second_cp0 - first_cp0;
ci->ci_hw.clock = cycles_per_sec * 2;
+ ci->ci_delayconst = cycles_per_sec;
}
/*