qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU


From: Thiemo Seufer
Subject: Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU
Date: Wed, 11 Apr 2007 17:05:16 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Atif Hashmi wrote:
> Hi Eduardo,
> 
> Thanks a lot for your help. I really appreciate it. I have added the
> functionality that I wanted.

Just in case it might help somebody reading this list, I use the appended
patch to detect a special instruction pattern as pass/fail condition and
shut down qemu with the appropriate message.


Thiemo


Index: qemu-cvs/target-mips/exec.h
===================================================================
--- qemu-cvs.orig/target-mips/exec.h
+++ qemu-cvs/target-mips/exec.h
@@ -140,6 +140,9 @@
 uint64_t do_sdr_kernel (uint64_t);
 #endif
 #endif
+void do_avp_ok (void);
+void do_avp_fail (void);
+
 void do_pmon (int function);
 
 void dump_sc (void);
Index: qemu-cvs/target-mips/op.c
===================================================================
--- qemu-cvs.orig/target-mips/op.c
+++ qemu-cvs/target-mips/op.c
@@ -954,6 +954,16 @@
 OP_COND(lez, (int32_t)T0 <= 0);
 OP_COND(ltz, (int32_t)T0 < 0);
 
+//
+void op_avp_ok (void) {
+    CALL_FROM_TB0(do_avp_ok);
+    RETURN();
+}
+void op_avp_fail (void) {
+    CALL_FROM_TB0(do_avp_fail);
+    RETURN();
+}
+
 /* Branches */
 //#undef USE_DIRECT_JUMP
 
Index: qemu-cvs/target-mips/op_helper.c
===================================================================
--- qemu-cvs.orig/target-mips/op_helper.c
+++ qemu-cvs/target-mips/op_helper.c
@@ -535,6 +535,18 @@
         fputs("\n", logfile);
 }
 
+void do_avp_ok (void)
+{
+    puts("ok");
+    qemu_system_shutdown_request();
+}
+
+void do_avp_fail (void)
+{
+    puts("fail");
+    qemu_system_shutdown_request();
+}
+
 void do_pmon (int function)
 {
     function /= 2;
Index: qemu-cvs/target-mips/translate.c
===================================================================
--- qemu-cvs.orig/target-mips/translate.c
+++ qemu-cvs/target-mips/translate.c
@@ -881,6 +881,14 @@
     uint32_t uimm;
     const char *opn = "unk";
 
+if (opc == OPC_SLTIU && rs == 0 && rt == 0 && (((uint16_t)imm == 0xabc2) | 
((uint16_t)imm == 0xabc1))) {
+    if ((uint16_t)imm == 0xabc2)
+        gen_op_avp_ok();
+    else
+        gen_op_avp_fail();
+    ctx->bstate = BS_STOP;
+    return;
+}
     if (rt == 0 && opc != OPC_ADDI && opc != OPC_DADDI) {
         /* if no destination, treat it as a NOP 
          * For addi, we must generate the overflow exception when needed.




reply via email to

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