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.36->1.38 (scottr): re-i...



details:   https://anonhg.NetBSD.org/src/rev/4bfb06be0f47
branches:  netbsd-1-4
changeset: 469126:4bfb06be0f47
user:      perry <perry%NetBSD.org@localhost>
date:      Thu Jul 01 15:18:38 1999 +0000

description:
pullup 1.36->1.38 (scottr): re-implement delay()

diffstat:

 sys/arch/mac68k/mac68k/clock.c |  55 ++++-------------------------------------
 1 files changed, 6 insertions(+), 49 deletions(-)

diffs (94 lines):

diff -r b96a9930873f -r 4bfb06be0f47 sys/arch/mac68k/mac68k/clock.c
--- a/sys/arch/mac68k/mac68k/clock.c    Thu Jul 01 15:14:27 1999 +0000
+++ b/sys/arch/mac68k/mac68k/clock.c    Thu Jul 01 15:18:38 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.36.12.1 1999/07/01 15:18:38 perry Exp $    */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -411,6 +411,8 @@
                    "to the PRAM on this system.\n");
 #endif
 }
+
+
 /*
  * The Macintosh timers decrement once every 1.2766 microseconds.
  * MGFH2, p. 180
@@ -418,55 +420,11 @@
 #define        CLK_RATE        12766
 
 #define        DELAY_CALIBRATE (0xffffff << 7) /* Large value for calibration */
-#define        LARGE_DELAY     0x40000         /* About 335 msec */
 
 u_int          delay_factor = DELAY_CALIBRATE;
 volatile int   delay_flag = 1;
 
-/*
- * delay(usec)
- *     Delay 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.
- */
-void
-delay(usec)
-       unsigned usec;
-{
-       volatile unsigned int cycles;
-
-       if (usec > LARGE_DELAY)
-               cycles = (usec >> 7) * delay_factor;
-       else
-               cycles = ((usec > 0 ? usec : 1) * delay_factor) >> 7;
-
-       while ((cycles-- > 0) && delay_flag);
-}
-
-static unsigned        dummy_delay __P((unsigned));
-/*
- * Dummy delay calibration.  Functionally identical to delay(), but
- * returns the number of times through the loop.
- */
-static unsigned
-dummy_delay(usec)
-       unsigned usec;
-{
-       volatile unsigned int cycles;
-
-       if (usec > LARGE_DELAY)
-               cycles = (usec >> 7) * delay_factor;
-       else
-               cycles = ((usec > 0 ? usec : 1) * delay_factor) >> 7;
-
-       while ((cycles-- > 0) && delay_flag);
-
-       return ((delay_factor >> 7) - cycles);
-}
-
+int            _delay __P((u_int));
 static void    delay_timer1_irq __P((void *));
 
 static void
@@ -482,8 +440,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;
@@ -503,7 +460,7 @@
                delay_flag = 1;
                via_reg(VIA1, vT1C) = 0;        /* 1024 clock ticks */
                via_reg(VIA1, vT1CH) = 4;       /* (approx 1.3 msec) */
-               sum += dummy_delay(1);
+               sum += ((delay_factor >> 7) - _delay(1));
        }
 
        /* Disable timer interrupts and reset service routine */



Home | Main Index | Thread Index | Old Index