2 * css bridge implementation
4 * Copyright 2012,2016 IBM Corp.
5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6 * Pierre Morel <pmorel@linux.vnet.ibm.com>
8 * This work is licensed under the terms of the GNU GPL, version 2 or (at
9 * your option) any later version. See the COPYING file in the top-level
12 #include "qemu/osdep.h"
13 #include "qapi/error.h"
14 #include "hw/hotplug.h"
15 #include "hw/sysbus.h"
16 #include "qemu/bitops.h"
17 #include "hw/s390x/css.h"
18 #include "ccw-device.h"
19 #include "hw/s390x/css-bridge.h"
22 * Invoke device-specific unplug handler, disable the subchannel
23 * (including sending a channel report to the guest) and remove the
24 * device from the virtual css bus.
26 static void ccw_device_unplug(HotplugHandler
*hotplug_dev
,
27 DeviceState
*dev
, Error
**errp
)
29 CcwDevice
*ccw_dev
= CCW_DEVICE(dev
);
30 CCWDeviceClass
*k
= CCW_DEVICE_GET_CLASS(ccw_dev
);
31 SubchDev
*sch
= ccw_dev
->sch
;
35 k
->unplug(hotplug_dev
, dev
, &err
);
37 error_propagate(errp
, err
);
43 * We should arrive here only for device_del, since we don't support
44 * direct hot(un)plug of channels.
47 /* Subchannel is now disabled and no longer valid. */
48 sch
->curr_status
.pmcw
.flags
&= ~(PMCW_FLAGS_MASK_ENA
|
51 css_generate_sch_crws(sch
->cssid
, sch
->ssid
, sch
->schid
, 1, 0);
53 object_unparent(OBJECT(dev
));
56 static void virtual_css_bus_reset(BusState
*qbus
)
58 /* This should actually be modelled via the generic css */
62 static void virtual_css_bus_class_init(ObjectClass
*klass
, void *data
)
64 BusClass
*k
= BUS_CLASS(klass
);
66 k
->reset
= virtual_css_bus_reset
;
69 static const TypeInfo virtual_css_bus_info
= {
70 .name
= TYPE_VIRTUAL_CSS_BUS
,
72 .instance_size
= sizeof(VirtualCssBus
),
73 .class_init
= virtual_css_bus_class_init
,
76 VirtualCssBus
*virtual_css_bus_init(void)
82 /* Create bridge device */
83 dev
= qdev_create(NULL
, TYPE_VIRTUAL_CSS_BRIDGE
);
84 qdev_init_nofail(dev
);
86 /* Create bus on bridge device */
87 bus
= qbus_create(TYPE_VIRTUAL_CSS_BUS
, dev
, "virtual-css");
88 cbus
= VIRTUAL_CSS_BUS(bus
);
90 /* Enable hotplugging */
91 qbus_set_hotplug_handler(bus
, dev
, &error_abort
);
96 /***************** Virtual-css Bus Bridge Device ********************/
98 static void virtual_css_bridge_class_init(ObjectClass
*klass
, void *data
)
100 HotplugHandlerClass
*hc
= HOTPLUG_HANDLER_CLASS(klass
);
101 DeviceClass
*dc
= DEVICE_CLASS(klass
);
103 hc
->unplug
= ccw_device_unplug
;
104 set_bit(DEVICE_CATEGORY_BRIDGE
, dc
->categories
);
107 static const TypeInfo virtual_css_bridge_info
= {
108 .name
= TYPE_VIRTUAL_CSS_BRIDGE
,
109 .parent
= TYPE_SYS_BUS_DEVICE
,
110 .instance_size
= sizeof(SysBusDevice
),
111 .class_init
= virtual_css_bridge_class_init
,
112 .interfaces
= (InterfaceInfo
[]) {
113 { TYPE_HOTPLUG_HANDLER
},
118 static void virtual_css_register(void)
120 type_register_static(&virtual_css_bridge_info
);
121 type_register_static(&virtual_css_bus_info
);
124 type_init(virtual_css_register
)