diff options
| author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-01-23 10:14:17 +0100 |
|---|---|---|
| committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-03-06 15:46:18 +0100 |
| commit | e3a575f5609569400da628d384b32f5e3cf58745 (patch) | |
| tree | e9bfaa800033709612bb2c3072e82bffab5ee549 /hw/core/cpu-system.c | |
| parent | 530c7139f64aa0e45b61ce9abecb7df8c55b3f12 (diff) | |
| download | focaccia-qemu-e3a575f5609569400da628d384b32f5e3cf58745.tar.gz focaccia-qemu-e3a575f5609569400da628d384b32f5e3cf58745.zip | |
cpus: Have cpu_class_init_props() per user / system emulation
Rather than maintaining a mix of system / user code for CPU class properties, move system properties to cpu-system.c and user ones to the new cpu-user.c unit. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20250123234415.59850-18-philmd@linaro.org>
Diffstat (limited to 'hw/core/cpu-system.c')
| -rw-r--r-- | hw/core/cpu-system.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/hw/core/cpu-system.c b/hw/core/cpu-system.c index 6e307c8959..1310b4203f 100644 --- a/hw/core/cpu-system.c +++ b/hw/core/cpu-system.c @@ -20,7 +20,10 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include "exec/memory.h" #include "exec/tswap.h" +#include "hw/qdev-core.h" +#include "hw/qdev-properties.h" #include "hw/core/sysemu-cpu-ops.h" bool cpu_paging_enabled(const CPUState *cpu) @@ -147,3 +150,40 @@ GuestPanicInformation *cpu_get_crash_info(CPUState *cpu) } return res; } + +static const Property cpu_system_props[] = { + /* + * Create a memory property for system CPU object, so users can + * wire up its memory. The default if no link is set up is to use + * the system address space. + */ + DEFINE_PROP_LINK("memory", CPUState, memory, TYPE_MEMORY_REGION, + MemoryRegion *), +}; + +static bool cpu_get_start_powered_off(Object *obj, Error **errp) +{ + CPUState *cpu = CPU(obj); + return cpu->start_powered_off; +} + +static void cpu_set_start_powered_off(Object *obj, bool value, Error **errp) +{ + CPUState *cpu = CPU(obj); + cpu->start_powered_off = value; +} + +void cpu_class_init_props(DeviceClass *dc) +{ + ObjectClass *oc = OBJECT_CLASS(dc); + + /* + * We can't use DEFINE_PROP_BOOL in the Property array for this + * property, because we want this to be settable after realize. + */ + object_class_property_add_bool(oc, "start-powered-off", + cpu_get_start_powered_off, + cpu_set_start_powered_off); + + device_class_set_props(dc, cpu_system_props); +} |