Patchwork [6/6] target-alpha: Add high-resolution access to wall clock and an alarm.

login
register
mail settings
Submitter Richard Henderson
Date Aug. 26, 2011, 8:03 p.m.
Message ID <4E57FC17.1080405@twiddle.net>
Download mbox | patch
Permalink /patch/111834/
State New
Headers show

Comments

Richard Henderson - Aug. 26, 2011, 8:03 p.m.
On 08/26/2011 06:36 AM, Peter Maydell wrote:
> Look at the way target-i386 and target-mips use gen_io_start()
> and gen_io_end() around x86 io insns and MIPS mtc0. I think
> that what you need is (a) to bracket with gen_io_start/end
> and (b) to end the translation block, but that's really just
> guesswork from the existing code...

I'll be applying this on top of 6/6.  Look sane?


r~

---

Patch

diff --git a/target-alpha/translate.c b/target-alpha/translate.c
index 37f2f20..8f0dc3e 100644
--- a/target-alpha/translate.c
+++ b/target-alpha/translate.c
@@ -1609,7 +1609,17 @@  static void gen_mfpr(int ra, int regno)
 
     if (regno == 250) {
         /* WALL_TIME */
-        gen_helper_get_time(cpu_ir[ra]);
+        if (use_iocount) {
+            /* Mark as an IO operation because we read the time.  */
+            gen_io_start();
+            gen_helper_get_time(cpu_ir[ra]);
+            gen_io_end();
+            /* Other targets break the TB to be able to take timer
+               interrupts immediately.  This doesn't apply to Alpha
+               because we never take interrupts in PALmode.  */
+        } else {
+            gen_helper_get_time(cpu_ir[ra]);
+        }
         return;
     }
 
@@ -1661,7 +1671,14 @@  static ExitStatus gen_mtpr(DisasContext *ctx, int rb, int regno)
 
     case 251:
         /* ALARM */
-        gen_helper_set_alarm(tmp);
+        if (use_icount) {
+            /* Mark as an IO operation because we reference the time.  */
+            gen_io_start();
+            gen_helper_set_alarm(tmp);
+            gen_io_end();
+        } else {
+            gen_helper_set_alarm(tmp);
+        }
         break;
 
     default: