Skip to contentSkip to conversation

sh4: user space emulator patches

Qemu-devel Magnus Damm 1 participant 1 message Jun 12, 2007

lore
Share & tools
lore
#0 lore raw

Hi everyone,

Here comes a batch of patches for the sh4 user space emulator. I have another 10 patches in my local queue that are specific to the sh4 user space emulator, and when I'm done with them I'll spend time on fixing up the sh4 system emulator. Maybe it's time for some CVS write access? Unless people enjoy committing patches for me that is. =)

- sh4: add missing cpu_halted symbol
- sh4: set FD bit in SR to emulate kernel behaviour
- sh4: setup stack properly, fixes wrong argc value problem
- sh4: use correct data structures for stat syscalls

Please apply.

Thanks!

/ magnus

sh4: add missing cpu_halted symbol

The sh4 user space emulator is missing an implementation of cpu_halted(). Without this patch is it impossible to execute the qemu-sh4 binary.

target-sh4/cpu.h +1 -0
@@ -115,6 +115,7 @@ typedef struct CPUSH4State {
     jmp_buf jmp_env;
     int user_mode_only;
     int interrupt_request;
+    int halted;
     int exception_index;
      CPU_COMMON tlb_t utlb[UTLB_SIZE];	/* unified translation table */
     tlb_t itlb[ITLB_SIZE];	/* instruction translation table */
target-sh4/exec.h +10 -0
@@ -36,6 +36,16 @@ register uint32_t T1 asm(AREG2);
 #include "cpu.h"
 #include "exec-all.h"
 
+static inline int cpu_halted(CPUState *env) {
+    if (!env->halted)
+        return 0;
+    if (env->interrupt_request & CPU_INTERRUPT_HARD) {
+        env->halted = 0;
+        return 0;
+    }
+    return EXCP_HALTED;
+}
+
 #ifndef CONFIG_USER_ONLY
 #include "softmmu_exec.h"
 #endif

sh4: set FD bit in SR to emulate kernel behaviour

The FD bit in SR is set by the kernel to trap floating point instructions.

target-sh4/translate.c +1 -1
@@ -125,7 +125,7 @@ void cpu_dump_state(CPUState * env, FILE
 void cpu_sh4_reset(CPUSH4State * env)
 {
 #if defined(CONFIG_USER_ONLY)
-    env->sr = 0x00000000;
+    env->sr = SR_FD;            /* FD - kernel does lazy fpu context switch */
 #else
     env->sr = 0x700000F0;	/* MD, RB, BL, I3-I0 */
 #endif

sh4: setup stack properly, fixes wrong argc value problem

The stack setup code is currently incorrect so argc is not passed properly to the emulated binary.

linux-user/elfload.c +1 -1
@@ -325,7 +325,7 @@ static inline void init_thread(struct ta
 {
   /* Check other registers XXXXX */
   regs->pc = infop->entry;
-  regs->regs[15] = infop->start_stack - 16 * 4;
+  regs->regs[15] = infop->start_stack;
 }
 
 #define USE_ELF_CORE_DUMP

sh4: use correct data structures for stat syscalls

The current stat syscalls are not emulated correctly under sh4. This patch fixes this by using the same data structure as the sh4 kernel.

linux-user/syscall_defs.h +60 -1

73 lines not on this page · raw message