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:
parent
aa557734c2
commit
ed7fa679fa
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user