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
This commit is contained in:
Marcel Moolenaar 2005-06-04 21:50:44 +00:00
parent ecf4269527
commit b7b527edfa

View File

@ -34,8 +34,11 @@ 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)
;
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));
}