Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mac68k/mac68k Write a new low-level assembly help f...
details: https://anonhg.NetBSD.org/src/rev/90225c91d95e
branches: trunk
changeset: 473609:90225c91d95e
user: scottr <scottr%NetBSD.org@localhost>
date: Wed Jun 09 06:59:53 1999 +0000
description:
Write a new low-level assembly help for delay() and the calibrator. This
eliminates stalls during instruction prefetch and makes the delay
consistent regardless of kernel configuration.
diffstat:
sys/arch/mac68k/mac68k/clock.c | 33 +++++++++++++++------------------
sys/arch/mac68k/mac68k/locore.s | 29 ++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 19 deletions(-)
diffs (128 lines):
diff -r 2a951a46b4f2 -r 90225c91d95e sys/arch/mac68k/mac68k/clock.c
--- a/sys/arch/mac68k/mac68k/clock.c Wed Jun 09 05:43:10 1999 +0000
+++ b/sys/arch/mac68k/mac68k/clock.c Wed Jun 09 06:59:53 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.36 1997/10/07 03:04:55 scottr Exp $ */
+/* $NetBSD: clock.c,v 1.37 1999/06/09 06:59:53 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -100,6 +100,7 @@
#endif
void rtclock_intr __P((void));
+int _delay __P((u_int));
#define DIFF19041970 2082844800
#define DIFF19701990 630720000
@@ -425,45 +426,42 @@
/*
* delay(usec)
- * Delay usec microseconds.
+ * Delay at least usec microseconds.
*
* The delay_factor is scaled up by a factor of 128 to avoid loss
- * of precision for small delays. As a result of this, note that
- * delays larger that LARGE_DELAY will be up to 128 usec too short,
- * due to adjustments for calculations involving 32 bit values.
+ * of precision for small delays.
*/
void
delay(usec)
- unsigned usec;
+ u_int usec;
{
- volatile unsigned int cycles;
+ volatile u_int cycles;
if (usec > LARGE_DELAY)
- cycles = (usec >> 7) * delay_factor;
+ cycles = ((usec + 127) >> 7) * delay_factor;
else
cycles = ((usec > 0 ? usec : 1) * delay_factor) >> 7;
- while ((cycles-- > 0) && delay_flag);
+ (void)_delay(cycles);
}
-static unsigned dummy_delay __P((unsigned));
+static u_int dummy_delay __P((u_int));
/*
* Dummy delay calibration. Functionally identical to delay(), but
* returns the number of times through the loop.
*/
-static unsigned
+static u_int
dummy_delay(usec)
- unsigned usec;
+ u_int usec;
{
- volatile unsigned int cycles;
+ volatile u_int cycles;
if (usec > LARGE_DELAY)
- cycles = (usec >> 7) * delay_factor;
+ cycles = ((usec + 127) >> 7) * delay_factor;
else
cycles = ((usec > 0 ? usec : 1) * delay_factor) >> 7;
- while ((cycles-- > 0) && delay_flag);
-
+ cycles = _delay(cycles);
return ((delay_factor >> 7) - cycles);
}
@@ -482,8 +480,7 @@
void
mac68k_calibrate_delay()
{
- int n;
- unsigned sum;
+ u_int sum, n;
/* Disable VIA1 timer 1 interrupts and set up service routine */
via_reg(VIA1, vIER) = V1IF_T1;
diff -r 2a951a46b4f2 -r 90225c91d95e sys/arch/mac68k/mac68k/locore.s
--- a/sys/arch/mac68k/mac68k/locore.s Wed Jun 09 05:43:10 1999 +0000
+++ b/sys/arch/mac68k/mac68k/locore.s Wed Jun 09 06:59:53 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.114 1999/04/29 16:27:16 christos Exp $ */
+/* $NetBSD: locore.s,v 1.115 1999/06/09 06:59:53 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -1491,6 +1491,33 @@
rts
/*
+ * Low-level microsecond delay helper
+ *
+ * The branch target for the loops must be aligned on a half-line (8-byte)
+ * boundary to minimize cache effects. This guarantees both that there
+ * will be no prefetch stalls due to cache line burst operations and that
+ * the loops will run from a single cache half-line.
+ */
+ .align 8 | align to half-line boundary
+ENTRY(_delay)
+ movl sp@(4),d0
+ jeq Ldelayexit
+ movl d0,d1
+ andl #0xffff,d0
+ swap d1
+ subql #1,d0
+ andl #0xffff,d1
+Ldelay:
+ tstl _C_LABEL(delay_flag)
+ dbeq d0,Ldelay
+ dbeq d1,Ldelay
+ addql #1,d0
+ swap d1
+ orl d1,d0
+Ldelayexit:
+ rts
+
+/*
* Handle the nitty-gritty of rebooting the machine.
* Basically we just turn off the MMU and jump to the appropriate ROM routine.
* Note that we must be running in an address range that is mapped one-to-one
Home |
Main Index |
Thread Index |
Old Index