No subject
Mon Jul 23 17:50:42 EST 2007
When reading the time base lower (TBL) on a 64-bit implementation, the
contents of the entire time base (TBU || TBL) is copied into rD.
The single mftb instruction we've been using to read the timebase is all
that's needed. As far as I can tell, there's no use at all for the mftbu
instruction on a 64-bit implementation.
- Bryan
apw at us.ltcfwd.linux.ibm.com
Sent by: k42-discussion-admin at www-124.southbury.usf.ibm.com
08/09/2004 10:43 PM
To: k42-discussion at www-124.southbury.usf.ibm.com
cc:
Subject: [K42-discussion] [patch] read upper half of
timebase
I did some looking around, and it seems that we are ignoring the upper
half of the timebase register. Bryan, what are your thoughts on the
following?
Note that it doesn't fix the Mambo problem we are seeing, since hi is 0
so early in boot when we are crashing. But I think we should handle
this nonetheless.
Index: lib/libc/misc/arch/powerpc/hardware.H
===================================================================
RCS file:
/u/kitchawa/cvsroot/kitch-core/lib/libc/misc/arch/powerpc/hardware.H,v
retrieving revision 1.45
diff -u -r1.45 hardware.H
--- lib/libc/misc/arch/powerpc/hardware.H 28 Jun 2004
17:01:25 -0000 1.45
+++ lib/libc/misc/arch/powerpc/hardware.H 10 Aug 2004
02:33:04 -0000
@@ -193,8 +193,19 @@
static __inline SysTime
getClock()
{
- uval64 now;
- __asm __volatile(" mftb %0 " : "=r"(now));
+ uval64 now = 0;
+ uval32 hi, hi_again, lo;
+
+ do {
+ __asm __volatile(" mftbu %0 " : "=r"(hi));
+ __asm __volatile(" mftb %0 " : "=r"(lo));
+ __asm __volatile(" mftbu %0 " : "=r"(hi_again));
+ } while (hi != hi_again);
+
+ now |= hi;
+ now = now << 32;
+ now |= lo;
+
return now;
}
_______________________________________________
K42-discussion mailing list
K42-discussion at www-124.ibm.com
http://www-124.ibm.com/developerworks/oss/mailman/listinfo/k42-discussion
--=_alternative 0043C11885256EEC_=
Content-Type: text/html; charset="US-ASCII"
<br><font size=2 face="sans-serif">No! No! No!</font>
<br>
<br><font size=2 face="sans-serif">We don't have to do this silliness on
64-bit powerpc implementations. It was only necessary on 32-bit implementations
that we don't support anyway.</font>
<br>
<br><font size=2 face="sans-serif">From the architecture:</font>
<br><font size=2 face="sans-serif">When reading the time base lower (TBL)
on a 64-bit implementation, the contents of the entire time base (TBU ||
TBL) is copied into rD.</font>
<br>
<br><font size=2 face="sans-serif">The single mftb instruction we've been
using to read the timebase is all that's needed. As far as I can
tell, there's no use at all for the mftbu instruction on a 64-bit implementation.</font>
<br>
<br><font size=2 face="sans-serif">- Bryan</font>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>apw at us.ltcfwd.linux.ibm.com</b></font>
<br><font size=1 face="sans-serif">Sent by: k42-discussion-admin at www-124.southbury.usf.ibm.com</font>
<p><font size=1 face="sans-serif">08/09/2004 10:43 PM</font>
<td><font size=1 face="Arial"> </font>
<br><font size=1 face="sans-serif"> To:
k42-discussion at www-124.southbury.usf.ibm.com</font>
<br><font size=1 face="sans-serif"> cc:
</font>
<br><font size=1 face="sans-serif"> Subject:
[K42-discussion] [patch] read upper
half of timebase</font></table>
<br>
<br>
<br><font size=2><tt>I did some looking around, and it seems that we are
ignoring the upper<br>
half of the timebase register. Bryan, what are your thoughts on the<br>
following?<br>
<br>
Note that it doesn't fix the Mambo problem we are seeing, since hi is 0<br>
so early in boot when we are crashing. But I think we should handle<br>
this nonetheless.<br>
<br>
<br>
Index: lib/libc/misc/arch/powerpc/hardware.H<br>
===================================================================<br>
RCS file: /u/kitchawa/cvsroot/kitch-core/lib/libc/misc/arch/powerpc/hardware.H,v<br>
retrieving revision 1.45<br>
diff -u -r1.45 hardware.H<br>
--- lib/libc/misc/arch/powerpc/hardware.H
28 Jun 2004 17:01:25 -0000
1.45<br>
+++ lib/libc/misc/arch/powerpc/hardware.H
10 Aug 2004 02:33:04 -0000<br>
@@ -193,8 +193,19 @@<br>
static __inline SysTime<br>
getClock()<br>
{<br>
- uval64 now;<br>
- __asm __volatile(" mftb %0 " : "=r"(now));<br>
+ uval64 now = 0;<br>
+ uval32 hi, hi_again, lo;<br>
+<br>
+ do {<br>
+
__asm __volatile(" mftbu %0 " : "=r"(hi));<br>
+
__asm __volatile(" mftb %0 " : "=r"(lo));<br>
+
__asm __volatile(" mftbu %0 " : "=r"(hi_again));<br>
+ } while (hi != hi_again);<br>
+<br>
+ now |= hi;<br>
+ now = now << 32;<br>
+ now |= lo;<br>
+<br>
return now;<br>
}<br>
<br>
_______________________________________________<br>
K42-discussion mailing list<br>
K42-discussion at www-124.ibm.com<br>
http://www-124.ibm.com/developerworks/oss/mailman/listinfo/k42-discussion<br>
</tt></font>
<br>
--=_alternative 0043C11885256EEC_=--
More information about the K42-discussion
mailing list