diff mbox series

[v2,2/3] target/hppa: Move diag argument handling to decodetree

Message ID 20240326181028.332867-3-richard.henderson@linaro.org
State Superseded
Headers show
Series target/hppa: Tidy and extend diag instructions | expand

Commit Message

Richard Henderson March 26, 2024, 6:10 p.m. UTC
Split trans_diag into per-operation functions.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/hppa/insns.decode |  8 +++++++-
 target/hppa/translate.c  | 34 +++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 14 deletions(-)

Comments

Helge Deller March 26, 2024, 8:27 p.m. UTC | #1
On 3/26/24 19:10, Richard Henderson wrote:
> Split trans_diag into per-operation functions.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Helge Deller <deller@gmx.de>

Helge

> ---
>   target/hppa/insns.decode |  8 +++++++-
>   target/hppa/translate.c  | 34 +++++++++++++++++++++-------------
>   2 files changed, 28 insertions(+), 14 deletions(-)
>
> diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode
> index 6a74cf23cd..9f6ffd8e2c 100644
> --- a/target/hppa/insns.decode
> +++ b/target/hppa/insns.decode
> @@ -634,4 +634,10 @@ fdiv_d          001110 ..... ..... 011 ..... ... .....  @f0e_d_3
>   xmpyu           001110 ..... ..... 010 .0111 .00 t:5    r1=%ra64 r2=%rb64
>
>   # diag
> -diag            000101 i:26
> +{
> +  [
> +    diag_btlb               000101 00 0000 0000 0000 0001 0000 0000
> +    diag_cout               000101 00 0000 0000 0000 0001 0000 0001
> +  ]
> +  diag_unimp                000101 i:26
> +}
> diff --git a/target/hppa/translate.c b/target/hppa/translate.c
> index 29e4a64e40..42dd3f2c8d 100644
> --- a/target/hppa/translate.c
> +++ b/target/hppa/translate.c
> @@ -4572,23 +4572,31 @@ static bool trans_fmpyfadd_d(DisasContext *ctx, arg_fmpyfadd_d *a)
>       return nullify_end(ctx);
>   }
>
> -static bool trans_diag(DisasContext *ctx, arg_diag *a)
> +/* Emulate PDC BTLB, called by SeaBIOS-hppa */
> +static bool trans_diag_btlb(DisasContext *ctx, arg_diag_btlb *a)
>   {
>       CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
>   #ifndef CONFIG_USER_ONLY
> -    if (a->i == 0x100) {
> -        /* emulate PDC BTLB, called by SeaBIOS-hppa */
> -        nullify_over(ctx);
> -        gen_helper_diag_btlb(tcg_env);
> -        return nullify_end(ctx);
> -    }
> -    if (a->i == 0x101) {
> -        /* print char in %r26 to first serial console, used by SeaBIOS-hppa */
> -        nullify_over(ctx);
> -        gen_helper_diag_console_output(tcg_env);
> -        return nullify_end(ctx);
> -    }
> +    nullify_over(ctx);
> +    gen_helper_diag_btlb(tcg_env);
> +    return nullify_end(ctx);
>   #endif
> +}
> +
> +/* Print char in %r26 to first serial console, used by SeaBIOS-hppa */
> +static bool trans_diag_cout(DisasContext *ctx, arg_diag_cout *a)
> +{
> +    CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
> +#ifndef CONFIG_USER_ONLY
> +    nullify_over(ctx);
> +    gen_helper_diag_console_output(tcg_env);
> +    return nullify_end(ctx);
> +#endif
> +}
> +
> +static bool trans_diag_unimp(DisasContext *ctx, arg_diag_unimp *a)
> +{
> +    CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
>       qemu_log_mask(LOG_UNIMP, "DIAG opcode 0x%04x ignored\n", a->i);
>       return true;
>   }
diff mbox series

Patch

diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode
index 6a74cf23cd..9f6ffd8e2c 100644
--- a/target/hppa/insns.decode
+++ b/target/hppa/insns.decode
@@ -634,4 +634,10 @@  fdiv_d          001110 ..... ..... 011 ..... ... .....  @f0e_d_3
 xmpyu           001110 ..... ..... 010 .0111 .00 t:5    r1=%ra64 r2=%rb64
 
 # diag
-diag            000101 i:26
+{
+  [
+    diag_btlb               000101 00 0000 0000 0000 0001 0000 0000
+    diag_cout               000101 00 0000 0000 0000 0001 0000 0001
+  ]
+  diag_unimp                000101 i:26
+}
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 29e4a64e40..42dd3f2c8d 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -4572,23 +4572,31 @@  static bool trans_fmpyfadd_d(DisasContext *ctx, arg_fmpyfadd_d *a)
     return nullify_end(ctx);
 }
 
-static bool trans_diag(DisasContext *ctx, arg_diag *a)
+/* Emulate PDC BTLB, called by SeaBIOS-hppa */
+static bool trans_diag_btlb(DisasContext *ctx, arg_diag_btlb *a)
 {
     CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
 #ifndef CONFIG_USER_ONLY
-    if (a->i == 0x100) {
-        /* emulate PDC BTLB, called by SeaBIOS-hppa */
-        nullify_over(ctx);
-        gen_helper_diag_btlb(tcg_env);
-        return nullify_end(ctx);
-    }
-    if (a->i == 0x101) {
-        /* print char in %r26 to first serial console, used by SeaBIOS-hppa */
-        nullify_over(ctx);
-        gen_helper_diag_console_output(tcg_env);
-        return nullify_end(ctx);
-    }
+    nullify_over(ctx);
+    gen_helper_diag_btlb(tcg_env);
+    return nullify_end(ctx);
 #endif
+}
+
+/* Print char in %r26 to first serial console, used by SeaBIOS-hppa */
+static bool trans_diag_cout(DisasContext *ctx, arg_diag_cout *a)
+{
+    CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
+#ifndef CONFIG_USER_ONLY
+    nullify_over(ctx);
+    gen_helper_diag_console_output(tcg_env);
+    return nullify_end(ctx);
+#endif
+}
+
+static bool trans_diag_unimp(DisasContext *ctx, arg_diag_unimp *a)
+{
+    CHECK_MOST_PRIVILEGED(EXCP_PRIV_OPR);
     qemu_log_mask(LOG_UNIMP, "DIAG opcode 0x%04x ignored\n", a->i);
     return true;
 }