From: Jing Liu
Currently, common base layers virtual css bridge and bus are
defined in hw/s390x/virtio-ccw.c(h). In order to support
multiple types of devices in the virtual channel subsystem,
especially non virtio-ccw, refactoring work needs to be done.
This work is just a pure code move without any functional change
except dropping an empty function virtual_css_bridge_init() and
virtio_ccw_busdev_unplug() changing. virtio_ccw_busdev_unplug()
is specific to virtio-ccw but gets referenced from the common
virtual css bridge code. To keep the functional changes to a
minimum we export this function from virtio-ccw.c and continue
to reference it inside virtual_css_bridge_class_init()
(now living in hw/s390x/css-bridge.c). A follow-up patch will
clean this up.
Signed-off-by: Jing Liu
Reviewed-by: Sascha Silbe
Reviewed-by: Dong Jia Shi
Signed-off-by: Cornelia Huck
---
hw/s390x/Makefile.objs| 1 +
hw/s390x/css-bridge.c | 89 +++
hw/s390x/s390-virtio-ccw.c| 1 +
hw/s390x/virtio-ccw.c | 79 ++
hw/s390x/virtio-ccw.h | 14 +--
include/hw/s390x/css-bridge.h | 31 +++
6 files changed, 127 insertions(+), 88 deletions(-)
create mode 100644 hw/s390x/css-bridge.c
create mode 100644 include/hw/s390x/css-bridge.h
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
index 2203617..141ce1a 100644
--- a/hw/s390x/Makefile.objs
+++ b/hw/s390x/Makefile.objs
@@ -8,6 +8,7 @@ obj-y += ipl.o
obj-y += css.o
obj-y += s390-virtio-ccw.o
obj-y += virtio-ccw.o
+obj-y += css-bridge.o
obj-y += s390-pci-bus.o s390-pci-inst.o
obj-y += s390-skeys.o
obj-$(CONFIG_KVM) += s390-skeys-kvm.o
diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c
new file mode 100644
index 000..e74cc1c
--- /dev/null
+++ b/hw/s390x/css-bridge.c
@@ -0,0 +1,89 @@
+/*
+ * css bridge implementation
+ *
+ * Copyright 2012,2016 IBM Corp.
+ * Author(s): Cornelia Huck
+ *Pierre Morel
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "virtio-ccw.h"
+#include "hw/hotplug.h"
+#include "hw/sysbus.h"
+#include "qemu/bitops.h"
+#include "hw/s390x/css.h"
+#include "hw/s390x/css-bridge.h"
+
+static void virtual_css_bus_reset(BusState *qbus)
+{
+/* This should actually be modelled via the generic css */
+css_reset();
+}
+
+static void virtual_css_bus_class_init(ObjectClass *klass, void *data)
+{
+BusClass *k = BUS_CLASS(klass);
+
+k->reset = virtual_css_bus_reset;
+}
+
+static const TypeInfo virtual_css_bus_info = {
+.name = TYPE_VIRTUAL_CSS_BUS,
+.parent = TYPE_BUS,
+.instance_size = sizeof(VirtualCssBus),
+.class_init = virtual_css_bus_class_init,
+};
+
+VirtualCssBus *virtual_css_bus_init(void)
+{
+VirtualCssBus *cbus;
+BusState *bus;
+DeviceState *dev;
+
+/* Create bridge device */
+dev = qdev_create(NULL, TYPE_VIRTUAL_CSS_BRIDGE);
+qdev_init_nofail(dev);
+
+/* Create bus on bridge device */
+bus = qbus_create(TYPE_VIRTUAL_CSS_BUS, dev, "virtual-css");
+cbus = VIRTUAL_CSS_BUS(bus);
+
+/* Enable hotplugging */
+qbus_set_hotplug_handler(bus, dev, _abort);
+
+return cbus;
+ }
+
+/* Virtual-css Bus Bridge Device /
+
+static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
+{
+HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+DeviceClass *dc = DEVICE_CLASS(klass);
+
+hc->unplug = virtio_ccw_busdev_unplug;
+set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+}
+
+static const TypeInfo virtual_css_bridge_info = {
+.name = TYPE_VIRTUAL_CSS_BRIDGE,
+.parent= TYPE_SYS_BUS_DEVICE,
+.instance_size = sizeof(SysBusDevice),
+.class_init= virtual_css_bridge_class_init,
+.interfaces = (InterfaceInfo[]) {
+{ TYPE_HOTPLUG_HANDLER },
+{ }
+}
+};
+
+static void virtual_css_register(void)
+{
+type_register_static(_css_bridge_info);
+type_register_static(_css_bus_info);
+}
+
+type_init(virtual_css_register)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 3b79e96..caf0a68 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -27,6 +27,7 @@
#include "hw/compat.h"
#include "ipl.h"
#include "hw/s390x/s390-virtio-ccw.h"
+#include "hw/s390x/css-bridge.h"
static const char *const reset_dev_types[] = {
TYPE_VIRTUAL_CSS_BRIDGE,
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 0afc0d3..8f1a0e8 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -33,31 +33,11 @@