@samitouri / QOSamiQemu / commits / a2d626371d

hw/cpu: Move internal declarations to new 'cpu-internal.h' header

Some declarations are only used within hw/core/, in particular by the 3 cpu-{common,user,system}.c. Restrict the declarations scope by moving them to a new "cpu-internal.h" local header. Rename cpu_exec_initfn() -> cpu_exec_init() because we usually have the 'fn' suffix for handler, not API entry point methods. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20260811183410.22428-4-philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Aug 11, 2026 at 08:00 UTC a2d626371dfc08e63009bbc73a9f3e5ae37b63ce
6 files changed +29 -9
MAINTAINERS
+1
@@ -2093,6 +2093,7 @@ Machine core
2093 M: Philippe Mathieu-Daudé <philmd@mailo.com>
2094 R: Zhao Liu <zhao1.liu@intel.com>
2095 S: Maintained
2096 +F: hw/core/cpu-internal.h
2097 F: hw/core/cpu-common.c
2098 F: hw/core/cpu-system.c
2099 F: hw/core/machine-qmp-cmds.c
hw/core/cpu-common.c
+2 -1
@@ -39,6 +39,7 @@
39 #ifdef CONFIG_PLUGIN
40 #include "qemu/plugin.h"
41 #endif
42 +#include "cpu-internal.h"
43
44 CPUState *cpu_by_arch_id(int64_t id)
45 {
@@ -326,7 +327,7 @@ static void cpu_common_initfn(Object *obj)
327 QTAILQ_INIT(&cpu->breakpoints);
328 QTAILQ_INIT(&cpu->watchpoints);
329
329 - cpu_exec_initfn(cpu);
330 + cpu_exec_init(cpu);
331
332 /*
333 * Plugin initialization must wait until the cpu start executing
hw/core/cpu-internal.h new
+22
@@ -0,0 +1,22 @@
1 +/*
2 + * QEMU private CPU interface between user / system modes)
3 + *
4 + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5 + *
6 + * SPDX-License-Identifier: GPL-2.0-or-later
7 + */
8 +#ifndef HW_CORE_CPU_INTERNAL_H
9 +#define HW_CORE_CPU_INTERNAL_H
10 +
11 +#include "hw/core/qdev.h"
12 +#include "hw/core/cpu.h"
13 +
14 +void cpu_class_init_props(DeviceClass *dc);
15 +void cpu_exec_class_post_init(CPUClass *cc);
16 +
17 +void cpu_exec_init(CPUState *cpu);
18 +
19 +void cpu_vmstate_register(CPUState *cpu);
20 +void cpu_vmstate_unregister(CPUState *cpu);
21 +
22 +#endif
hw/core/cpu-system.c
+2 -1
@@ -30,6 +30,7 @@
30 #include "hw/core/sysemu-cpu-ops.h"
31 #include "migration/vmstate.h"
32 #include "system/tcg.h"
33 +#include "cpu-internal.h"
34
35 bool cpu_has_work(CPUState *cpu)
36 {
@@ -188,7 +189,7 @@ void cpu_exec_class_post_init(CPUClass *cc)
189 g_assert(cc->sysemu_ops->has_work);
190 }
191
191 -void cpu_exec_initfn(CPUState *cpu)
192 +void cpu_exec_init(CPUState *cpu)
193 {
194 cpu->memory = get_system_memory();
195 object_ref(OBJECT(cpu->memory));
hw/core/cpu-user.c
+2 -1
@@ -11,6 +11,7 @@
11 #include "hw/core/qdev-properties.h"
12 #include "hw/core/cpu.h"
13 #include "migration/vmstate.h"
14 +#include "cpu-internal.h"
15
16 static const Property cpu_user_props[] = {
17 /*
@@ -32,7 +33,7 @@ void cpu_exec_class_post_init(CPUClass *cc)
33 /* nothing to do */
34 }
35
35 -void cpu_exec_initfn(CPUState *cpu)
36 +void cpu_exec_init(CPUState *cpu)
37 {
38 /* nothing to do */
39 }
include/hw/core/cpu.h
-6
@@ -1178,12 +1178,6 @@ G_NORETURN void cpu_abort(CPUState *cpu, const char *fmt, ...)
1178 */
1179 void qemu_process_cpu_events(CPUState *cpu);
1180
1181 -/* $(top_srcdir)/cpu.c */
1182 -void cpu_class_init_props(DeviceClass *dc);
1183 -void cpu_exec_class_post_init(CPUClass *cc);
1184 -void cpu_exec_initfn(CPUState *cpu);
1185 -void cpu_vmstate_register(CPUState *cpu);
1186 -void cpu_vmstate_unregister(CPUState *cpu);
1181 bool cpu_exec_realizefn(CPUState *cpu, Error **errp);
1182 void cpu_exec_unrealizefn(CPUState *cpu);
1183 void cpu_exec_reset_hold(CPUState *cpu);