[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 02/16] hw/core/sysbus: Add a function for creatin
From: |
Thomas Huth |
Subject: |
[Qemu-devel] [PATCH v2 02/16] hw/core/sysbus: Add a function for creating and attaching an object |
Date: |
Fri, 13 Jul 2018 10:27:30 +0200 |
A lot of functions are initializing an object and attach it immediately
afterwards to the system bus. Provide a common function for this, which
also uses object_initialize_child() to make sure that the reference
counter is correctly initialized to 1 afterwards.
Signed-off-by: Thomas Huth <address@hidden>
---
hw/core/sysbus.c | 8 ++++++++
include/hw/sysbus.h | 3 +++
2 files changed, 11 insertions(+)
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index ecfb0cf..e2436ce 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -376,6 +376,14 @@ BusState *sysbus_get_default(void)
return main_system_bus;
}
+void sysbus_init_child_obj(Object *parent, const char *childname, void *child,
+ size_t childsize, const char *childtype)
+{
+ object_initialize_child(parent, childname, child, childsize, childtype,
+ &error_abort);
+ qdev_set_parent_bus(DEVICE(child), sysbus_get_default());
+}
+
static void sysbus_register_types(void)
{
type_register_static(&system_bus_info);
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index e88bb6d..e405232 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -96,6 +96,9 @@ void sysbus_add_io(SysBusDevice *dev, hwaddr addr,
MemoryRegion *mem);
MemoryRegion *sysbus_address_space(SysBusDevice *dev);
+void sysbus_init_child_obj(Object *parent, const char *childname, void *child,
+ size_t childsize, const char *childtype);
+
/* Call func for every dynamically created sysbus device in the system */
void foreach_dynamic_sysbus_device(FindSysbusDeviceFunc *func, void *opaque);
--
1.8.3.1
[Qemu-devel] [PATCH v2 02/16] hw/core/sysbus: Add a function for creating and attaching an object,
Thomas Huth <=
[Qemu-devel] [PATCH v2 03/16] hw/arm/bcm2836: Fix crash with device_add bcm2837 on unsupported machines, Thomas Huth, 2018/07/13
[Qemu-devel] [PATCH v2 04/16] hw/arm/armv7: Fix crash when introspecting the "iotkit" device, Thomas Huth, 2018/07/13
[Qemu-devel] [PATCH v2 05/16] hw/cpu/a15mpcore: Fix introspection problem with the a15mpcore_priv device, Thomas Huth, 2018/07/13
[Qemu-devel] [PATCH v2 06/16] hw/display/xlnx_dp: Move problematic code from instance_init to realize, Thomas Huth, 2018/07/13