Skip to content

Commit 995b87d

Browse files
committed
Revert "cpu: Move cpu_common_props to hw/core/cpu.c"
This reverts commit 1b36e4f. Despite a comment saying why cpu_common_props cannot be placed in a file that is compiled once, it was moved anyway. Revert that. Since then, Property is not defined in hw/core/cpu.h, so it is now easier to declare a function to install the properties rather than the Property array itself. Cc: Eduardo Habkost <[email protected]> Suggested-by: Peter Maydell <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent 02bf7fa commit 995b87d

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

cpu.c

+21
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,27 @@ void cpu_exec_unrealizefn(CPUState *cpu)
179179
cpu_list_remove(cpu);
180180
}
181181

182+
static Property cpu_common_props[] = {
183+
#ifndef CONFIG_USER_ONLY
184+
/*
185+
* Create a memory property for softmmu CPU object,
186+
* so users can wire up its memory. (This can't go in hw/core/cpu.c
187+
* because that file is compiled only once for both user-mode
188+
* and system builds.) The default if no link is set up is to use
189+
* the system address space.
190+
*/
191+
DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
192+
MemoryRegion *),
193+
#endif
194+
DEFINE_PROP_BOOL("start-powered-off", CPUState, start_powered_off, false),
195+
DEFINE_PROP_END_OF_LIST(),
196+
};
197+
198+
void cpu_class_init_props(DeviceClass *dc)
199+
{
200+
device_class_set_props(dc, cpu_common_props);
201+
}
202+
182203
void cpu_exec_initfn(CPUState *cpu)
183204
{
184205
cpu->as = NULL;

hw/core/cpu-common.c

+1-16
Original file line numberDiff line numberDiff line change
@@ -257,21 +257,6 @@ static int64_t cpu_common_get_arch_id(CPUState *cpu)
257257
return cpu->cpu_index;
258258
}
259259

260-
static Property cpu_common_props[] = {
261-
#ifndef CONFIG_USER_ONLY
262-
/* Create a memory property for softmmu CPU object,
263-
* so users can wire up its memory. (This can't go in hw/core/cpu.c
264-
* because that file is compiled only once for both user-mode
265-
* and system builds.) The default if no link is set up is to use
266-
* the system address space.
267-
*/
268-
DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION,
269-
MemoryRegion *),
270-
#endif
271-
DEFINE_PROP_BOOL("start-powered-off", CPUState, start_powered_off, false),
272-
DEFINE_PROP_END_OF_LIST(),
273-
};
274-
275260
static void cpu_class_init(ObjectClass *klass, void *data)
276261
{
277262
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -286,7 +271,7 @@ static void cpu_class_init(ObjectClass *klass, void *data)
286271
dc->realize = cpu_common_realizefn;
287272
dc->unrealize = cpu_common_unrealizefn;
288273
dc->reset = cpu_common_reset;
289-
device_class_set_props(dc, cpu_common_props);
274+
cpu_class_init_props(dc);
290275
/*
291276
* Reason: CPUs still need special care by board code: wiring up
292277
* IRQs, adding reset handlers, halting non-first CPUs, ...

include/hw/core/cpu.h

+1
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
10081008
GCC_FMT_ATTR(2, 3);
10091009

10101010
/* $(top_srcdir)/cpu.c */
1011+
void cpu_class_init_props(DeviceClass *dc);
10111012
void cpu_exec_initfn(CPUState *cpu);
10121013
void cpu_exec_realizefn(CPUState *cpu, Error **errp);
10131014
void cpu_exec_unrealizefn(CPUState *cpu);

0 commit comments

Comments
 (0)