Skip to content

Commit d0a4cca

Browse files
committed
cpus: Remove CPUClass::has_work() handler
All handlers have been converted to SysemuCPUOps::has_work(). Remove CPUClass::has_work along with cpu_common_has_work() and simplify cpu_has_work(), making SysemuCPUOps::has_work handler mandatory. Note, since cpu-common.c is in meson's common_ss[] source set, we must define cpu_exec_class_post_init() in cpu-target.c (which is in the specific_ss[] source set) to have CONFIG_USER_ONLY defined. Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]>
1 parent f37799c commit d0a4cca

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

hw/core/cpu-common.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ static void cpu_common_reset_hold(Object *obj, ResetType type)
134134
cpu_exec_reset_hold(cpu);
135135
}
136136

137-
static bool cpu_common_has_work(CPUState *cs)
138-
{
139-
return false;
140-
}
141-
142137
ObjectClass *cpu_class_by_name(const char *typename, const char *cpu_model)
143138
{
144139
ObjectClass *oc;
@@ -259,6 +254,8 @@ static void cpu_common_initfn(Object *obj)
259254
{
260255
CPUState *cpu = CPU(obj);
261256

257+
cpu_exec_class_post_init(CPU_GET_CLASS(obj));
258+
262259
/* cache the cpu class for the hotpath */
263260
cpu->cc = CPU_GET_CLASS(cpu);
264261

@@ -331,7 +328,6 @@ static void cpu_common_class_init(ObjectClass *klass, void *data)
331328

332329
k->parse_features = cpu_common_parse_features;
333330
k->get_arch_id = cpu_common_get_arch_id;
334-
k->has_work = cpu_common_has_work;
335331
k->gdb_read_register = cpu_common_gdb_read_register;
336332
k->gdb_write_register = cpu_common_gdb_write_register;
337333
set_bit(DEVICE_CATEGORY_CPU, dc->categories);

hw/core/cpu-system.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@
3333

3434
bool cpu_has_work(CPUState *cpu)
3535
{
36-
if (cpu->cc->sysemu_ops->has_work) {
37-
return cpu->cc->sysemu_ops->has_work(cpu);
38-
}
39-
40-
g_assert(cpu->cc->has_work);
41-
return cpu->cc->has_work(cpu);
36+
return cpu->cc->sysemu_ops->has_work(cpu);
4237
}
4338

4439
bool cpu_paging_enabled(const CPUState *cpu)
@@ -188,6 +183,12 @@ void cpu_class_init_props(DeviceClass *dc)
188183
device_class_set_props(dc, cpu_system_props);
189184
}
190185

186+
void cpu_exec_class_post_init(CPUClass *cc)
187+
{
188+
/* Check mandatory SysemuCPUOps handlers */
189+
g_assert(cc->sysemu_ops->has_work);
190+
}
191+
191192
void cpu_exec_initfn(CPUState *cpu)
192193
{
193194
cpu->memory = get_system_memory();

hw/core/cpu-user.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ void cpu_class_init_props(DeviceClass *dc)
2727
device_class_set_props(dc, cpu_user_props);
2828
}
2929

30+
void cpu_exec_class_post_init(CPUClass *cc)
31+
{
32+
/* nothing to do */
33+
}
34+
3035
void cpu_exec_initfn(CPUState *cpu)
3136
{
3237
/* nothing to do */

include/hw/core/cpu.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ struct SysemuCPUOps;
104104
* instantiatable CPU type.
105105
* @parse_features: Callback to parse command line arguments.
106106
* @reset_dump_flags: #CPUDumpFlags to use for reset logging.
107-
* @has_work: Callback for checking if there is work to do.
108107
* @mmu_index: Callback for choosing softmmu mmu index;
109108
* may be used internally by memory_rw_debug without TCG.
110109
* @memory_rw_debug: Callback for GDB memory access.
@@ -153,7 +152,6 @@ struct CPUClass {
153152
ObjectClass *(*class_by_name)(const char *cpu_model);
154153
void (*parse_features)(const char *typename, char *str, Error **errp);
155154

156-
bool (*has_work)(CPUState *cpu);
157155
int (*mmu_index)(CPUState *cpu, bool ifetch);
158156
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
159157
uint8_t *buf, int len, bool is_write);
@@ -1156,6 +1154,7 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
11561154

11571155
/* $(top_srcdir)/cpu.c */
11581156
void cpu_class_init_props(DeviceClass *dc);
1157+
void cpu_exec_class_post_init(CPUClass *cc);
11591158
void cpu_exec_initfn(CPUState *cpu);
11601159
void cpu_vmstate_register(CPUState *cpu);
11611160
void cpu_vmstate_unregister(CPUState *cpu);

include/hw/core/sysemu-cpu-ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct SysemuCPUOps {
1919
/**
2020
* @has_work: Callback for checking if there is work to do.
2121
*/
22-
bool (*has_work)(CPUState *cpu);
22+
bool (*has_work)(CPUState *cpu); /* MANDATORY NON-NULL */
2323
/**
2424
* @get_memory_mapping: Callback for obtaining the memory mappings.
2525
*/

0 commit comments

Comments
 (0)