From 2d2cca84b09584b0acad8f68df27b30fd5bc245d Mon Sep 17 00:00:00 2001 From: briggs Date: Mon, 29 Jan 1996 04:11:01 +0000 Subject: Fix for delay(usec) for small usec. From Scott Reynolds . --- sys/arch/mac68k/mac68k/clock.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'sys/arch/mac68k') diff --git a/sys/arch/mac68k/mac68k/clock.c b/sys/arch/mac68k/mac68k/clock.c index 5fe1159fe6d..0d4b8bdc8a5 100644 --- a/sys/arch/mac68k/mac68k/clock.c +++ b/sys/arch/mac68k/mac68k/clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: clock.c,v 1.16 1995/09/16 12:31:13 briggs Exp $ */ +/* $NetBSD: clock.c,v 1.17 1996/01/29 04:10:00 briggs Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -414,19 +414,22 @@ resettodr(void) * try to compensate for this sometime because access to the via * is hardly cheap. * - * Paranoia can be removed whenever... ;-) + * It would probably be worthwhile to invent a version of this that + * didn't depend on the VIA. */ void delay(int usec) { - int ticks, paranoia = 0x10000000; + int ticks; int t, timerh, timerl; if (usec <= 0) usec = 1; - ticks = usec / CLK_RATE; - ticks = ticks * 10000; + if (usec < 200000) + ticks = (usec * 10000) / CLK_RATE; + else + ticks = (usec / CLK_RATE) * 10000; while (ticks) { t = min(ticks, 65535); @@ -437,11 +440,9 @@ delay(int usec) via_reg(VIA1, vT2C) = timerl; via_reg(VIA1, vT2CH) = timerh; - while (!(via_reg(VIA1, vIFR) & V1IF_T2) && paranoia) - paranoia--; + while (!(via_reg(VIA1, vIFR) & V1IF_T2)) + ; ticks -= t; } - if (!paranoia) - printf("paranoia in delay()!!!\n"); } -- cgit v1.2.3