qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] SPARC - host support in vl.c


From: Bochnig, Martin
Subject: [Qemu-devel] SPARC - host support in vl.c
Date: Wed, 01 Sep 2004 00:04:50 +0200
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.2.1) Gecko/20030711

Here my patch suggestions to add SPARC host support to vl.c :


#elif defined(__sparc__)

 /* Derived from: "m68k updates #2" by Richard Zidlicky
 "crude hack to get some sort of rdtsc support" */

#include <sys/time.h>
static int64_t cputicks=0;
static struct timeval lastcptcall={0,0};

// assume 5 MHz Pentium, min 80 ticks between rdtsc calls

int64_t cpu_get_real_ticks(void)
{
     struct timeval tp;
     gettimeofday(&tp,(void*)0);
     if (tp.tv_sec == lastcptcall.tv_sec &&
        tp.tv_usec == lastcptcall.tv_usec ){
       cputicks += 1;
     } else {
       cputicks=0;
       lastcptcall=tp;
     }
     return ((int64_t)tp.tv_sec*1000000+tp.tv_usec)*5+cputicks;
}


#elif defined(__sparc64__)

/* I'm not sure it was worth it, personally.
*
*UltraSparc:
*
*  unsigned long x;
*  asm volatile ("rd %tick, %0" : "=r"(x));
*
* Earlier Sparcs do not have this feature.
*
*
*/

int64_t cpu_get_real_ticks(void)
{
    int64_t val;
   asm volatile ("rd %%tick, %0" : "=r"(val));
    return val;
}

#else
#error unsupported CPU
#endif

Any ideas would be appreciated.

Martin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]