Thread (23 messages) 23 messages, 7 authors, 2010-04-23

Re: Continual reading from the PowerPc time base register is not stable

From: Chris Friesen <hidden>
Date: 2010-03-25 22:19:13

On 03/25/2010 09:00 AM, Csdncannon wrote:
I am really sorry that the previously attached code is wrong, this one
"timebase.c" is the right one, and the "log_timebase" file is the right log.

We are using FreeScale PowerPc 8378, kernel 2.6.28 and compiled as 32-bit.

volatile unsigned long long getTimeBase()
{
	unsigned long upper,lower,upper2;
	do {
		asm volatile("sync; isync":::"memory");
		asm volatile("mftbu %0" : "=r" (upper));
		asm volatile("sync; isync":::"memory");
		asm volatile("mftbl %0" : "=r" (lower));
		asm volatile("sync; isync":::"memory");
		asm volatile("mftbu %0" : "=r" (upper2));
		asm volatile("sync; isync":::"memory");
	}while(upper2!=upper);

	return (upper<<32)|lower;
}


Shouldn't "upper" be cast to 64-bit before shifting?

Chris
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help