Since the TYPE_ARMV7M object doesn't know its CPU type at the
time armv7m_instance_init() is called, we need to prepare to
forward any CPU properties there, then we can forward them in
armv7m_realize().
But then when introspecting at runtime, in the case the requested
CPU doesn't expose such properties, we can still see them exposed
in the container.
It is possible to remove an unmeaningful property with
qdev_property_del_static(). As an example, remove the 'vfp'
property when not relevant.
When running the musca-a board, the monitor output changes as:
(qemu) info qtree
...
dev: armv7m, id ""
gpio-in "NMI" 1
gpio-out "SYSRESETREQ" 1
gpio-in "" 96
clock-in "cpuclk" freq_hz=40 MHz
clock-in "refclk" freq_hz=0 Hz
cpu-type = "cortex-m33-arm-cpu"
init-svtor = 270532608 (0x10200000)
init-nsvtor = 0 (0x0)
enable-bitband = false
start-powered-off = false
- vfp = "false"
dsp = false
mpu-ns-regions = 8 (0x8)
mpu-s-regions = 8 (0x8)
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/arm/armv7m.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 12cdad09f9..f1f40353cb 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -244,6 +244,9 @@ static const MemoryRegionOps ppb_default_ops = {
.valid.max_access_size = 8,
};
+static Property optional_arm_cpu_vfp_property =
+ DEFINE_PROP_BOOL_NODEFAULT("vfp", ARMv7MState, vfp);
+
static void armv7m_instance_init(Object *obj)
{
ARMv7MState *s = ARMV7M(obj);
@@ -271,6 +274,9 @@ static void armv7m_instance_init(Object *obj)
s->refclk = qdev_init_clock_in(DEVICE(obj), "refclk", NULL, NULL, 0);
s->cpuclk = qdev_init_clock_in(DEVICE(obj), "cpuclk", NULL, NULL, 0);
+
+ qdev_property_add_static(DEVICE(obj),
+ &optional_arm_cpu_vfp_property);
}
static void armv7m_realize(DeviceState *dev, Error **errp)
@@ -331,6 +337,8 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
} else if (s->vfp == OPTIONAL_BOOL_TRUE) {
error_setg(errp, "'%s' does not support VFP", s->cpu_type);
return;
+ } else {
+ qdev_property_del_static(dev, &optional_arm_cpu_vfp_property);
}
if (object_property_find(OBJECT(s->cpu), "dsp")) {
if (!object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, errp)) {
@@ -551,7 +559,6 @@ static Property armv7m_properties[] = {
DEFINE_PROP_BOOL("enable-bitband", ARMv7MState, enable_bitband, false),
DEFINE_PROP_BOOL("start-powered-off", ARMv7MState, start_powered_off,
false),
- DEFINE_PROP_BOOL_NODEFAULT("vfp", ARMv7MState, vfp),
DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true),
DEFINE_PROP_UINT32("mpu-ns-regions", ARMv7MState, mpu_ns_regions, UINT_MAX),
DEFINE_PROP_UINT32("mpu-s-regions", ARMv7MState, mpu_s_regions, UINT_MAX),
--
2.41.0