Hi Cameron,
Anyone know of an equivalent for 601 that will still
work on 603+? Or am I as dead in the water as I suspect?
The rdtsc function has its origin in the rdtsc instruction on an x86
CPU, it returns a 64-bit value, the number of cycles since power on.
I can see from the rdtsc function for PowerPC that it is implemented
using a routine, so it's exact performance isn't critical I would presume.
The nearest instruction on a 601 is mfspr rd,6 which loads the
decrementer. This is a user-level instruction on the 601 (not on the 603
or later). So, -DEC roughly the tb.
According to the Ppc601 user manual, dec uses the 7.8125MHz RTC clock
as its time base (pg H-3), but on page B-8 it says the power architecure
decrements dec every nanosecond.
So, we could do something like:
static __inline__ unsigned long long rdtsc(void)
{
asm { mfspr regUpper,6 };
return (long long)-regUpper<<32;
}
In this case, the effective frequency of the clock is 7.8125MHz*2^32.
For the PowerPc601. On initialisation I would probably read the
processor version register (PVR) to determine the processor;
and if it was a 601 I'd substitute the PowerPC 601 code and
then flush the code and data caches.
-cheers from julz @P