qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Zidlicky <rz@linux-m68k.org>
To: Fabrice Bellard <fabrice@bellard.org>, Qemu ML <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [patch] m68k updates #2
Date: Wed, 17 Mar 2004 19:07:00 +0100	[thread overview]
Message-ID: <20040317180700.GB2562@linux-m68k.org> (raw)

Hi,

this is experimantal and I am open to suggestions how to do
it better. m68k does not have any rdtsc equivalent so I have
to work around it like this - normal timer may have very low
resolution (around 1/200 s).
Afaics the better alternative would be to count instructions
in generated code blocks and calculate clock value from this
somehow.

Richard


diff -urN qemu-cvs/vl.c qemu-cvs-new/vl.c
--- qemu-cvs/vl.c	Mon Mar 15 00:43:15 2004
+++ qemu-cvs-new/vl.c	Wed Mar 17 18:35:55 2004
@@ -346,6 +346,30 @@
     return val;
 }
 
+#elif defined(__mc68020__)
+
+/* 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;
+}
+
 #else
 #error unsupported CPU
 #endif

                 reply	other threads:[~2004-03-17 20:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040317180700.GB2562@linux-m68k.org \
    --to=rz@linux-m68k.org \
    --cc=fabrice@bellard.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).