Patchwork [3/9] sparc64: use helper_wrpil to check pending irq on write

login
register
mail settings
Submitter Igor V. Kovalenko
Date Jan. 5, 2010, 11:19 p.m.
Message ID <20100105231918.6526.19467.stgit@skyserv>
Download mbox | patch
Permalink /patch/42233/
State New
Headers show

Comments

Igor V. Kovalenko - Jan. 5, 2010, 11:19 p.m.
From: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
---
 target-sparc/helper.h    |    1 +
 target-sparc/op_helper.c |   14 ++++++++++++++
 target-sparc/translate.c |    5 +----
 3 files changed, 16 insertions(+), 4 deletions(-)
Blue Swirl - Jan. 6, 2010, 3:41 p.m.
On Tue, Jan 5, 2010 at 11:19 PM, Igor V. Kovalenko
<igor.v.kovalenko@gmail.com> wrote:
> From: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
>
> Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
> ---
>  target-sparc/helper.h    |    1 +
>  target-sparc/op_helper.c |   14 ++++++++++++++
>  target-sparc/translate.c |    5 +----
>  3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/target-sparc/helper.h b/target-sparc/helper.h
> index 4002b9e..6f103e7 100644
> --- a/target-sparc/helper.h
> +++ b/target-sparc/helper.h
> @@ -5,6 +5,7 @@ DEF_HELPER_0(rett, void)
>  DEF_HELPER_1(wrpsr, void, tl)
>  DEF_HELPER_0(rdpsr, tl)
>  #else
> +DEF_HELPER_1(wrpil, void, tl)
>  DEF_HELPER_1(wrpstate, void, tl)
>  DEF_HELPER_0(done, void)
>  DEF_HELPER_0(retry, void)
> diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
> index 26092e5..a7da0e4 100644
> --- a/target-sparc/op_helper.c
> +++ b/target-sparc/op_helper.c
> @@ -3303,6 +3303,20 @@ void helper_wrpstate(target_ulong new_state)
>     change_pstate(new_state & 0xf3f);
>  }
>
> +void helper_wrpil(target_ulong new_pil)
> +{
> +    DPRINTF_PSTATE("helper_wrpil old=%X new=%X\n",
> +                   env->psrpil, (uint32_t)new_pil);
> +
> +    env->psrpil = new_pil;
> +
> +#if !defined(CONFIG_USER_ONLY)
> +    if (env->pstate & PS_IE) {
> +        cpu_check_irqs(env);
> +    }
> +#endif
> +}

It's not possible to write to PIL in user mode, so the whole code
inside the function should be surrounded by #if
!defined(CONFIG_USER_ONLY)/#endif. Please use lowercase hex.

I'm wondering about using target_ulong instead of uint32_t (type of
env->psrpil). TL makes the generated code shorter, uint32_t would
decrease TCG register pressure on 32 bit hosts. This is not
performance critical, so either way should be OK.

Patch

diff --git a/target-sparc/helper.h b/target-sparc/helper.h
index 4002b9e..6f103e7 100644
--- a/target-sparc/helper.h
+++ b/target-sparc/helper.h
@@ -5,6 +5,7 @@  DEF_HELPER_0(rett, void)
 DEF_HELPER_1(wrpsr, void, tl)
 DEF_HELPER_0(rdpsr, tl)
 #else
+DEF_HELPER_1(wrpil, void, tl)
 DEF_HELPER_1(wrpstate, void, tl)
 DEF_HELPER_0(done, void)
 DEF_HELPER_0(retry, void)
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c
index 26092e5..a7da0e4 100644
--- a/target-sparc/op_helper.c
+++ b/target-sparc/op_helper.c
@@ -3303,6 +3303,20 @@  void helper_wrpstate(target_ulong new_state)
     change_pstate(new_state & 0xf3f);
 }
 
+void helper_wrpil(target_ulong new_pil)
+{
+    DPRINTF_PSTATE("helper_wrpil old=%X new=%X\n",
+                   env->psrpil, (uint32_t)new_pil);
+
+    env->psrpil = new_pil;
+
+#if !defined(CONFIG_USER_ONLY)
+    if (env->pstate & PS_IE) {
+        cpu_check_irqs(env);
+    }
+#endif
+}
+
 void helper_done(void)
 {
     trap_state* tsptr = cpu_tsptr(env);
diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index bf6df50..7e9f0cf 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -3371,10 +3371,7 @@  static void disas_sparc_insn(DisasContext * dc)
                                                offsetof(CPUSPARCState, tl));
                                 break;
                             case 8: // pil
-                                tcg_gen_trunc_tl_i32(cpu_tmp32, cpu_tmp0);
-                                tcg_gen_st_i32(cpu_tmp32, cpu_env,
-                                               offsetof(CPUSPARCState,
-                                                        psrpil));
+                                gen_helper_wrpil(cpu_tmp0);
                                 break;
                             case 9: // cwp
                                 gen_helper_wrcwp(cpu_tmp0);