Implement Arm BKPT instruction.
authorpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
Sat, 4 Feb 2006 19:35:26 +0000 (19:35 +0000)
committerpbrook <pbrook@c046a42c-6fe2-441c-8c8c-71466251a162>
Sat, 4 Feb 2006 19:35:26 +0000 (19:35 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1740 c046a42c-6fe2-441c-8c8c-71466251a162

linux-user/main.c
target-arm/cpu.h
target-arm/helper.c
target-arm/op.c
target-arm/translate.c

index ef3a171166be7b960ec6ae2e388a53bcca1b9c97..56accfbb5277a6a3933c2f789cc89a4e3fc681dd 100644 (file)
@@ -358,14 +358,27 @@ void cpu_loop(CPUARMState *env)
             }
             break;
         case EXCP_SWI:
+        case EXCP_BKPT:
             {
                 /* system call */
-                if (env->thumb) {
-                    insn = lduw((void *)(env->regs[15] - 2));
-                    n = insn & 0xff;
+                if (trapnr == EXCP_BKPT) {
+                    if (env->thumb) {
+                        insn = lduw((void *)(env->regs[15]));
+                        n = insn & 0xff;
+                        env->regs[15] += 2;
+                    } else {
+                        insn = ldl((void *)(env->regs[15]));
+                        n = (insn & 0xf) | ((insn >> 4) & 0xff0);
+                        env->regs[15] += 4;
+                    }
                 } else {
-                    insn = ldl((void *)(env->regs[15] - 4));
-                    n = insn & 0xffffff;
+                    if (env->thumb) {
+                        insn = lduw((void *)(env->regs[15] - 2));
+                        n = insn & 0xff;
+                    } else {
+                        insn = ldl((void *)(env->regs[15] - 4));
+                        n = insn & 0xffffff;
+                    }
                 }
 
                 if (n == ARM_NR_cacheflush) {
index 3b36839e4b236a15a52c1d0c6a3c434a6b84f465..7cc7da60e9cb7549f9c94b3e064a86825fb6585b 100644 (file)
@@ -34,6 +34,7 @@
 #define EXCP_DATA_ABORT      4
 #define EXCP_IRQ             5
 #define EXCP_FIQ             6
+#define EXCP_BKPT            7
 
 /* We currently assume float and double are IEEE single and double
    precision respectively.
index 538e17a35c80d4fbf46bec52e5619fdc24817818..5804df8264cbb90b4c508d5aba2e0fc88fd71a61 100644 (file)
@@ -127,6 +127,7 @@ void do_interrupt(CPUARMState *env)
         offset = 0;
         break;
     case EXCP_PREFETCH_ABORT:
+    case EXCP_BKPT:
         new_mode = ARM_CPU_MODE_ABT;
         addr = 0x0c;
         mask = CPSR_A | CPSR_I;
index 35419a1b71b40e70a0e97bfc382551b20e74ec6c..acac2394a6e6618575119594f4726fccc83de0d6 100644 (file)
@@ -885,6 +885,12 @@ void OPPROTO op_wfi(void)
     cpu_loop_exit();
 }
 
+void OPPROTO op_bkpt(void)
+{
+    env->exception_index = EXCP_BKPT;
+    cpu_loop_exit();
+}
+
 /* VFP support.  We follow the convention used for VFP instrunctions:
    Single precition routines have a "s" suffix, double precision a
    "d" suffix.  */
index 089fbf2fd9d80cba2467603a6eb9d936e13c097c..5f817080f897288b62e9f1b7b880cfccc86aa578 100644 (file)
@@ -1217,6 +1217,12 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)
                 gen_op_addl_T0_T1_saturate();
             gen_movl_reg_T0(s, rd);
             break;
+        case 7: /* bkpt */
+            gen_op_movl_T0_im((long)s->pc - 4);
+            gen_op_movl_reg_TN[0][15]();
+            gen_op_bkpt();
+            s->is_jmp = DISAS_JUMP;
+            break;
         case 0x8: /* signed multiply */
         case 0xa:
         case 0xc:
@@ -2183,6 +2189,13 @@ static void disas_thumb_insn(DisasContext *s)
                 gen_bx(s);
             break;
 
+        case 0xe: /* bkpt */
+            gen_op_movl_T0_im((long)s->pc - 2);
+            gen_op_movl_reg_TN[0][15]();
+            gen_op_bkpt();
+            s->is_jmp = DISAS_JUMP;
+            break;
+
         default:
             goto undef;
         }