[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/9] hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE
From: |
CLEMENT MATHIEU--DRIF |
Subject: |
Re: [PATCH 3/9] hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE |
Date: |
Mon, 27 Jan 2025 06:19:05 +0000 |
Reviewed-by: Clément Mathieu--Drif<clement.mathieu--drif@eviden.com>
On 25/01/2025 19:13, Philippe Mathieu-Daudé wrote:
> Caution: External email. Do not open attachments or click links, unless this
> email comes from a known sender and you know the content is safe.
>
>
> Some TYPE_SYS_BUS_DEVICEs can be optionally dynamically
> plugged on the TYPE_PLATFORM_BUS_DEVICE.
> Rather than sometimes noting that with comment around
> the 'user_creatable = true' line in each DeviceRealize
> handler, introduce an abstract TYPE_DYNAMIC_SYS_BUS_DEVICE
> class.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/hw/sysbus.h | 2 ++
> hw/core/sysbus.c | 14 ++++++++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
> index c9b1e0e90e3..81bbda10d37 100644
> --- a/include/hw/sysbus.h
> +++ b/include/hw/sysbus.h
> @@ -19,6 +19,8 @@ DECLARE_INSTANCE_CHECKER(BusState, SYSTEM_BUS,
> OBJECT_DECLARE_TYPE(SysBusDevice, SysBusDeviceClass,
> SYS_BUS_DEVICE)
>
> +#define TYPE_DYNAMIC_SYS_BUS_DEVICE "dynamic-sysbus-device"
> +
> /**
> * SysBusDeviceClass:
> *
> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
> index 306f98406c0..e8d03fd28d9 100644
> --- a/hw/core/sysbus.c
> +++ b/hw/core/sysbus.c
> @@ -321,6 +321,14 @@ BusState *sysbus_get_default(void)
> return main_system_bus;
> }
>
> +static void dynamic_sysbus_device_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *k = DEVICE_CLASS(klass);
> +
> + k->user_creatable = true;
> + k->hotpluggable = false;
> +}
> +
> static const TypeInfo sysbus_types[] = {
> {
> .name = TYPE_SYSTEM_BUS,
> @@ -336,6 +344,12 @@ static const TypeInfo sysbus_types[] = {
> .class_size = sizeof(SysBusDeviceClass),
> .class_init = sysbus_device_class_init,
> },
> + {
> + .name = TYPE_DYNAMIC_SYS_BUS_DEVICE,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .class_init = dynamic_sysbus_device_class_init,
> + .abstract = true,
> + }
> };
>
> DEFINE_TYPES(sysbus_types)
> --
> 2.47.1
>
- [PATCH 0/9] hw/sysbus/platform-bus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE, Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 1/9] hw/sysbus: Use sizeof(BusState) in main_system_bus_create(), Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 2/9] hw/sysbus: Declare QOM types using DEFINE_TYPES() macro, Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 3/9] hw/sysbus: Introduce TYPE_DYNAMIC_SYS_BUS_DEVICE, Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 4/9] hw/vfio: Have VFIO_PLATFORM devices inherit from DYNAMIC_SYS_BUS_DEVICE, Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 5/9] hw/display: Have RAMFB device inherit from DYNAMIC_SYS_BUS_DEVICE, Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 6/9] hw/i386: Have X86_IOMMU devices inherit from DYNAMIC_SYS_BUS_DEVICE, Philippe Mathieu-Daudé, 2025/01/25
- [PATCH 7/9] hw/net: Have eTSEC device inherit from DYNAMIC_SYS_BUS_DEVICE, Philippe Mathieu-Daudé, 2025/01/25