Skip to contentSkip to conversation

qom-qdev queue 20260827

GIT PULL Applied Mark Cave-Ayland 2 participants 18 messages Aug 27

lore
Share & tools
lore
#0 lore raw

The following changes since commit bbc8fb89fa3478a6f47c0475d2e4952e69a64f45:

Merge tag 'pull-tcg-20260826' of https://gitlab.com/rth7680/qemu into staging (2026-08-26 21:33:14 -0700)

are available in the Git repository at:

https://gitlab.com/mcayland-ntx/qemu.git tags/classprop-hw-acpi-upstream-20260827

for you to fetch changes up to 3435f9eed289b362097429d031c75bdaa847446b:

hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop (2026-08-27 15:22:11 +0100)

----------------------------------------------------------------
qom-qdev queue
- Conversion of object properties to class properties (hw/acpi)

----------------------------------------------------------------
Mark Cave-Ayland (16):
qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro qom/object.c: add object_class_property_add_uint8_ptr()
qom/object.c: add object_class_property_add_uint64_ptr()
hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop qom/object.c: add object_class_property_add_uint32_ptr()
hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property qom/object.c: add object_class_property_add_bool_ptr()
hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props qom/object.c: add object_class_property_add_uint16_ptr()
hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop hw/acpi/piix4.c: convert static variables to static class properties hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop

 include/hw/acpi/ich9.h         |   2 +-
 include/hw/pci/pci_bus.h       |   2 +
 include/qom/object.h           |  90 ++++++++++++++++++++++
 hw/acpi/generic_event_device.c |  10 +++
 hw/acpi/ich9.c                 | 115 +++++++++++----------------
 hw/acpi/pci-bridge.c           |   9 ++-
 hw/acpi/pcihp.c                |  35 ++++-----
 hw/acpi/piix4.c                |  51 ++++++++----
 hw/arm/virt-acpi-build.c       |   5 +-
 hw/i386/acpi-build.c           |   5 +-
 hw/isa/lpc_ich9.c              |  36 +++++----
 hw/pci/pci.c                   |   7 ++
 qom/object.c                   | 171 +++++++++++++++++++++++++++++++++++++++++
 13 files changed, 416 insertions(+), 122 deletions(-)
#1 lore raw

[PULL 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro

This macro will be used to generate the boilerplate property_class_get_type_ptr() QOM get function for the specified scalar type.

Note that since the macro is currently unused, the object_class_prop_ptr() helper function is temporarily marked as __attribute__((unused)) to allow compilation to succeed.

Message-Id: <[email protected]>

---
 qom/object.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
qom/object.c +22 -0
index 47977b1f44..e32ae30bd5 100644
@@ -2703,6 +2703,28 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
 #undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
 
 
+__attribute__((unused))
+static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
+{
+    void *ptr = obj;
+    ptr += offset;
+
+    return ptr;
+}
+
+#define OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
+    static void property_class_get_##type##_ptr(Object *obj, Visitor *v, \
+                                                const char *name, \
+                                                void *opaque, Error **errp) \
+    { \
+        type##_t value = *(type##_t *)object_class_prop_ptr(obj, \
+                                                        (ptrdiff_t)opaque); \
+        visit_type_##type(v, name, &value, errp); \
+    }
+
+#undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
+
+
 ObjectProperty *
 object_property_add_uint8_ptr(Object *obj, const char *name,
                               const uint8_t *v,
Signature · 1 line
2.43.0
#2 lore raw

[PULL 05/16] qom/object.c: add object_class_property_add_uint64_ptr()

In reply to Mark Cave-Ayland

This adds a class property that references a uint8_t within the object instance and is intended to be a replacement for object_property_add_uint64_ptr().

Message-Id: <[email protected]>

---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)
include/qom/object.h +18 -0
index eba675d218..67ccd2b08f 100644
@@ -2168,6 +2168,24 @@ ObjectProperty *object_property_add_uint64_ptr(Object *obj, const char *name,
                                     const uint64_t *v,
                                     ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint64_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint64 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint64'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint64_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint64_ptr:
  * @klass: the object class to add a static property to
qom/object.c +21 -0
index a480fdd400..271c2916b7 100644
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
 #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
@@ -2911,6 +2912,26 @@ object_property_add_uint64_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint64_ptr(ObjectClass *klass, const char *name,
+                                     ptrdiff_t offset,
+                                     ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint64_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint64_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint64",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint64_ptr(ObjectClass *klass,
                                             const char *name,
Signature · 1 line
2.43.0
#3 lore raw

[PULL 04/16] qom/object.c: add object_class_property_add_uint8_ptr()

In reply to Mark Cave-Ayland

This adds a class property that references a uint8_t within the object instance and is intended to be a replacement for object_property_add_uint8_ptr().

This commit also removes the __attribute__((unused)) annotation from object_class_prop_ptr() which is no longer required now that the previous defined DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() is now being used.

Message-Id: <[email protected]>

---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 23 ++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
include/qom/object.h +18 -0
index 11b1c9d2dc..eba675d218 100644
@@ -2033,6 +2033,24 @@ ObjectProperty *object_property_add_uint8_ptr(Object *obj, const char *name,
                                               const uint8_t *v,
                                               ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint8_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint8 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint8'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint8_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint8_ptr:
  * @klass: the object class to add a static property to
qom/object.c +22 -1
index 9cb2cae4a7..a480fdd400 100644
@@ -2703,7 +2703,6 @@ DEFINE_OBJECT_PROPERTY_SCALAR_METHODS(uint64)
 #undef DEFINE_OBJECT_PROPERTY_SCALAR_METHODS
 
 
-__attribute__((unused))
 static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
 {
     void *ptr = obj;
@@ -2742,6 +2741,8 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
 #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
 #undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
@@ -2767,6 +2768,26 @@ object_property_add_uint8_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint8_ptr(ObjectClass *klass, const char *name,
+                                    ptrdiff_t offset,
+                                    ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint8_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint8_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint8",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint8_ptr(ObjectClass *klass,
                                            const char *name,
Signature · 1 line
2.43.0
#4 lore raw

[PULL 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro

In reply to Mark Cave-Ayland

This macro defines both the QOM get and set functions for the given scaler type.

Message-Id: <[email protected]>

---
 qom/object.c | 5 +++++
 1 file changed, 5 insertions(+)
qom/object.c +5 -0
index fe4e552928..9cb2cae4a7 100644
@@ -2738,8 +2738,13 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
         *field = value; \
     }
 
+#define DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(type) \
+    OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) \
+    OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
+
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
 #undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
+#undef DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS
 
 
 ObjectProperty *
Signature · 1 line
2.43.0
#5 lore raw

[PULL 08/16] qom/object.c: add object_class_property_add_uint32_ptr()

In reply to Mark Cave-Ayland

This adds a class property that references a uint32_t within the object instance and is intended to be a replacement for object_property_add_uint32_ptr().

Message-Id: <[email protected]>

---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)
include/qom/object.h +18 -0
index 67ccd2b08f..8dead29284 100644
@@ -2129,6 +2129,24 @@ ObjectProperty *object_property_add_uint32_ptr(Object *obj, const char *name,
                                     const uint32_t *v,
                                     ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint32_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint32 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint32'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint32_ptr(ObjectClass *klass,
+                                    const char *name,
+                                    ptrdiff_t offset,
+                                    ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint32_ptr:
  * @klass: the object class to add a static property to
qom/object.c +21 -0
index 271c2916b7..f91764aaa7 100644
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
@@ -2871,6 +2872,26 @@ object_property_add_uint32_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint32_ptr(ObjectClass *klass, const char *name,
+                                     ptrdiff_t offset,
+                                     ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint32_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint32_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint32",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint32_ptr(ObjectClass *klass,
                                             const char *name,
Signature · 1 line
2.43.0
#6 lore raw

[PULL 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props

In reply to Mark Cave-Ayland

ACPI_PM_PROP_TCO_ENABLED, ACPI_PM_PROP_ACPI_PCIHP_BRIDGE and x-keep-pci-slot-hpc properties can be converted to use object_class_property_add_bool_ptr(). Remove the now unused ich9_pm_add_properties() function.

Message-Id: <[email protected]>

---
 include/hw/acpi/ich9.h |   3 +-
 hw/acpi/ich9.c         | 102 ++++++++++++++---------------------------
 hw/isa/lpc_ich9.c      |   3 +-
 3 files changed, 36 insertions(+), 72 deletions(-)
include/hw/acpi/ich9.h +1 -2
index 3fb993bb9e..6d14544751 100644
@@ -83,8 +83,7 @@ extern const VMStateDescription vmstate_ich9_pm;
 
 void ich9_pm_reset_properties(ICH9LPCPMRegs *pm);
 
-void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm);
-void ich9_pm_add_class_properties(ObjectClass *oc);
+void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset);
 
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp);
hw/acpi/ich9.c +34 -68

123 lines not on this page · raw message

hw/isa/lpc_ich9.c +1 -2
index d3f1358887..b55b5136a3 100644
@@ -689,7 +689,6 @@ static void ich9_lpc_initfn(Object *obj)
                              IOAPIC_NUM_PINS);
 
     ich9_pm_reset_properties(&lpc->pm);
-    ich9_pm_add_properties(obj, &lpc->pm);
 }
 
 static void ich9_lpc_realize(PCIDevice *d, Error **errp)
@@ -920,7 +919,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
                                                &acpi_disable_cmd,
                                                OBJ_PROP_FLAG_READ);
 
-    ich9_pm_add_class_properties(klass);
+    ich9_pm_add_class_properties(klass, offsetof(ICH9LPCState, pm));
 }
 
 static const TypeInfo ich9_lpc_info = {
Signature · 1 line
2.43.0
#7 lore raw

[PULL 10/16] qom/object.c: add object_class_property_add_bool_ptr()

In reply to Mark Cave-Ayland

This adds a class property that references a bool within the object instance and is intended to be used as a replacement for object_class_property_add_bool() where possible. Since bool is a macro then it is necessary to implement property_class_get_bool_ptr() and property_class_set_bool_ptr() manually instead of using the existing OBJECT_CLASS_PROPERTY_SCALAR_GETTER() and OBJECT_CLASS_PROPERTY_SCALAR_SETTER() macros.

Message-Id: <[email protected]>

---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
include/qom/object.h +18 -0
index 8dead29284..de37016ba8 100644
@@ -2017,6 +2017,24 @@ typedef enum {
     OBJ_PROP_FLAG_READWRITE = (OBJ_PROP_FLAG_READ | OBJ_PROP_FLAG_WRITE),
 } ObjectPropertyFlags;
 
+/**
+ * object_class_property_add_bool_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the bool value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an boolean property in memory.  This function will add a
+ * property of type 'bool'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_bool_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_property_add_uint8_ptr:
  * @obj: the object to add a property to
qom/object.c +43 -0

49 lines not on this page · raw message

Signature · 1 line
2.43.0
#8 lore raw

[PULL 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props

In reply to Mark Cave-Ayland

ACPI_PM_PROP_SCI_INT can be updated to use object_class_property_add_uint8_ptr() with OBJ_PROP_FLAG_READ, whilst ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP can be updated to use object_class_property_add_uint64_ptr().

Message-Id: <[email protected]>

---
 hw/isa/lpc_ich9.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
hw/isa/lpc_ich9.c +20 -13
index edf9783ec8..07c9509cf4 100644
@@ -683,24 +683,11 @@ static void ich9_lpc_initfn(Object *obj)
 {
     ICH9LPCState *lpc = ICH9_LPC_DEVICE(obj);
 
-    static const uint8_t acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
-    static const uint8_t acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
-
     object_initialize_child(obj, "rtc", &lpc->rtc, TYPE_MC146818_RTC);
 
     qdev_init_gpio_out_named(DEVICE(lpc), lpc->gsi, ICH9_GPIO_GSI,
                              IOAPIC_NUM_PINS);
 
-    object_property_add_uint8_ptr(obj, ACPI_PM_PROP_SCI_INT,
-                                  &lpc->sci_gsi, OBJ_PROP_FLAG_READ);
-    object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_ENABLE_CMD,
-                                  &acpi_enable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_DISABLE_CMD,
-                                  &acpi_disable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint64_ptr(obj, ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
-                                   &lpc->smi_negotiated_features,
-                                   OBJ_PROP_FLAG_READ);
-
     ich9_pm_reset_properties(&lpc->pm);
     ich9_pm_add_properties(obj, &lpc->pm);
 }
@@ -888,6 +875,9 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
     AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(klass);
     AcpiDevAmlIfClass *amldevc = ACPI_DEV_AML_IF_CLASS(klass);
 
+    static const uint8_t acpi_enable_cmd = ICH9_APM_ACPI_ENABLE;
+    static const uint8_t acpi_disable_cmd = ICH9_APM_ACPI_DISABLE;
+
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     device_class_set_legacy_reset(dc, ich9_lpc_reset);
     k->realize = ich9_lpc_realize;
@@ -912,6 +902,23 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
     adevc->ospm_status = ich9_pm_ospm_status;
     adevc->send_event = ich9_send_gpe;
     amldevc->build_dev_aml = build_ich9_isa_aml;
+
+    object_class_property_add_uint8_ptr(klass, ACPI_PM_PROP_SCI_INT,
+                                        offsetof(ICH9LPCState, sci_gsi),
+                                        OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint64_ptr(klass,
+                                         ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
+                                         offsetof(ICH9LPCState,
+                                                  smi_negotiated_features),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(klass,
+                                               ACPI_PM_PROP_ACPI_ENABLE_CMD,
+                                               &acpi_enable_cmd,
+                                               OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(klass,
+                                               ACPI_PM_PROP_ACPI_DISABLE_CMD,
+                                               &acpi_disable_cmd,
+                                               OBJ_PROP_FLAG_READ);
 }
 
 static const TypeInfo ich9_lpc_info = {
Signature · 1 line
2.43.0
#9 lore raw

[PULL 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop

In reply to Mark Cave-Ayland

Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all callers accordingly.

Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL property to enable the relevant ACPI changes, set the type of the underlying variable to uint32_t with a default value of UINT32_MAX indicating that the property has not been set.

Message-Id: <[email protected]>

---
 include/hw/pci/pci_bus.h |  2 ++
 hw/acpi/pci-bridge.c     |  9 ++++++++-
 hw/acpi/pcihp.c          | 30 ++++++++++++++----------------
 hw/arm/virt-acpi-build.c |  5 ++++-
 hw/i386/acpi-build.c     |  5 ++++-
 hw/pci/pci.c             |  7 +++++++
 6 files changed, 39 insertions(+), 19 deletions(-)
include/hw/pci/pci_bus.h +2 -0
index c738446788..7ecb23d13c 100644
@@ -56,6 +56,8 @@ struct PCIBus {
     int *irq_count;
 
     Notifier machine_done;
+
+    uint32_t acpi_pcihp_bsel_val;
 };
 
 static inline bool pci_bus_is_cxl(PCIBus *bus)
hw/acpi/pci-bridge.c +8 -1
index 394a919479..1bfc5431f2 100644
@@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
 
     if (!DEVICE(br)->hotplugged) {
         PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
+        Error *local_err = NULL;
+        uint32_t bsel;
 
         build_append_pci_bus_devices(scope, sec_bus);
 
@@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
          * generate hotplug slots descriptors if
          * bridge has ACPI PCI hotplug attached,
          */
-        if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
+        bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
+                                        &local_err);
+
+        if (local_err == NULL && bsel != UINT32_MAX) {
             build_append_pcihp_slots(scope, sec_bus);
         }
+
+        error_free(local_err);
     }
 }
 
hw/acpi/pcihp.c +14 -16
index a91f523c93..b26ddf0a26 100644
@@ -58,7 +58,7 @@ typedef struct AcpiPciHpFind {
 static int acpi_pcihp_get_bsel(PCIBus *bus)
 {
     Error *local_err = NULL;
-    uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+    uint32_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
                                              &local_err);
 
     if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
@@ -78,18 +78,14 @@ typedef struct {
 static void *acpi_set_bsel(PCIBus *bus, void *opaque)
 {
     BSELInfo *info = opaque;
-    unsigned *bus_bsel;
     DeviceState *br = bus->qbus.parent;
     bool is_bridge = IS_PCI_BRIDGE(br);
 
     /* hotplugged bridges can't be described in ACPI ignore them */
     if (qbus_is_hotpluggable(BUS(bus))) {
         if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
-            bus_bsel = g_malloc(sizeof *bus_bsel);
-
-            *bus_bsel = info->bsel_alloc++;
-            object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
-                                           bus_bsel, OBJ_PROP_FLAG_READ);
+            object_property_set_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+                                     info->bsel_alloc++, NULL);
         }
     }
 
@@ -730,14 +726,16 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)
     /* If bus supports hotplug select it and notify about local events */
     bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
     if (bsel) {
-        uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
-
-        aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
-        aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
-                                     aml_int(1))); /* Device Check */
-        aml_append(method, aml_call2("DVNT", aml_name("PCID"),
-                                     aml_int(3))); /* Eject Request */
-        nr_notifiers++;
+        uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
+
+        if (bsel_val != UINT32_MAX) {
+            aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
+            aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
+                                         aml_int(1))); /* Device Check */
+            aml_append(method, aml_call2("DVNT", aml_name("PCID"),
+                                         aml_int(3))); /* Eject Request */
+            nr_notifiers++;
+        }
     }
 
     /* Notify about child bus events in any case */
@@ -848,7 +846,7 @@ void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel = object_property_get_qobject(OBJECT(bus),
                         ACPI_PCIHP_PROP_BSEL, NULL);
-    uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
+    uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
     qobject_unref(bsel);
 
     aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
hw/arm/virt-acpi-build.c +4 -1
index f6386088b6..d368913e76 100644
@@ -1207,6 +1207,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
                         .oem_table_id = vms->oem_table_id };
     Aml *pci0_scope;
+    uint32_t bsel;
 
     acpi_table_begin(&table, table_data);
     dsdt = init_aml_allocator();
@@ -1269,7 +1270,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 
     aml_append(pci0_scope, build_pci_bridge_edsm());
     build_append_pci_bus_devices(pci0_scope, vms->bus);
-    if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
+    bsel = object_property_get_uint(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
+                                    &error_abort);
+    if (bsel != UINT32_MAX) {
         build_append_pcihp_slots(pci0_scope, vms->bus);
     }
 
hw/i386/acpi-build.c +4 -1
index 8837b69687..1696821048 100644
@@ -1198,13 +1198,16 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     sb_scope = aml_scope("\\_SB");
     {
         Object *pci_host = acpi_get_i386_pci_host();
+        uint32_t bsel;
 
         if (pci_host) {
             PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
             Aml *ascope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
             build_append_pci_bus_devices(ascope, pbus);
-            if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
+            bsel = object_property_get_uint(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
+                                            &error_abort);
+            if (bsel != UINT32_MAX) {
                 build_append_pcihp_slots(ascope, pbus);
             }
             aml_append(sb_scope, ascope);
hw/pci/pci.c +7 -0
index d3191609e2..e8e8a3b767 100644
@@ -25,6 +25,7 @@
 #include "qemu/osdep.h"
 #include "qemu/datadir.h"
 #include "qemu/units.h"
+#include "hw/acpi/pcihp.h"
 #include "hw/core/irq.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bridge.h"
@@ -187,6 +188,8 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
     bus->machine_done.notify = pcibus_machine_done;
     qemu_add_machine_init_done_notifier(&bus->machine_done);
 
+    bus->acpi_pcihp_bsel_val = UINT32_MAX;
+
     vmstate_register_any(NULL, &vmstate_pcibus, bus);
 }
 
@@ -302,6 +305,10 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data)
     pbc->numa_node = pcibus_numa_node;
 
     fwgc->get_data = pci_bus_fw_cfg_gen_data;
+
+    object_class_property_add_uint32_ptr(klass, ACPI_PCIHP_PROP_BSEL,
+                                         offsetof(PCIBus, acpi_pcihp_bsel_val),
+                                         OBJ_PROP_FLAG_READWRITE);
 }
 
 static const TypeInfo pci_bus_info = {
Signature · 1 line
2.43.0
#10 lore raw

[PULL 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro

In reply to Mark Cave-Ayland

This macro will be used to generate the boilerplate property_class_set_type_ptr() QOM set function for the specified scalar type.

Message-Id: <[email protected]>

---
 qom/object.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
qom/object.c +17 -0
index e32ae30bd5..fe4e552928 100644
@@ -2722,7 +2722,24 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
         visit_type_##type(v, name, &value, errp); \
     }
 
+#define OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) \
+    static void property_class_set_##type##_ptr(Object *obj, Visitor *v, \
+                                                const char *name, \
+                                                void *opaque, Error **errp) \
+    { \
+        type##_t *field = (type##_t *)object_class_prop_ptr(obj, \
+                                                        (ptrdiff_t)opaque); \
+        type##_t value; \
+        \
+        if (!visit_type_##type(v, name, &value, errp)) { \
+            return; \
+        } \
+        \
+        *field = value; \
+    }
+
 #undef OBJECT_CLASS_PROPERTY_SCALAR_GETTER
+#undef OBJECT_CLASS_PROPERTY_SCALAR_SETTER
 
 
 ObjectProperty *
Signature · 1 line
2.43.0
#11 lore raw

[PULL 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop

In reply to Mark Cave-Ayland

In order to convert to a class property, the ICH9LPCPMRegs instance must be resolved by the getter/setter instead of being passed directly as an opaque.

Message-Id: <[email protected]>

---
 hw/acpi/ich9.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
hw/acpi/ich9.c +3 -2
index 5e8f8a7eaf..ac3f452dc3 100644
@@ -342,7 +342,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, qemu_irq sci_irq)
 static void ich9_pm_get_gpe0_blk(Object *obj, Visitor *v, const char *name,
                                  void *opaque, Error **errp)
 {
-    ICH9LPCPMRegs *pm = opaque;
+    ICH9LPCState *s = ICH9_LPC_DEVICE(obj);
+    ICH9LPCPMRegs *pm = &s->pm;
     uint32_t value = pm->pm_io_base + ICH9_PMIO_GPE0_STS;
 
     visit_type_uint32(v, name, &value, errp);
@@ -411,7 +412,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
                              OBJ_PROP_LINK_STRONG);
     object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32",
                         ich9_pm_get_gpe0_blk,
-                        NULL, NULL, pm);
+                        NULL, NULL, NULL);
     object_property_add_uint32_ptr(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
                                    &gpe0_len, OBJ_PROP_FLAG_READ);
     object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S3_DISABLED,
Signature · 1 line
2.43.0
#12 lore raw

[PULL 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property

In reply to Mark Cave-Ayland

The ACPI_PM_PROP_GPE0_BLK_LEN property is assigned to a static variable and so can be converted to a static class property. Introduce ich9_pm_add_class_properties() to hold the ACPI_PM_PROP_GPE0_BLK_LEN property and soon all other class props after they have been converted from object props.

Message-Id: <[email protected]>

---
 include/hw/acpi/ich9.h |  1 +
 hw/acpi/ich9.c         | 14 ++++++++++----
 hw/isa/lpc_ich9.c      |  2 ++
 3 files changed, 13 insertions(+), 4 deletions(-)
include/hw/acpi/ich9.h +1 -0
index 30990fcef5..3fb993bb9e 100644
@@ -84,6 +84,7 @@ extern const VMStateDescription vmstate_ich9_pm;
 void ich9_pm_reset_properties(ICH9LPCPMRegs *pm);
 
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm);
+void ich9_pm_add_class_properties(ObjectClass *oc);
 
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp);
hw/acpi/ich9.c +10 -4
index ac3f452dc3..774b34195f 100644
@@ -402,8 +402,6 @@ void ich9_pm_reset_properties(ICH9LPCPMRegs *pm)
 
 void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
 {
-    static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
-
     object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE,
                                    &pm->pm_io_base, OBJ_PROP_FLAG_READ);
     object_property_add_link(obj, "bus", TYPE_PCI_BUS,
@@ -413,8 +411,6 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
     object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, "uint32",
                         ich9_pm_get_gpe0_blk,
                         NULL, NULL, NULL);
-    object_property_add_uint32_ptr(obj, ACPI_PM_PROP_GPE0_BLK_LEN,
-                                   &gpe0_len, OBJ_PROP_FLAG_READ);
     object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S3_DISABLED,
                                   &pm->disable_s3, OBJ_PROP_FLAG_READWRITE);
     object_property_add_uint8_ptr(obj, ACPI_PM_PROP_S4_DISABLED,
@@ -432,6 +428,16 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)
                              ich9_pm_set_keep_pci_slot_hpc);
 }
 
+void ich9_pm_add_class_properties(ObjectClass *oc)
+{
+    static const uint32_t gpe0_len = ICH9_PMIO_GPE0_LEN;
+
+    object_class_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK_LEN,
+                                                &gpe0_len,
+                                                OBJ_PROP_FLAG_READ);
+}
+
 void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                                 Error **errp)
 {
hw/isa/lpc_ich9.c +2 -0
index 07c9509cf4..d3f1358887 100644
@@ -919,6 +919,8 @@ static void ich9_lpc_class_init(ObjectClass *klass, const void *data)
                                                ACPI_PM_PROP_ACPI_DISABLE_CMD,
                                                &acpi_disable_cmd,
                                                OBJ_PROP_FLAG_READ);
+
+    ich9_pm_add_class_properties(klass);
 }
 
 static const TypeInfo ich9_lpc_info = {
Signature · 1 line
2.43.0
#13 lore raw

[PULL 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop

In reply to Mark Cave-Ayland

ACPI_PM_PROP_PM_IO_BASE can be converted to use object_class_property_add_uint32_ptr(). Remove the now unused piix4_pm_add_properties() function.

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
hw/acpi/piix4.c +4 -8
index 6462ba970c..52bd61667f 100644
@@ -405,12 +405,6 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)
         (memory_region_present(io_as, 0x2f8) ? 0x90 : 0);
 }
 
-static void piix4_pm_add_properties(PIIX4PMState *s)
-{
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
-                                   &s->io_base, OBJ_PROP_FLAG_READ);
-}
-
 static void piix4_pm_add_class_properties(ObjectClass *oc)
 {
     static const uint8_t acpi_enable_cmd = ACPI_ENABLE;
@@ -439,6 +433,10 @@ static void piix4_pm_add_class_properties(ObjectClass *oc)
                                                 ACPI_PM_PROP_SCI_INT,
                                                 &sci_int,
                                                 OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint32_ptr(oc,
+                                         ACPI_PM_PROP_PM_IO_BASE,
+                                         offsetof(PIIX4PMState, io_base),
+                                         OBJ_PROP_FLAG_READ);
 }
 
 static void piix4_pm_realize(PCIDevice *dev, Error **errp)
@@ -494,8 +492,6 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
 
     piix4_acpi_system_hot_add_init(pci_address_space_io(dev),
                                    pci_get_bus(dev), s);
-
-    piix4_pm_add_properties(s);
 }
 
 static void piix4_pm_init(Object *obj)
Signature · 1 line
2.43.0
#14 lore raw

[PULL 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props

In reply to Mark Cave-Ayland

Since the objects referenced by acpi_pcihp_init() do not inherit from a common class, add ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP class properties to each referenced object and remove the object properties manually added in acpi_pcihp_init().

Message-Id: <[email protected]>

---
 hw/acpi/generic_event_device.c | 10 ++++++++++
 hw/acpi/ich9.c                 |  6 ++++++
 hw/acpi/pcihp.c                |  5 -----
 hw/acpi/piix4.c                |  9 +++++++++
 4 files changed, 25 insertions(+), 5 deletions(-)
hw/acpi/generic_event_device.c +10 -0
index 9e9416d406..67c9e9b3e8 100644
@@ -11,6 +11,7 @@
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/pcihp.h"
 #include "hw/acpi/cpu.h"
@@ -608,6 +609,15 @@ static void acpi_ged_class_init(ObjectClass *class, const void *data)
 
     adevc->ospm_status = acpi_ged_ospm_status;
     adevc->send_event = acpi_ged_send_event;
+
+    object_class_property_add_uint16_ptr(class, ACPI_PCIHP_IO_BASE_PROP,
+                                         offsetof(AcpiGedState,
+                                                  pcihp_state.io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(class, ACPI_PCIHP_IO_LEN_PROP,
+                                         offsetof(AcpiGedState,
+                                                  pcihp_state.io_len),
+                                         OBJ_PROP_FLAG_READ);
 }
 
 static const TypeInfo acpi_ged_info = {
hw/acpi/ich9.c +6 -0
index d6df8db21f..8082eae428 100644
@@ -400,6 +400,12 @@ void ich9_pm_add_class_properties(ObjectClass *oc, ptrdiff_t pm_offset)
     object_class_property_add_bool_ptr(oc, "x-keep-pci-slot-hpc",
                                        PM_REG_FIELD(keep_pci_slot_hpc),
                                        OBJ_PROP_FLAG_READWRITE);
+    object_class_property_add_uint16_ptr(oc, ACPI_PCIHP_IO_BASE_PROP,
+                                   PM_REG_FIELD(acpi_pci_hotplug.io_base),
+                                   OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(oc, ACPI_PCIHP_IO_LEN_PROP,
+                                   PM_REG_FIELD(acpi_pci_hotplug.io_len),
+                                   OBJ_PROP_FLAG_READ);
 }
 
 #undef PM_REG_FIELD
hw/acpi/pcihp.c +0 -5
index 87162ff2c0..a91f523c93 100644
@@ -502,11 +502,6 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s,
     memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s,
                           "acpi-pci-hotplug", s->io_len);
     memory_region_add_subregion(io, s->io_base, &s->io);
-
-    object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_BASE_PROP, &s->io_base,
-                                   OBJ_PROP_FLAG_READ);
-    object_property_add_uint16_ptr(owner, ACPI_PCIHP_IO_LEN_PROP, &s->io_len,
-                                   OBJ_PROP_FLAG_READ);
 }
 
 void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar)
hw/acpi/piix4.c +9 -0
index 9b7f50c7af..1d209ac96d 100644
@@ -607,6 +607,15 @@ static void piix4_pm_class_init(ObjectClass *klass, const void *data)
     hc->is_hotpluggable_bus = piix4_is_hotpluggable_bus;
     adevc->ospm_status = piix4_ospm_status;
     adevc->send_event = piix4_send_gpe;
+
+    object_class_property_add_uint16_ptr(klass, ACPI_PCIHP_IO_BASE_PROP,
+                                         offsetof(PIIX4PMState,
+                                                  acpi_pci_hotplug.io_base),
+                                         OBJ_PROP_FLAG_READ);
+    object_class_property_add_uint16_ptr(klass, ACPI_PCIHP_IO_LEN_PROP,
+                                         offsetof(PIIX4PMState,
+                                                  acpi_pci_hotplug.io_len),
+                                         OBJ_PROP_FLAG_READ);
 }
 
 static const TypeInfo piix4_pm_info = {
Signature · 1 line
2.43.0
#15 lore raw

[PULL 15/16] hw/acpi/piix4.c: convert static variables to static class properties

In reply to Mark Cave-Ayland

The majority of the properties in piix4_pm_add_properties() are assigned to static variables and so can be converted to static class properties. Introduce piix4_pm_add_class_properties() to hold the static properties and soon all other class props after they have been converted from object props.

Message-Id: <[email protected]>

---
 hw/acpi/piix4.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)
hw/acpi/piix4.c +28 -12
index 1d209ac96d..6462ba970c 100644
@@ -406,6 +406,12 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque)
 }
 
 static void piix4_pm_add_properties(PIIX4PMState *s)
+{
+    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
+                                   &s->io_base, OBJ_PROP_FLAG_READ);
+}
+
+static void piix4_pm_add_class_properties(ObjectClass *oc)
 {
     static const uint8_t acpi_enable_cmd = ACPI_ENABLE;
     static const uint8_t acpi_disable_cmd = ACPI_DISABLE;
@@ -413,18 +419,26 @@ static void piix4_pm_add_properties(PIIX4PMState *s)
     static const uint32_t gpe0_blk_len = GPE_LEN;
     static const uint16_t sci_int = 9;
 
-    object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_ENABLE_CMD,
-                                  &acpi_enable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint8_ptr(OBJECT(s), ACPI_PM_PROP_ACPI_DISABLE_CMD,
-                                  &acpi_disable_cmd, OBJ_PROP_FLAG_READ);
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK,
-                                  &gpe0_blk, OBJ_PROP_FLAG_READ);
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_GPE0_BLK_LEN,
-                                  &gpe0_blk_len, OBJ_PROP_FLAG_READ);
-    object_property_add_uint16_ptr(OBJECT(s), ACPI_PM_PROP_SCI_INT,
-                                  &sci_int, OBJ_PROP_FLAG_READ);
-    object_property_add_uint32_ptr(OBJECT(s), ACPI_PM_PROP_PM_IO_BASE,
-                                  &s->io_base, OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(oc,
+                                               ACPI_PM_PROP_ACPI_ENABLE_CMD,
+                                               &acpi_enable_cmd,
+                                               OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint8_ptr(oc,
+                                               ACPI_PM_PROP_ACPI_DISABLE_CMD,
+                                               &acpi_disable_cmd,
+                                               OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK,
+                                                &gpe0_blk,
+                                                OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint32_ptr(oc,
+                                                ACPI_PM_PROP_GPE0_BLK_LEN,
+                                                &gpe0_blk_len,
+                                                OBJ_PROP_FLAG_READ);
+    object_class_static_property_add_uint16_ptr(oc,
+                                                ACPI_PM_PROP_SCI_INT,
+                                                &sci_int,
+                                                OBJ_PROP_FLAG_READ);
 }
 
 static void piix4_pm_realize(PCIDevice *dev, Error **errp)
@@ -616,6 +630,8 @@ static void piix4_pm_class_init(ObjectClass *klass, const void *data)
                                          offsetof(PIIX4PMState,
                                                   acpi_pci_hotplug.io_len),
                                          OBJ_PROP_FLAG_READ);
+
+    piix4_pm_add_class_properties(klass);
 }
 
 static const TypeInfo piix4_pm_info = {
Signature · 1 line
2.43.0
#16 lore raw

[PULL 12/16] qom/object.c: add object_class_property_add_uint16_ptr()

In reply to Mark Cave-Ayland

This adds a class property that references a uint16_t within the object instance and is intended to be a replacement for object_property_add_uint16_ptr().

Message-Id: <[email protected]>

---
 include/qom/object.h | 18 ++++++++++++++++++
 qom/object.c         | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)
include/qom/object.h +18 -0
index de37016ba8..e24f0a2b2d 100644
@@ -2108,6 +2108,24 @@ ObjectProperty *object_property_add_uint16_ptr(Object *obj, const char *name,
                                     const uint16_t *v,
                                     ObjectPropertyFlags flags);
 
+/**
+ * object_class_property_add_uint16_ptr:
+ * @klass: the object class to add a property to
+ * @name: the name of the property
+ * @offset: the offset from the object instance where the uint16 value is
+ *   stored
+ * @flags: bitwise-or'd ObjectPropertyFlags
+ *
+ * Add an integer property in memory.  This function will add a
+ * property of type 'uint16'.
+ *
+ * Returns: The newly added property on success, or %NULL on failure.
+ */
+ObjectProperty *object_class_property_add_uint16_ptr(ObjectClass *klass,
+                                         const char *name,
+                                         ptrdiff_t offset,
+                                         ObjectPropertyFlags flags);
+
 /**
  * object_class_static_property_add_uint16_ptr:
  * @klass: the object class to add a static property to
qom/object.c +21 -0
index 635eeeac77..85bbd7f9fe 100644
@@ -2742,6 +2742,7 @@ static void *object_class_prop_ptr(Object *obj, ptrdiff_t offset)
     OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type)
 
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint8)
+DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint16)
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint32)
 DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS(uint64)
 
@@ -2874,6 +2875,26 @@ object_property_add_uint16_ptr(Object *obj, const char *name,
                                getter, setter, NULL, (void *)v);
 }
 
+ObjectProperty *
+object_class_property_add_uint16_ptr(ObjectClass *klass, const char *name,
+                                     ptrdiff_t offset,
+                                     ObjectPropertyFlags flags)
+{
+    ObjectPropertyAccessor *getter = NULL;
+    ObjectPropertyAccessor *setter = NULL;
+
+    if ((flags & OBJ_PROP_FLAG_READ) == OBJ_PROP_FLAG_READ) {
+        getter = property_class_get_uint16_ptr;
+    }
+
+    if ((flags & OBJ_PROP_FLAG_WRITE) == OBJ_PROP_FLAG_WRITE) {
+        setter = property_class_set_uint16_ptr;
+    }
+
+    return object_class_property_add(klass, name, "uint16",
+                                     getter, setter, NULL, (void *)offset);
+}
+
 ObjectProperty *
 object_class_static_property_add_uint16_ptr(ObjectClass *klass,
                                             const char *name,
Signature · 1 line
2.43.0
#17 lore raw
In reply to Mark Cave-Ayland
Quoted 8 lines · Mark Cave-Ayland

The following changes since commit bbc8fb89fa3478a6f47c0475d2e4952e69a64f45:

   Merge tag 'pull-tcg-20260826' ofhttps://gitlab.com/rth7680/qemu into staging (2026-08-26 21:33:14 -0700)

are available in the Git repository at:

   https://gitlab.com/mcayland-ntx/qemu.git tags/classprop-hw-acpi-upstream-20260827
Quoted 7 lines

for you to fetch changes up to 3435f9eed289b362097429d031c75bdaa847446b:

   hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop (2026-08-27 15:22:11 +0100)

----------------------------------------------------------------
qom-qdev queue
- Conversion of object properties to class properties (hw/acpi)

Applied, thanks.

r~