summaryrefslogtreecommitdiffstats
path: root/sys/boot
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2005-06-04 21:50:44 +0000
committermarcel <marcel@FreeBSD.org>2005-06-04 21:50:44 +0000
commited7fa679fad4f5d58e3577d1962ab65eb9f91770 (patch)
tree1524c7df7ed8385a5983d4253585f3bb4d7fa23c /sys/boot
parentaa557734c2b0f94c65816af9e5ce5664ea792d40 (diff)
downloadFreeBSD-src-ed7fa679fad4f5d58e3577d1962ab65eb9f91770.zip
FreeBSD-src-ed7fa679fad4f5d58e3577d1962ab65eb9f91770.tar.gz
Fix delay(). The processor cycle counter is a 32-bit wrapping counter.
Hence, mask off the upper 32 bits and deal with wrap-arounds. MFC after: 1 week
Diffstat (limited to 'sys/boot')
-rw-r--r--sys/boot/alpha/libalpha/delay.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/boot/alpha/libalpha/delay.c b/sys/boot/alpha/libalpha/delay.c
index 6e437a7..5a81c78 100644
--- a/sys/boot/alpha/libalpha/delay.c
+++ b/sys/boot/alpha/libalpha/delay.c
@@ -33,9 +33,12 @@ __FBSDID("$FreeBSD$");
void
delay(int usecs)
{
- struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR;
- unsigned long start = alpha_rpcc();
- unsigned long end = start + (hwrpb->rpb_cc_freq * usecs) / 1000000;
- while (alpha_rpcc() < end)
- ;
+ struct rpb *hwrpb = (struct rpb *)HWRPB_ADDR;
+ unsigned long end, now, start;
+
+ start = alpha_rpcc() & 0xfffffffful;
+ end = start + (hwrpb->rpb_cc_freq * usecs) / 1000000;
+ do {
+ now = alpha_rpcc() & 0xfffffffful;
+ } while (now < end || (now > start && end < start));
}
OpenPOWER on IntegriCloud