peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0027-target-lm32-switch-to-AREG0-free-mode.patch

5544c1
From 25e9a95d0571c40738daa479467d757eb477739e Mon Sep 17 00:00:00 2001
5544c1
From: Blue Swirl <blauwirbel@gmail.com>
5544c1
Date: Sun, 2 Sep 2012 06:57:17 +0000
5544c1
Subject: [PATCH] target-lm32: switch to AREG0 free mode
5544c1
5544c1
Add an explicit CPUState parameter instead of relying on AREG0
5544c1
and switch to AREG0 free mode.
5544c1
5544c1
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 configure                 |  2 +-
5544c1
 target-lm32/Makefile.objs |  2 --
5544c1
 target-lm32/helper.h      | 20 ++++++++++----------
5544c1
 target-lm32/op_helper.c   | 29 +++++++++++------------------
5544c1
 target-lm32/translate.c   | 28 +++++++++++++---------------
5544c1
 5 files changed, 35 insertions(+), 46 deletions(-)
5544c1
5544c1
diff --git a/configure b/configure
5544c1
index 3ad6f74..1e3ea7f 100755
5544c1
--- a/configure
5544c1
+++ b/configure
5544c1
@@ -3839,7 +3839,7 @@ symlink "$source_path/Makefile.target" "$target_dir/Makefile"
5544c1
 
5544c1
 
5544c1
 case "$target_arch2" in
5544c1
-  alpha | i386 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
5544c1
+  alpha | i386 | lm32 | or32 | s390x | sparc* | x86_64 | xtensa* | ppc*)
5544c1
     echo "CONFIG_TCG_PASS_AREG0=y" >> $config_target_mak
5544c1
   ;;
5544c1
 esac
5544c1
diff --git a/target-lm32/Makefile.objs b/target-lm32/Makefile.objs
5544c1
index 2e0e093..ca20f21 100644
5544c1
--- a/target-lm32/Makefile.objs
5544c1
+++ b/target-lm32/Makefile.objs
5544c1
@@ -1,4 +1,2 @@
5544c1
 obj-y += translate.o op_helper.o helper.o cpu.o
5544c1
 obj-$(CONFIG_SOFTMMU) += machine.o
5544c1
-
5544c1
-$(obj)/op_helper.o: QEMU_CFLAGS += $(HELPER_CFLAGS)
5544c1
diff --git a/target-lm32/helper.h b/target-lm32/helper.h
5544c1
index 9d335ef..07f5670 100644
5544c1
--- a/target-lm32/helper.h
5544c1
+++ b/target-lm32/helper.h
5544c1
@@ -1,14 +1,14 @@
5544c1
 #include "def-helper.h"
5544c1
 
5544c1
-DEF_HELPER_1(raise_exception, void, i32)
5544c1
-DEF_HELPER_0(hlt, void)
5544c1
-DEF_HELPER_1(wcsr_im, void, i32)
5544c1
-DEF_HELPER_1(wcsr_ip, void, i32)
5544c1
-DEF_HELPER_1(wcsr_jtx, void, i32)
5544c1
-DEF_HELPER_1(wcsr_jrx, void, i32)
5544c1
-DEF_HELPER_0(rcsr_im, i32)
5544c1
-DEF_HELPER_0(rcsr_ip, i32)
5544c1
-DEF_HELPER_0(rcsr_jtx, i32)
5544c1
-DEF_HELPER_0(rcsr_jrx, i32)
5544c1
+DEF_HELPER_2(raise_exception, void, env, i32)
5544c1
+DEF_HELPER_1(hlt, void, env)
5544c1
+DEF_HELPER_2(wcsr_im, void, env, i32)
5544c1
+DEF_HELPER_2(wcsr_ip, void, env, i32)
5544c1
+DEF_HELPER_2(wcsr_jtx, void, env, i32)
5544c1
+DEF_HELPER_2(wcsr_jrx, void, env, i32)
5544c1
+DEF_HELPER_1(rcsr_im, i32, env)
5544c1
+DEF_HELPER_1(rcsr_ip, i32, env)
5544c1
+DEF_HELPER_1(rcsr_jtx, i32, env)
5544c1
+DEF_HELPER_1(rcsr_jrx, i32, env)
5544c1
 
5544c1
 #include "def-helper.h"
5544c1
diff --git a/target-lm32/op_helper.c b/target-lm32/op_helper.c
5544c1
index 51edc1a..7b91d8c 100644
5544c1
--- a/target-lm32/op_helper.c
5544c1
+++ b/target-lm32/op_helper.c
5544c1
@@ -1,6 +1,5 @@
5544c1
 #include <assert.h>
5544c1
 #include "cpu.h"
5544c1
-#include "dyngen-exec.h"
5544c1
 #include "helper.h"
5544c1
 #include "host-utils.h"
5544c1
 
5544c1
@@ -18,55 +17,55 @@
5544c1
 #define SHIFT 3
5544c1
 #include "softmmu_template.h"
5544c1
 
5544c1
-void helper_raise_exception(uint32_t index)
5544c1
+void helper_raise_exception(CPULM32State *env, uint32_t index)
5544c1
 {
5544c1
     env->exception_index = index;
5544c1
     cpu_loop_exit(env);
5544c1
 }
5544c1
 
5544c1
-void helper_hlt(void)
5544c1
+void helper_hlt(CPULM32State *env)
5544c1
 {
5544c1
     env->halted = 1;
5544c1
     env->exception_index = EXCP_HLT;
5544c1
     cpu_loop_exit(env);
5544c1
 }
5544c1
 
5544c1
-void helper_wcsr_im(uint32_t im)
5544c1
+void helper_wcsr_im(CPULM32State *env, uint32_t im)
5544c1
 {
5544c1
     lm32_pic_set_im(env->pic_state, im);
5544c1
 }
5544c1
 
5544c1
-void helper_wcsr_ip(uint32_t im)
5544c1
+void helper_wcsr_ip(CPULM32State *env, uint32_t im)
5544c1
 {
5544c1
     lm32_pic_set_ip(env->pic_state, im);
5544c1
 }
5544c1
 
5544c1
-void helper_wcsr_jtx(uint32_t jtx)
5544c1
+void helper_wcsr_jtx(CPULM32State *env, uint32_t jtx)
5544c1
 {
5544c1
     lm32_juart_set_jtx(env->juart_state, jtx);
5544c1
 }
5544c1
 
5544c1
-void helper_wcsr_jrx(uint32_t jrx)
5544c1
+void helper_wcsr_jrx(CPULM32State *env, uint32_t jrx)
5544c1
 {
5544c1
     lm32_juart_set_jrx(env->juart_state, jrx);
5544c1
 }
5544c1
 
5544c1
-uint32_t helper_rcsr_im(void)
5544c1
+uint32_t helper_rcsr_im(CPULM32State *env)
5544c1
 {
5544c1
     return lm32_pic_get_im(env->pic_state);
5544c1
 }
5544c1
 
5544c1
-uint32_t helper_rcsr_ip(void)
5544c1
+uint32_t helper_rcsr_ip(CPULM32State *env)
5544c1
 {
5544c1
     return lm32_pic_get_ip(env->pic_state);
5544c1
 }
5544c1
 
5544c1
-uint32_t helper_rcsr_jtx(void)
5544c1
+uint32_t helper_rcsr_jtx(CPULM32State *env)
5544c1
 {
5544c1
     return lm32_juart_get_jtx(env->juart_state);
5544c1
 }
5544c1
 
5544c1
-uint32_t helper_rcsr_jrx(void)
5544c1
+uint32_t helper_rcsr_jrx(CPULM32State *env)
5544c1
 {
5544c1
     return lm32_juart_get_jrx(env->juart_state);
5544c1
 }
5544c1
@@ -74,17 +73,12 @@ uint32_t helper_rcsr_jrx(void)
5544c1
 /* Try to fill the TLB and return an exception if error. If retaddr is
5544c1
    NULL, it means that the function was called in C code (i.e. not
5544c1
    from generated code or from helper.c) */
5544c1
-/* XXX: fix it to restore all registers */
5544c1
-void tlb_fill(CPULM32State *env1, target_ulong addr, int is_write, int mmu_idx,
5544c1
+void tlb_fill(CPULM32State *env, target_ulong addr, int is_write, int mmu_idx,
5544c1
               uintptr_t retaddr)
5544c1
 {
5544c1
     TranslationBlock *tb;
5544c1
-    CPULM32State *saved_env;
5544c1
     int ret;
5544c1
 
5544c1
-    saved_env = env;
5544c1
-    env = env1;
5544c1
-
5544c1
     ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx);
5544c1
     if (unlikely(ret)) {
5544c1
         if (retaddr) {
5544c1
@@ -98,7 +92,6 @@ void tlb_fill(CPULM32State *env1, target_ulong addr, int is_write, int mmu_idx,
5544c1
         }
5544c1
         cpu_loop_exit(env);
5544c1
     }
5544c1
-    env = saved_env;
5544c1
 }
5544c1
 #endif
5544c1
 
5544c1
diff --git a/target-lm32/translate.c b/target-lm32/translate.c
5544c1
index 872a2ba..5f6dcba 100644
5544c1
--- a/target-lm32/translate.c
5544c1
+++ b/target-lm32/translate.c
5544c1
@@ -116,7 +116,7 @@ static inline void t_gen_raise_exception(DisasContext *dc, uint32_t index)
5544c1
 {
5544c1
     TCGv_i32 tmp = tcg_const_i32(index);
5544c1
 
5544c1
-    gen_helper_raise_exception(tmp);
5544c1
+    gen_helper_raise_exception(cpu_env, tmp);
5544c1
     tcg_temp_free_i32(tmp);
5544c1
 }
5544c1
 
5544c1
@@ -179,7 +179,7 @@ static void dec_and(DisasContext *dc)
5544c1
     } else  {
5544c1
         if (dc->r0 == 0 && dc->r1 == 0 && dc->r2 == 0) {
5544c1
             tcg_gen_movi_tl(cpu_pc, dc->pc + 4);
5544c1
-            gen_helper_hlt();
5544c1
+            gen_helper_hlt(cpu_env);
5544c1
         } else {
5544c1
             tcg_gen_and_tl(cpu_R[dc->r2], cpu_R[dc->r0], cpu_R[dc->r1]);
5544c1
         }
5544c1
@@ -601,10 +601,10 @@ static void dec_rcsr(DisasContext *dc)
5544c1
         tcg_gen_mov_tl(cpu_R[dc->r2], cpu_ie);
5544c1
         break;
5544c1
     case CSR_IM:
5544c1
-        gen_helper_rcsr_im(cpu_R[dc->r2]);
5544c1
+        gen_helper_rcsr_im(cpu_R[dc->r2], cpu_env);
5544c1
         break;
5544c1
     case CSR_IP:
5544c1
-        gen_helper_rcsr_ip(cpu_R[dc->r2]);
5544c1
+        gen_helper_rcsr_ip(cpu_R[dc->r2], cpu_env);
5544c1
         break;
5544c1
     case CSR_CC:
5544c1
         tcg_gen_mov_tl(cpu_R[dc->r2], cpu_cc);
5544c1
@@ -622,10 +622,10 @@ static void dec_rcsr(DisasContext *dc)
5544c1
         tcg_gen_mov_tl(cpu_R[dc->r2], cpu_deba);
5544c1
         break;
5544c1
     case CSR_JTX:
5544c1
-        gen_helper_rcsr_jtx(cpu_R[dc->r2]);
5544c1
+        gen_helper_rcsr_jtx(cpu_R[dc->r2], cpu_env);
5544c1
         break;
5544c1
     case CSR_JRX:
5544c1
-        gen_helper_rcsr_jrx(cpu_R[dc->r2]);
5544c1
+        gen_helper_rcsr_jrx(cpu_R[dc->r2], cpu_env);
5544c1
         break;
5544c1
     case CSR_ICC:
5544c1
     case CSR_DCC:
5544c1
@@ -812,7 +812,7 @@ static void dec_wcsr(DisasContext *dc)
5544c1
         if (use_icount) {
5544c1
             gen_io_start();
5544c1
         }
5544c1
-        gen_helper_wcsr_im(cpu_R[dc->r1]);
5544c1
+        gen_helper_wcsr_im(cpu_env, cpu_R[dc->r1]);
5544c1
         tcg_gen_movi_tl(cpu_pc, dc->pc + 4);
5544c1
         if (use_icount) {
5544c1
             gen_io_end();
5544c1
@@ -824,7 +824,7 @@ static void dec_wcsr(DisasContext *dc)
5544c1
         if (use_icount) {
5544c1
             gen_io_start();
5544c1
         }
5544c1
-        gen_helper_wcsr_ip(cpu_R[dc->r1]);
5544c1
+        gen_helper_wcsr_ip(cpu_env, cpu_R[dc->r1]);
5544c1
         tcg_gen_movi_tl(cpu_pc, dc->pc + 4);
5544c1
         if (use_icount) {
5544c1
             gen_io_end();
5544c1
@@ -844,10 +844,10 @@ static void dec_wcsr(DisasContext *dc)
5544c1
         tcg_gen_mov_tl(cpu_deba, cpu_R[dc->r1]);
5544c1
         break;
5544c1
     case CSR_JTX:
5544c1
-        gen_helper_wcsr_jtx(cpu_R[dc->r1]);
5544c1
+        gen_helper_wcsr_jtx(cpu_env, cpu_R[dc->r1]);
5544c1
         break;
5544c1
     case CSR_JRX:
5544c1
-        gen_helper_wcsr_jrx(cpu_R[dc->r1]);
5544c1
+        gen_helper_wcsr_jrx(cpu_env, cpu_R[dc->r1]);
5544c1
         break;
5544c1
     case CSR_DC:
5544c1
         tcg_gen_mov_tl(cpu_dc, cpu_R[dc->r1]);
5544c1
@@ -940,15 +940,13 @@ static const DecoderInfo decinfo[] = {
5544c1
     dec_cmpne
5544c1
 };
5544c1
 
5544c1
-static inline void decode(DisasContext *dc)
5544c1
+static inline void decode(DisasContext *dc, uint32_t ir)
5544c1
 {
5544c1
-    uint32_t ir;
5544c1
-
5544c1
     if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP))) {
5544c1
         tcg_gen_debug_insn_start(dc->pc);
5544c1
     }
5544c1
 
5544c1
-    dc->ir = ir = ldl_code(dc->pc);
5544c1
+    dc->ir = ir;
5544c1
     LOG_DIS("%8.8x\t", dc->ir);
5544c1
 
5544c1
     /* try guessing 'empty' instruction memory, although it may be a valid
5544c1
@@ -1068,7 +1066,7 @@ static void gen_intermediate_code_internal(CPULM32State *env,
5544c1
             gen_io_start();
5544c1
         }
5544c1
 
5544c1
-        decode(dc);
5544c1
+        decode(dc, cpu_ldl_code(env, dc->pc));
5544c1
         dc->pc += 4;
5544c1
         num_insns++;
5544c1
 
5544c1
-- 
5544c1
1.7.12.1
5544c1