Fix DELAY function to use the RPCC cycle counter register.
This commit is contained in:
parent
d50e5bd5cc
commit
2d41e34a07
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60200
@ -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;
|
||||
|
||||
while (N > 0) /* XXX */
|
||||
N -= 3; /* XXX */
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
pcc0 = alpha_rpcc() & 0xffffffffUL;
|
||||
cycles = 0;
|
||||
usec = 0;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user