qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] SPARC - host support in vl.c
@ 2004-08-31 22:04 Bochnig, Martin
  2004-08-31 22:14 ` Falk Hueffner
  2004-08-31 23:24 ` [Qemu-devel] The very best I can get on SPARC Bochnig, Martin
  0 siblings, 2 replies; 7+ messages in thread
From: Bochnig, Martin @ 2004-08-31 22:04 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-09-01 15:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-31 22:04 [Qemu-devel] SPARC - host support in vl.c Bochnig, Martin
2004-08-31 22:14 ` Falk Hueffner
2004-08-31 22:24   ` Bochnig, Martin
2004-08-31 22:41     ` Falk Hueffner
2004-09-01  7:57       ` Bochnig, Martin
2004-09-01 15:44   ` Richard Zidlicky
2004-08-31 23:24 ` [Qemu-devel] The very best I can get on SPARC Bochnig, Martin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).