Skip to contentSkip to conversation

sh4: signal handling for the user space emulator

PATCH New Magnus Damm 1 participant 1 message Nov 30, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh4: signal handling for the user space emulator

Hi everyone,

Here comes a patch that implements signal handling for the sh4 user space emulator. Please apply on top of the recently posted delay slot patch.

 linux-user/main.c              |   12 +
 linux-user/sh4/target_signal.h |    5
 linux-user/signal.c            |  321 ++++++++++++++++++++++++++++++++++++++--
 target-sh4/helper.c            |    6
 4 files changed, 331 insertions(+), 13 deletions(-)

Thanks,

/ magnus

linux-user/main.c +12 -0
@@ -1617,6 +1617,9 @@ void cpu_loop (CPUState *env)
             env->gregs[0] = ret;
             env->pc += 2;
             break;
+        case EXCP_INTERRUPT:
+            /* just indicate that signals should be handled asap */
+            break;
         case EXCP_DEBUG:
             {
                 int sig;
@@ -1631,6 +1634,15 @@ void cpu_loop (CPUState *env)
                   }
             }
             break;
+	case 0xa0:
+	case 0xc0:
+            info.si_signo = SIGSEGV;
+            info.si_errno = 0;
+            info.si_code = TARGET_SEGV_MAPERR;
+            info._sifields._sigfault._addr = env->tea;
+            queue_signal(info.si_signo, &info);
+	    break;
+
         default:
             printf ("Unhandled trap: 0x%x\n", trapnr);
             cpu_dump_state(env, stderr, fprintf, 0);
linux-user/sh4/target_signal.h +5 -0
@@ -21,4 +21,9 @@ typedef struct target_sigaltstack {
 #define TARGET_MINSIGSTKSZ    2048
 #define TARGET_SIGSTKSZ       8192
 
+static inline abi_ulong get_sp_from_cpustate(CPUSH4State *state)
+{
+    return state->gregs[15];
+}
+
 #endif /* TARGET_SIGNAL_H */
linux-user/signal.c +311 -10

345 lines not on this page · raw message

target-sh4/helper.c +3 -3
@@ -39,16 +39,16 @@ int cpu_sh4_handle_mmu_fault(CPUState * 
 			     int mmu_idx, int is_softmmu)
 {
     env->tea = address;
+    env->exception_index = 0;
     switch (rw) {
     case 0:
+	env->tea = address;
         env->exception_index = 0x0a0;
         break;
     case 1:
+	env->tea = address;
         env->exception_index = 0x0c0;
         break;
-    case 2:
-        env->exception_index = 0x0a0;
-        break;
     }
     return 1;
 }