ARM: Trigger system calls from the SupervisorCall invoke method.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:05 +0000 (12:58 -0500)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:05 +0000 (12:58 -0500)
This simplifies the decoder slightly, and makes the system call mechanism
very slightly more realistic.

src/arch/arm/faults.cc
src/arch/arm/faults.hh
src/arch/arm/isa/decoder/arm.isa

index 9e32a23a391cc2f0f493e8c27e2b8177d8010372..9b365790913c201d6592e6bba6bab0e6c5a799a9 100644 (file)
@@ -160,6 +160,27 @@ UndefinedInstruction::invoke(ThreadContext *tc)
     }
 }
 
+void
+SupervisorCall::invoke(ThreadContext *tc)
+{
+    // As of now, there isn't a 32 bit thumb version of this instruction.
+    assert(!machInst.bigThumb);
+    uint32_t callNum;
+    if (machInst.thumb) {
+        callNum = bits(machInst, 7, 0);
+    } else {
+        callNum = bits(machInst, 23, 0);
+    }
+    if (callNum == 0) {
+        callNum = tc->readIntReg(INTREG_R7);
+    }
+    tc->syscall(callNum);
+
+    // Advance the PC since that won't happen automatically.
+    tc->setPC(tc->readNextPC());
+    tc->setNextPC(tc->readNextNPC());
+}
+
 #endif // FULL_SYSTEM
 
 // return via SUBS pc, lr, xxx; rfe, movs, ldm
index 90a730507beba4b9e4e83e95ea97584c252109f6..64940dd2614a5b8f83a4cb01c48dd7e8547ff65f 100644 (file)
@@ -125,7 +125,19 @@ class UndefinedInstruction : public ArmFault<UndefinedInstruction>
 #endif
 };
 
-class SupervisorCall       : public ArmFault<SupervisorCall> {};
+class SupervisorCall       : public ArmFault<SupervisorCall>
+{
+#if !FULL_SYSTEM
+  protected:
+    ExtMachInst machInst;
+
+  public:
+    SupervisorCall(ExtMachInst _machInst) : machInst(_machInst)
+    {}
+
+    void invoke(ThreadContext *tc);
+#endif
+};
 class PrefetchAbort        : public ArmFault<PrefetchAbort> {};
 class DataAbort            : public ArmFault<DataAbort> {};
 class Interrupt            : public ArmFault<Interrupt> {};
index 050571240efed71f14fe28253747dd65bdfa1f6c..fe7e67b1127c9a30cde1370e8b430c489cc25a95 100644 (file)
@@ -286,18 +286,13 @@ format DataOp {
             } // CPNUM  (OP4 == 1)
         } //OPCODE_4
 
+        1: PredOp::swi({{
 #if FULL_SYSTEM
-        1: PredOp::swi({{ fault = new SupervisorCall; }}, IsSerializeAfter, IsNonSpeculative, IsSyscall);
+            fault = new SupervisorCall();
 #else
-        1: PredOp::swi({{ if (testPredicate(CondCodes, condCode))
-            {
-                if (IMMED_23_0)
-                    xc->syscall(IMMED_23_0);
-                else
-                    xc->syscall(R7);
-            }
-        }});
-#endif // FULL_SYSTEM
+            fault = new SupervisorCall(machInst);
+#endif
+        }}, IsSyscall);
     } // OPCODE_24
 
 }