aboutsummaryrefslogtreecommitdiff
path: root/hw/sysbus.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-05-02 12:06:55 +0200
committerAndreas Färber <afaerber@suse.de>2012-06-18 15:14:38 +0200
commit8185d21639ab749979445734ec671122aa96e805 (patch)
tree3864a9d2837a5c43ed3e7230a671e5af4f01a005 /hw/sysbus.c
parent09e5ab6360ce78fc0acbfe29ac100f8148397ca6 (diff)
qdev: Move SysBus initialization to sysbus.c
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 <pbonzini@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/sysbus.c')
-rw-r--r--hw/sysbus.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/hw/sysbus.c b/hw/sysbus.c
index db4efccef4..fe5c4212ff 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);