Hi Fabrizio,
> Question #1: Is there a way I can do the same thing on a Sparcv8 system?
> Does sparcv8 has the 'tick' register at all or the 'tick' register
> was introduced only on newer architectures?
On SPARCv9 and above, you should actually use STICK (system tick) as we
support mix-speed configuration. %stick is a per processor register
that's synchronized across all the CPUs.
With SPARCv8, I think %tick is a privilege register and you need to use
"rdpr %tick".
> Problem #2: How can I do a similar thing with Sun's CC compiler? The
> 'asm' sections are valid only for gcc and I'm not very familiar with
> Sun's CC.
Sun's CC compiler uses a different format inline functions. Please
refer to
usr/src/uts/i86pc/ml/amd64.il and ia32.il
usr/src/uts/sparc/ml/sparc.il
for examples.
Hope that helps.
Sherry
On Mon, Aug 20, 2007 at 10:48:08AM -0700, Fabrizio Bertocci wrote:
> Hi everyone,
> I have two questions for the Solaris experts here, both related to
> finding the right way to read the real-time clock from my application
> (running in user's space).
>
> Bottom line is that I need to have a 'rdtsc()' function available on
> Sparc. Currently my
> 'rdtsc()' function works on Intel/AMD platforms and simply executes the
> processor's 'rdtsc' instruction to return a 64-bit integer with the
> number of clock tick since power up.
>
> The IA32 version of rdtsc() is:
>
> inline unsigned long long HiresTimer::rdtsc() {
> unsigned long long x;
> asm volatile(
> "rdtsc \n\t"
> : "=A" (x));
> return x;
> }
>
>
> The IA64 version is:
>
> inline unsigned long long HiresTimer::rdtsc() {
> unsigned long high, low;
> asm volatile(
> "rdtsc \n\t"
> : "=a" (low),
> "=d" (high));
> return ((unsigned long long)high << 32) | (low);
> }
>
> The above code works perfectly on Solaris 10 on x86 with gcc (3.4.x
> and 4.1.x).
>
> For the Solaris on Sparc, I was able to get this to work on a sparcv9
> system:
>
> inline unsigned long long HiresTimer::rdtsc() {
> unsigned long long tickreg;
> asm ("rd %%tick, %0" : "=r" (tickreg));
> return tickreg;
> }
>
> (still with gcc).
>
> Question #1: Is there a way I can do the same thing on a Sparcv8 system?
> Does sparcv8 has the 'tick' register at all or the 'tick' register
> was introduced only on newer architectures?
>
> Problem #2: How can I do a similar thing with Sun's CC compiler? The
> 'asm' sections are valid only for gcc and I'm not very familiar with
> Sun's CC.
>
> Thank you in advance for any help you can give me.
>
> Fabrizio Bertocci
>
>
> _______________________________________________
> opensolaris-code mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
--
Sherry Moore, Solaris Kernel Development http://blogs.sun.com/sherrym
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code