Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/sys/arch/mac68k/mac68k pullup 1.114->1.117 (scottr): re...



details:   https://anonhg.NetBSD.org/src/rev/fceb78edd3d8
branches:  netbsd-1-4
changeset: 469127:fceb78edd3d8
user:      perry <perry%NetBSD.org@localhost>
date:      Thu Jul 01 15:19:54 1999 +0000

description:
pullup 1.114->1.117 (scottr): re-implement delay()

diffstat:

 sys/arch/mac68k/mac68k/locore.s |  47 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diffs (61 lines):

diff -r 4bfb06be0f47 -r fceb78edd3d8 sys/arch/mac68k/mac68k/locore.s
--- a/sys/arch/mac68k/mac68k/locore.s   Thu Jul 01 15:18:38 1999 +0000
+++ b/sys/arch/mac68k/mac68k/locore.s   Thu Jul 01 15:19:54 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.112.2.1 1999/04/30 16:27:52 perry Exp $   */
+/*     $NetBSD: locore.s,v 1.112.2.2 1999/07/01 15:19:54 perry Exp $   */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -1488,6 +1488,51 @@
 Lm68881rdone:
        frestore a0@                    | restore state
        rts
+       rts
+
+/*
+ * delay() - delay for a specified number of microseconds
+ * _delay() - calibrator helper for delay()
+ *
+ * Notice that delay_factor is scaled up by a factor of 128 to avoid loss
+ * of precision for small delays.  As a result of this we need to avoid
+ * overflow.
+ *
+ * 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
+                                       | (use nop instructions if necessary!)
+ALTENTRY(_delay, _delay)
+ENTRY(delay)
+       movl    sp@(4),d0               | get microseconds to delay
+       cmpl    #0x40000,d0             | is it a "large" delay?
+       bls     Ldelayshort             | no, normal calculation
+       movql   #0x7f,d1                | adjust for scaled multipler (to
+       addl    d1,d0                   |   avoid overflow)
+       lsrl    #7,d0
+       mulul   _C_LABEL(delay_factor),d0 | calculate number of loop iterations
+       bra     Ldelaysetup             | go do it!
+Ldelayshort:
+       mulul   _C_LABEL(delay_factor),d0 | calculate number of loop iterations
+       lsrl    #7,d0                   | adjust for scaled multiplier
+Ldelaysetup:
+       jeq     Ldelayexit              | bail out if nothing to do
+       movql   #0,d1                   | put bits 15-0 in d1 for the
+       movw    d0,d1                   |   inner loop, and move bits
+       movw    #0,d0                   |   31-16 to the low-order word
+       subql   #1,d1                   |   of d0 for the outer loop
+       swap    d0
+Ldelay:
+       tstl    _C_LABEL(delay_flag)    | this never changes for delay()!
+       dbeq    d1,Ldelay               |   (used only for timing purposes)
+       dbeq    d0,Ldelay
+       addqw   #1,d1                   | adjust end count and
+       swap    d0                      |    return the longword result
+       orl     d1,d0
+Ldelayexit:
 
 /*
  * Handle the nitty-gritty of rebooting the machine.



Home | Main Index | Thread Index | Old Index