Skip to content

Commit f54c047

Browse files
committed
target/s390x: Move has_work() from CPUClass to SysemuCPUOps
Move has_work() from CPUClass to SysemuCPUOps, move s390_cpu_has_work() to cpu-system.c so it is only build for system emulation binaries, restrict functions not used anymore on user emulation in interrupt.c. Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]>
1 parent 0df9781 commit f54c047

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed

target/s390x/cpu-system.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@
3939
#include "system/tcg.h"
4040
#include "hw/core/sysemu-cpu-ops.h"
4141

42+
bool s390_cpu_has_work(CPUState *cs)
43+
{
44+
S390CPU *cpu = S390_CPU(cs);
45+
46+
/* STOPPED cpus can never wake up */
47+
if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
48+
s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
49+
return false;
50+
}
51+
52+
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
53+
return false;
54+
}
55+
56+
return s390_cpu_has_int(cpu);
57+
}
58+
4259
/* S390CPUClass::load_normal() */
4360
static void s390_cpu_load_normal(CPUState *s)
4461
{
@@ -158,6 +175,7 @@ void s390_cpu_finalize(Object *obj)
158175
}
159176

160177
static const struct SysemuCPUOps s390_sysemu_ops = {
178+
.has_work = s390_cpu_has_work,
161179
.get_phys_page_debug = s390_cpu_get_phys_page_debug,
162180
.get_crash_info = s390_cpu_get_crash_info,
163181
.write_elf64_note = s390_cpu_write_elf64_note,

target/s390x/cpu.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,6 @@ static vaddr s390_cpu_get_pc(CPUState *cs)
126126
return cpu->env.psw.addr;
127127
}
128128

129-
static bool s390_cpu_has_work(CPUState *cs)
130-
{
131-
S390CPU *cpu = S390_CPU(cs);
132-
133-
/* STOPPED cpus can never wake up */
134-
if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
135-
s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
136-
return false;
137-
}
138-
139-
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
140-
return false;
141-
}
142-
143-
return s390_cpu_has_int(cpu);
144-
}
145-
146129
static int s390x_cpu_mmu_index(CPUState *cs, bool ifetch)
147130
{
148131
return s390x_env_mmu_index(cpu_env(cs), ifetch);
@@ -395,7 +378,6 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
395378
&scc->parent_phases);
396379

397380
cc->class_by_name = s390_cpu_class_by_name,
398-
cc->has_work = s390_cpu_has_work;
399381
cc->mmu_index = s390x_cpu_mmu_index;
400382
cc->dump_state = s390_cpu_dump_state;
401383
cc->query_cpu_fast = s390_query_cpu_fast;

target/s390x/interrupt.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ void trigger_pgm_exception(CPUS390XState *env, uint32_t code)
3030
/* env->int_pgm_ilen is already set, or will be set during unwinding */
3131
}
3232

33+
#if !defined(CONFIG_USER_ONLY)
3334
void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra)
3435
{
3536
if (kvm_enabled()) {
@@ -41,7 +42,6 @@ void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra)
4142
}
4243
}
4344

44-
#if !defined(CONFIG_USER_ONLY)
4545
void cpu_inject_clock_comparator(S390CPU *cpu)
4646
{
4747
CPUS390XState *env = &cpu->env;
@@ -225,11 +225,9 @@ bool s390_cpu_has_stop_int(S390CPU *cpu)
225225

226226
return env->pending_int & INTERRUPT_STOP;
227227
}
228-
#endif
229228

230229
bool s390_cpu_has_int(S390CPU *cpu)
231230
{
232-
#ifndef CONFIG_USER_ONLY
233231
if (!tcg_enabled()) {
234232
return false;
235233
}
@@ -238,7 +236,5 @@ bool s390_cpu_has_int(S390CPU *cpu)
238236
s390_cpu_has_io_int(cpu) ||
239237
s390_cpu_has_restart_int(cpu) ||
240238
s390_cpu_has_stop_int(cpu);
241-
#else
242-
return false;
243-
#endif
244239
}
240+
#endif /* !CONFIG_USER_ONLY */

target/s390x/s390x-internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ bool s390_cpu_system_realize(DeviceState *dev, Error **errp);
245245
void s390_cpu_finalize(Object *obj);
246246
void s390_cpu_system_class_init(CPUClass *cc);
247247
void s390_cpu_machine_reset_cb(void *opaque);
248+
bool s390_cpu_has_work(CPUState *cs);
248249

249250
#else
250251
static inline unsigned int s390_cpu_halt(S390CPU *cpu)
@@ -341,6 +342,7 @@ void cpu_unmap_lowcore(LowCore *lowcore);
341342

342343
/* interrupt.c */
343344
void trigger_pgm_exception(CPUS390XState *env, uint32_t code);
345+
#ifndef CONFIG_USER_ONLY
344346
void cpu_inject_clock_comparator(S390CPU *cpu);
345347
void cpu_inject_cpu_timer(S390CPU *cpu);
346348
void cpu_inject_emergency_signal(S390CPU *cpu, uint16_t src_cpu_addr);
@@ -353,6 +355,7 @@ bool s390_cpu_has_restart_int(S390CPU *cpu);
353355
bool s390_cpu_has_stop_int(S390CPU *cpu);
354356
void cpu_inject_restart(S390CPU *cpu);
355357
void cpu_inject_stop(S390CPU *cpu);
358+
#endif /* CONFIG_USER_ONLY */
356359

357360

358361
/* ioinst.c */

0 commit comments

Comments
 (0)