[PATCH 4/7] target/s390x: Move s390_cpu_has_work to excp_helper.c

Philippe Mathieu-Daudé posted 7 patches 4 years, 8 months ago
Maintainers: Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
[PATCH 4/7] target/s390x: Move s390_cpu_has_work to excp_helper.c
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
We will restrict the s390_cpu_has_work() function to TCG.
First declare it in "internal.h" and move it to excp_helper.c.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 target/s390x/internal.h    |  1 +
 target/s390x/cpu.c         | 17 -----------------
 target/s390x/excp_helper.c | 18 ++++++++++++++++++
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/target/s390x/internal.h b/target/s390x/internal.h
index 11515bb6173..7184e38631c 100644
--- a/target/s390x/internal.h
+++ b/target/s390x/internal.h
@@ -263,6 +263,7 @@ ObjectClass *s390_cpu_class_by_name(const char *name);
 
 
 /* excp_helper.c */
+bool s390_cpu_has_work(CPUState *cs);
 void s390x_cpu_debug_excp_handler(CPUState *cs);
 void s390_cpu_do_interrupt(CPUState *cpu);
 bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index d35eb39a1bb..91142db1097 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -56,23 +56,6 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value)
     cpu->env.psw.addr = value;
 }
 
-static bool s390_cpu_has_work(CPUState *cs)
-{
-    S390CPU *cpu = S390_CPU(cs);
-
-    /* STOPPED cpus can never wake up */
-    if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
-        s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
-        return false;
-    }
-
-    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
-        return false;
-    }
-
-    return s390_cpu_has_int(cpu);
-}
-
 #if !defined(CONFIG_USER_ONLY)
 /* S390CPUClass::load_normal() */
 static void s390_cpu_load_normal(CPUState *s)
diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c
index ce16af394b1..64923ffb83a 100644
--- a/target/s390x/excp_helper.c
+++ b/target/s390x/excp_helper.c
@@ -28,12 +28,30 @@
 #include "hw/s390x/ioinst.h"
 #include "exec/address-spaces.h"
 #include "tcg_s390x.h"
+#include "qapi/qapi-types-machine.h"
 #ifndef CONFIG_USER_ONLY
 #include "sysemu/sysemu.h"
 #include "hw/s390x/s390_flic.h"
 #include "hw/boards.h"
 #endif
 
+bool s390_cpu_has_work(CPUState *cs)
+{
+    S390CPU *cpu = S390_CPU(cs);
+
+    /* STOPPED cpus can never wake up */
+    if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
+        s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
+        return false;
+    }
+
+    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
+        return false;
+    }
+
+    return s390_cpu_has_int(cpu);
+}
+
 void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env,
                                               uint32_t code, uintptr_t ra)
 {
-- 
2.26.2

Re: [PATCH 4/7] target/s390x: Move s390_cpu_has_work to excp_helper.c
Posted by Thomas Huth 4 years, 8 months ago
On 02/03/2021 11.27, Philippe Mathieu-Daudé wrote:
> We will restrict the s390_cpu_has_work() function to TCG.
> First declare it in "internal.h" and move it to excp_helper.c.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>   target/s390x/internal.h    |  1 +
>   target/s390x/cpu.c         | 17 -----------------
>   target/s390x/excp_helper.c | 18 ++++++++++++++++++
>   3 files changed, 19 insertions(+), 17 deletions(-)
> 
> diff --git a/target/s390x/internal.h b/target/s390x/internal.h
> index 11515bb6173..7184e38631c 100644
> --- a/target/s390x/internal.h
> +++ b/target/s390x/internal.h
> @@ -263,6 +263,7 @@ ObjectClass *s390_cpu_class_by_name(const char *name);
>   
>   
>   /* excp_helper.c */
> +bool s390_cpu_has_work(CPUState *cs);
>   void s390x_cpu_debug_excp_handler(CPUState *cs);
>   void s390_cpu_do_interrupt(CPUState *cpu);
>   bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index d35eb39a1bb..91142db1097 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -56,23 +56,6 @@ static void s390_cpu_set_pc(CPUState *cs, vaddr value)
>       cpu->env.psw.addr = value;
>   }
>   
> -static bool s390_cpu_has_work(CPUState *cs)
> -{
> -    S390CPU *cpu = S390_CPU(cs);
> -
> -    /* STOPPED cpus can never wake up */
> -    if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
> -        s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
> -        return false;
> -    }
> -
> -    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
> -        return false;
> -    }
> -
> -    return s390_cpu_has_int(cpu);
> -}
> -
>   #if !defined(CONFIG_USER_ONLY)
>   /* S390CPUClass::load_normal() */
>   static void s390_cpu_load_normal(CPUState *s)
> diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c
> index ce16af394b1..64923ffb83a 100644
> --- a/target/s390x/excp_helper.c
> +++ b/target/s390x/excp_helper.c
> @@ -28,12 +28,30 @@
>   #include "hw/s390x/ioinst.h"
>   #include "exec/address-spaces.h"
>   #include "tcg_s390x.h"
> +#include "qapi/qapi-types-machine.h"
>   #ifndef CONFIG_USER_ONLY
>   #include "sysemu/sysemu.h"
>   #include "hw/s390x/s390_flic.h"
>   #include "hw/boards.h"
>   #endif
>   
> +bool s390_cpu_has_work(CPUState *cs)
> +{
> +    S390CPU *cpu = S390_CPU(cs);
> +
> +    /* STOPPED cpus can never wake up */
> +    if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
> +        s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
> +        return false;
> +    }
> +
> +    if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
> +        return false;
> +    }
> +
> +    return s390_cpu_has_int(cpu);
> +}
> +
>   void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env,
>                                                 uint32_t code, uintptr_t ra)
>   {
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>