[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/22] qdev: Move SysBus initialization to sysbus.c
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH 16/22] qdev: Move SysBus initialization to sysbus.c |
Date: |
Mon, 18 Jun 2012 15:59:08 +0200 |
From: Paolo Bonzini <address@hidden>
TYPE_SYSTEM_BUS will be local to hw/sysbus.c, so move existing references
to main_system_bus and system_bus_info there.
Signed-off-by: Paolo Bonzini <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
hw/qdev.c | 26 ++------------------------
hw/sysbus.c | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 7b2802d..7816a37 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -34,10 +34,6 @@ int qdev_hotplug = 0;
static bool qdev_hot_added = false;
static bool qdev_hot_removed = false;
-/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
-static BusState *main_system_bus;
-static void main_system_bus_create(void);
-
/* Register a new device type. */
const VMStateDescription *qdev_get_vmsd(DeviceState *dev)
{
@@ -188,14 +184,6 @@ static int qdev_reset_one(DeviceState *dev, void *opaque)
return 0;
}
-BusState *sysbus_get_default(void)
-{
- if (!main_system_bus) {
- main_system_bus_create();
- }
- return main_system_bus;
-}
-
static int qbus_reset_one(BusState *bus, void *opaque)
{
if (bus->info->reset) {
@@ -415,7 +403,7 @@ void qbus_create_inplace(BusState *bus, BusInfo *info,
if (parent) {
QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling);
parent->num_child_bus++;
- } else if (bus != main_system_bus) {
+ } else if (bus != sysbus_get_default()) {
/* TODO: once all bus devices are qdevified,
only reset handler for main_system_bus should be registered here. */
qemu_register_reset(qbus_reset_all_fn, bus);
@@ -432,16 +420,6 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent,
const char *name)
return bus;
}
-static void main_system_bus_create(void)
-{
- /* assign main_system_bus before qbus_create_inplace()
- * in order to make "if (bus != main_system_bus)" work */
- main_system_bus = g_malloc0(system_bus_info.size);
- main_system_bus->qdev_allocated = 1;
- qbus_create_inplace(main_system_bus, &system_bus_info, NULL,
- "main-system-bus");
-}
-
void qbus_free(BusState *bus)
{
DeviceState *dev;
@@ -453,7 +431,7 @@ void qbus_free(BusState *bus)
QLIST_REMOVE(bus, sibling);
bus->parent->num_child_bus--;
} else {
- assert(bus != main_system_bus); /* main_system_bus is never freed */
+ assert(bus != sysbus_get_default()); /* main_system_bus is never freed
*/
qemu_unregister_reset(qbus_reset_all_fn, bus);
}
g_free((void*)bus->name);
diff --git a/hw/sysbus.c b/hw/sysbus.c
index db4efcc..fe5c421 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -256,6 +256,27 @@ static TypeInfo sysbus_device_type_info = {
.class_init = sysbus_device_class_init,
};
+/* This is a nasty hack to allow passing a NULL bus to qdev_create. */
+static BusState *main_system_bus;
+
+static void main_system_bus_create(void)
+{
+ /* assign main_system_bus before qbus_create_inplace()
+ * in order to make "if (bus != sysbus_get_default())" work */
+ main_system_bus = g_malloc0(system_bus_info.size);
+ main_system_bus->qdev_allocated = 1;
+ qbus_create_inplace(main_system_bus, &system_bus_info, NULL,
+ "main-system-bus");
+}
+
+BusState *sysbus_get_default(void)
+{
+ if (!main_system_bus) {
+ main_system_bus_create();
+ }
+ return main_system_bus;
+}
+
static void sysbus_register_types(void)
{
type_register_static(&sysbus_device_type_info);
--
1.7.7
- [Qemu-devel] [PULL] qom-next queue, second batch: QBus, API additions and cleanups, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 05/22] qom: Make Object a type, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 01/22] qom: Add object_class_get_parent(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 09/22] arm_l2x0: Rename "type" property to "cache-type", Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 03/22] qom: Add object_child_foreach(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 16/22] qdev: Move SysBus initialization to sysbus.c,
Andreas Färber <=
- [Qemu-devel] [PATCH 20/22] qbus: Initialize in standard way, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 07/22] qom: Assert that public types have a non-NULL parent field, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 18/22] qdev: Connect busses with their parent devices, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 04/22] qom: Add class_base_init, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 08/22] m48t59: Rename "type" property to "model", Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 22/22] qom: Push error reporting to object_property_find(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 10/22] qdev: Push "type" property up to Object, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 06/22] qom: Drop type_register_static_alias() macro, Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 02/22] qom: Introduce object_property_is_{child, link}(), Andreas Färber, 2012/06/18
- [Qemu-devel] [PATCH 11/22] qdev: Move bus properties to a separate global, Andreas Färber, 2012/06/18