diff options
| author | Matt Jacob <mjacob@FreeBSD.org> | 2000-05-07 22:44:27 +0000 |
|---|---|---|
| committer | Matt Jacob <mjacob@FreeBSD.org> | 2000-05-07 22:44:27 +0000 |
| commit | 2d41e34a07f6ab1ce444958ca1a68fb451cf0b7e (patch) | |
| tree | d7f3547e7537e4fc838e28e34c8505db5930ae9f | |
| parent | d50e5bd5cc8b23813a4540f5e4d0f6b4160920f4 (diff) | |
Notes
| -rw-r--r-- | sys/alpha/alpha/machdep.c | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 041ea4e9dd826..8855858a52fbc 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -1130,17 +1130,44 @@ bzero(void *buf, size_t len) } } -/* - * Wait "n" microseconds. - */ void DELAY(int n) { -#ifndef SIMOS - long N = cycles_per_usec * (n); +#ifndef SIMOS + unsigned long pcc0, pcc1, curcycle, cycles; + int usec; + + if (n == 0) + return; + + pcc0 = alpha_rpcc() & 0xffffffffUL; + cycles = 0; + usec = 0; - while (N > 0) /* XXX */ - N -= 3; /* XXX */ + while (usec <= n) { + /* + * Get the next CPU cycle count; + */ + pcc1 = alpha_rpcc() & 0xffffffffUL; + if (pcc1 < pcc0) { + curcycle = (pcc1 + 0x100000000UL) - pcc0; + } else { + curcycle = pcc1 - pcc0; + } + + /* + * We now have the number of processor cycles since we + * last checked. Add the current cycle count to the + * running total. If it's over cycles_per_usec, increment + * the usec counter. + */ + cycles += curcycle; + while (cycles > cycles_per_usec) { + usec++; + cycles -= cycles_per_usec; + } + pcc0 = pcc1; + } #endif } |
