Skip to contentSkip to conversation

m68k updates #2

PATCH New Richard Zidlicky 1 participant 1 message Mar 17, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k updates #2

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

vl.c +24 -0
diff -urN qemu-cvs/vl.c qemu-cvs-new/vl.c
@@ -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