On 2/10/26 11:02, Jamin Lin wrote:
Hi Cédric
Subject: Re: [PATCH v1 01/11] hw/arm/aspeed_ast2400: Use unimp array and
table for unimplemented devices
On 10/1/26 13:51, Jamin Lin wrote:
Cédric Le Goater <[email protected]> 於 2026年10月1日 下午3:41 寫道:
On 9/30/26 14:16, Philippe Mathieu-Daudé wrote:
On 30/9/26 13:50, Cédric Le Goater wrote:
Note to Peter: I really think keeping duplicating the
UnimplementedDeviceConfig structure is a basic software
development antipattern. Could you reconsider your objection?
What's the background ?
I think that was discussed on IRC, the only ref on the list is:
https://lore.kernel.org/qemu-devel/CAFEAcA_ob6mHqfAAM9iAMae5vfxaYhmc
[email protected]/
create_unimplemented_device() calls qdev_create() and allocate on
the heap, my motivation was to have another helper for in-place init
(when the UnimplementedDeviceState state is embedded in the parent).
Now we ended with such helpers like
aspeed_mmio_map_unimplemented()
which realize in place, make_unimp_dev() and create_unimp() init and
realize in place and Jamin adds yet another pattern. While all are
valids, I'd rather unify.
Could an array such as :
static const AspeedUnimpDevice aspeed_soc_ast2700_unimp_devs[] = {
{ "dpmcu", "aspeed.dpmcu", ASPEED_DEV_DPMCU, 0x0004000
0 },
{ "iomem", "aspeed.io", ASPEED_DEV_IOMEM, 0x00FE0000
},
{ "iomem0", "aspeed.iomem0", ASPEED_DEV_IOMEM0, 0x01000000 },
{ "iomem1", "aspeed.iomem1", ASPEED_DEV_IOMEM1,
0x01000000 }, };
be defined at the class level of the SoC and handled automatically ?
I guess would need some kind on common SoC model in that case.
C.
Hi Cédric,
I will resend v2 and rework the design along these lines.
Please wait a bit for Phil's feedback.
Defining the unimplemented devices as a class-level array and I will
look into introducing a common SoC helper/model for this.
This could be a start for a more generalized solution.
I was thinking something like (untested but you get the idea):
-- >8 --
diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h
index 77a5077511f..d12774d6cc3 100644
--- a/include/hw/misc/unimp.h
+++ b/include/hw/misc/unimp.h
@@ -25,6 +25,27 @@ struct UnimplementedDeviceState {
uint64_t size;
};
+typedef struct UnimplementedDeviceConfig {
+ const char *qom_name;
+ const char *region_name;
+ uint64_t offset;
+ uint64_t size;
+ int priority;
+} UnimplementedDeviceConfig;
+
+/**
+ * create_unimplemented_devices:
+ * @parentobj: the parent object
+ * @container: a #MemoryRegion within which @addr is a relative address
+ * @devconfigs: NULL terminated array of #UnimplementedDeviceConfig
+ *
+ * For each entries in @devconfigs, create a TYPE_UNIMPLEMENTED_DEVICE
+ * and mmap it in @container at UnimplementedDeviceConfig::offset.
+ * @container is expected to be a QOM child of @parentobj.
+ */
+void create_unimplemented_devices(Object *parentobj, MemoryRegion
*container,
+ const UnimplementedDeviceConfig
*const devconfigs[]);
+
/**
* create_unimplemented_device: create and map a dummy device
* @name: name of the device for debug logging
---