Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Provide assembly versions of the clock timing calcu...
details: https://anonhg.NetBSD.org/src/rev/495ab096270b
branches: trunk
changeset: 572381:495ab096270b
user: simonb <simonb%NetBSD.org@localhost>
date: Sat Jan 01 09:48:39 2005 +0000
description:
Provide assembly versions of the clock timing calculation loops that
aren't effected by changes in compiler optimisation.
Fixes PR port-mips/26959 from Izumi Tsutsui
diffstat:
sys/arch/mips/mips/mips_mcclock.c | 23 ++----
sys/arch/mips/mips/mips_mcclock.h | 5 +-
sys/arch/mips/mips/mips_mcclock_loop.S | 102 +++++++++++++++++++++++++++++++++
sys/arch/pmax/conf/files.pmax | 13 ++-
4 files changed, 120 insertions(+), 23 deletions(-)
diffs (207 lines):
diff -r e0637bc9b284 -r 495ab096270b sys/arch/mips/mips/mips_mcclock.c
--- a/sys/arch/mips/mips/mips_mcclock.c Sat Jan 01 09:14:49 2005 +0000
+++ b/sys/arch/mips/mips/mips_mcclock.c Sat Jan 01 09:48:39 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_mcclock.c,v 1.11 2002/03/05 15:54:33 simonb Exp $ */
+/* $NetBSD: mips_mcclock.c,v 1.12 2005/01/01 09:48:39 simonb Exp $ */
/*
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -34,7 +34,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: mips_mcclock.c,v 1.11 2002/03/05 15:54:33 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mips_mcclock.c,v 1.12 2005/01/01 09:48:39 simonb Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -146,7 +146,7 @@
void *mcclock_addr;
int clockmask;
{
- int iters = 0;
+ int iters;
volatile int junk;
volatile struct mcclock_pad32_clockdatum *clk = mcclock_addr;
@@ -164,19 +164,12 @@
junk++; junk++; junk++; junk++;
/* Count loops until next tick-interrupt request occurs (4ms). */
- if (MIPS_HAS_CLOCK) {
- while ((mips_cp0_cause_read() & clockmask) == 0) {
- __asm __volatile ("nop; nop; nop; nop");
- iters++;
- }
- } else {
- while ((mips_cp0_cause_read() & clockmask) == 0) {
- __asm __volatile ("nop; nop;");
- iters++;
- }
- }
+ if (MIPS_HAS_CLOCK)
+ iters = mips_mcclock_loop_with_clock(clockmask);
+ else
+ iters = mips_mcclock_loop_without_clock(clockmask);
- /* Ack the interrupt from the just-gone-off tick */
+ /* Ack the interrupt from the just-gone-off tick */
junk = clk[MC_REGC].datum;
return (iters);
diff -r e0637bc9b284 -r 495ab096270b sys/arch/mips/mips/mips_mcclock.h
--- a/sys/arch/mips/mips/mips_mcclock.h Sat Jan 01 09:14:49 2005 +0000
+++ b/sys/arch/mips/mips/mips_mcclock.h Sat Jan 01 09:48:39 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_mcclock.h,v 1.3 2002/03/05 14:12:30 simonb Exp $ */
+/* $NetBSD: mips_mcclock.h,v 1.4 2005/01/01 09:48:39 simonb Exp $ */
/*
* Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
@@ -40,10 +40,11 @@
* counting iterations of an loop between successive ticks.
*/
unsigned mc_cpuspeed(vaddr_t, int);
+int mips_mcclock_loop_with_clock(int);
+int mips_mcclock_loop_without_clock(int);
/*
* CPU speed in MHz, as estimated by mc_cpuspeed(). Read-only.
*/
extern int cpu_mhz;
-
#endif
diff -r e0637bc9b284 -r 495ab096270b sys/arch/mips/mips/mips_mcclock_loop.S
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/mips/mips/mips_mcclock_loop.S Sat Jan 01 09:48:39 2005 +0000
@@ -0,0 +1,102 @@
+/* $NetBSD: mips_mcclock_loop.S,v 1.1 2005/01/01 09:48:39 simonb Exp $ */
+
+/*
+ * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Simon Burge.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mips/asm.h>
+#include <mips/cpuregs.h>
+
+ .set noreorder
+
+/*
+ * Provide assembly versions of the clock timing calculation loops that
+ * aren't effected by changes in compiler optimisation.
+ *
+ * These two functions are not profiled!
+ */
+
+
+LEAF_NOPROFILE(mips_mcclock_loop_with_clock)
+ subu sp, CALLFRAME_SIZ
+ sw s0, 0(sp)
+ sw ra, CALLFRAME_RA(sp)
+ j 2f
+ move s0, zero # iters = 0;
+1:
+ .set push
+ .set mips32
+ ssnop # asm ("ssnop;ssnop;ssnop;ssnop");
+ ssnop
+ ssnop
+ ssnop
+ .set pop
+
+ addu s0, 1 # iters++;
+2: jal mips_cp0_cause_read # v0 = mips_cp0_cause_read();
+ nop
+ and v0, a0 # v0 &= clockmask;
+ beqz v0, 1b # if zero then repeat
+ move v0, s0 # return iters
+ lw ra, CALLFRAME_RA(sp)
+ lw s0, 0(sp)
+ j ra
+ addu sp, CALLFRAME_SIZ
+END(mips_mcclock_loop_with_clock)
+
+LEAF_NOPROFILE(mips_mcclock_loop_without_clock)
+ subu sp, CALLFRAME_SIZ
+ sw s0, 0(sp)
+ sw ra, CALLFRAME_RA(sp)
+ j 2f
+ move s0, zero # iters = 0;
+1:
+ .set push
+ .set mips32
+ ssnop # asm ("ssnop;ssnop");
+ ssnop
+ .set pop
+
+ addu s0, 1 # iters++;
+2: jal mips_cp0_cause_read # v0 = mips_cp0_cause_read();
+ nop
+ and v0, a0 # v0 &= clockmask;
+ beqz v0, 1b # if zero then repeat
+ move v0, s0 # return iters
+ lw ra, CALLFRAME_RA(sp)
+ lw s0, 0(sp)
+ j ra
+ addu sp, CALLFRAME_SIZ
+END(mips_mcclock_loop_without_clock)
diff -r e0637bc9b284 -r 495ab096270b sys/arch/pmax/conf/files.pmax
--- a/sys/arch/pmax/conf/files.pmax Sat Jan 01 09:14:49 2005 +0000
+++ b/sys/arch/pmax/conf/files.pmax Sat Jan 01 09:48:39 2005 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.pmax,v 1.107 2003/12/13 23:04:37 ad Exp $
+# $NetBSD: files.pmax,v 1.108 2005/01/01 09:48:39 simonb Exp $
# DECstation-specific configuration info
# maxpartitions must be first item in files.${ARCH}.
@@ -81,11 +81,12 @@
attach mcclock at ioasic with mcclock_ioasic
attach mcclock at ibus with mcclock_ibus
file arch/pmax/pmax/clock.c
-file dev/dec/mcclock.c mcclock
-file dev/dec/mcclock_pad32.c mcclock
-file arch/pmax/tc/mcclock_ioasic.c mcclock_ioasic
-file arch/pmax/ibus/mcclock_ibus.c mcclock_ibus
-file arch/mips/mips/mips_mcclock.c mcclock # CPU speed via mcclock
+file dev/dec/mcclock.c mcclock
+file dev/dec/mcclock_pad32.c mcclock
+file arch/pmax/tc/mcclock_ioasic.c mcclock_ioasic
+file arch/pmax/ibus/mcclock_ibus.c mcclock_ibus
+file arch/mips/mips/mips_mcclock.c mcclock # CPU speed via mcclock
+file arch/mips/mips/mips_mcclock_loop.S mcclock # CPU speed via mcclock
include "dev/scsipi/files.scsipi"
Home |
Main Index |
Thread Index |
Old Index