Skip to contentSkip to conversation

experimental sh4 host support

PATCH In review Magnus Damm 2 participants 2 messages Nov 13, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 experimental sh4 host support

From: Magnus Damm <[email protected]>

This patch adds experimental sh4 host support to QEMU. The patch contains a work-in-progresss snapshot, and only the bare essentials are in place at this point. The sh4 host support has been tested with the sh4 target using the QEMU sh4 user space emulator and tiny assembly snippets. Both big and little endian host support should be ok at this point, but 64-bit targets and softmmu are still on the TODO list together with fixes for icache handling.

---

 configure            |   11 
 cpu-exec.c           |   15 
 dyngen-exec.h        |    4 
 exec-all.h           |    9 
 tcg/sh4/tcg-target.c |  864 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tcg/sh4/tcg-target.h |   65 +++
 6 files changed, 966 insertions(+), 2 deletions(-)
configure +10 -1
@@ -134,13 +134,19 @@ elif check_define _ARCH_PPC ; then
   else
     cpu="ppc"
   fi
+elif check_define __SH4__ ; then
+  if check_define __BIG_ENDIAN__ ; then
+    cpu="sh4eb"
+  else
+    cpu="sh4"
+  fi
 else
   cpu=`uname -m`
 fi
 
 target_list=""
 case "$cpu" in
-  alpha|cris|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|sparc64)
+  alpha|cris|ia64|m68k|microblaze|mips|mips64|ppc|ppc64|sh4|sh4eb|sparc64)
     cpu="$cpu"
   ;;
   i386|i486|i586|i686|i86pc|BePC)
@@ -1878,6 +1884,9 @@ case "$cpu" in
   armv4b|armv4l)
     ARCH=arm
   ;;
+  sh4|sh4eb)
+    ARCH=sh4
+  ;;
   *)
     echo "Unsupported CPU = $cpu"
     exit 1
cpu-exec.c +15 -0
@@ -1190,6 +1190,21 @@ int cpu_signal_handler(int host_signum, 
                              &uc->uc_sigmask, puc);
 }
 
+#elif defined(__SH4__)
+
+int cpu_signal_handler(int host_signum, void *pinfo,
+                       void *puc)
+{
+    siginfo_t *info = pinfo;
+    struct ucontext *uc = puc;
+    greg_t pc = uc->uc_mcontext.pc;
+    int is_write;
+
+    /* XXX: compute is_write */
+    is_write = 0;
+    return handle_cpu_signal(pc, (unsigned long)info->si_addr,
+                             is_write, &uc->uc_sigmask, puc);
+}
 #else
 
 #error host CPU specific signal handler needed
dyngen-exec.h +4 -0
@@ -106,6 +106,10 @@ extern int printf(const char *, ...);
 #define AREG0 "r7"
 #define AREG1 "r4"
 #define AREG2 "r5"
+#elif defined(__SH4__)
+#define AREG0 "r11"
+#define AREG1 "r12"
+#define AREG2 "r13"
 #else
 #error unsupported CPU
 #endif
exec-all.h +8 -1
@@ -114,7 +114,7 @@ static inline int tlb_set_page(CPUState 
 #define CODE_GEN_AVG_BLOCK_SIZE 64
 #endif
 
-#if defined(_ARCH_PPC) || defined(__x86_64__) || defined(__arm__) || defined(__i386__)
+#if defined(_ARCH_PPC) || defined(__x86_64__) || defined(__arm__) || defined(__i386__) || defined(__SH4__)
 #define USE_DIRECT_JUMP
 #endif
 
@@ -189,6 +189,13 @@ extern int code_gen_max_blocks;
 #if defined(_ARCH_PPC)
 extern void ppc_tb_set_jmp_target(unsigned long jmp_addr, unsigned long addr);
 #define tb_set_jmp_target1 ppc_tb_set_jmp_target
+#elif defined(__SH4__)
+static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
+{
+    /* patch the branch destination */
+    *(uint32_t *)jmp_addr = addr;
+    /* FIXME: need to handle caches */
+}
 #elif defined(__i386__) || defined(__x86_64__)
 static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
 {
tcg/sh4/tcg-target.c new file +864 -0

864 lines not on this page · raw message

tcg/sh4/tcg-target.h new file +65 -0

65 lines not on this page · raw message

#1 lore raw
Quoted 10 lines · Magnus Damm

From: Magnus Damm <[email protected]>

This patch adds experimental sh4 host support to QEMU. The patch contains a work-in-progresss snapshot, and only the bare essentials are in place at this point. The sh4 host support has been tested with the sh4 target using the QEMU sh4 user space emulator and tiny assembly snippets. Both big and little endian host support should be ok at this point, but 64-bit targets and softmmu are still on the TODO list together with fixes for icache handling.

Symbols starting with __ are reserved, please change the names. [..snip..]

Signature · 1 line
mailto:[email protected]