]> git.proxmox.com Git - mirror_qemu.git/blame - hw/s390x/ap-bridge.c
Revert "vl: Fix to create migration object before block backends again"
[mirror_qemu.git] / hw / s390x / ap-bridge.c
CommitLineData
a51b3153
TK
1/*
2 * ap bridge
3 *
4 * Copyright 2018 IBM Corp.
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or (at
7 * your option) any later version. See the COPYING file in the top-level
8 * directory.
9 */
10#include "qemu/osdep.h"
11#include "qapi/error.h"
12#include "hw/sysbus.h"
13#include "qemu/bitops.h"
14#include "hw/s390x/ap-bridge.h"
15#include "cpu.h"
16
17static char *ap_bus_get_dev_path(DeviceState *dev)
18{
19 /* at most one */
20 return g_strdup_printf("/1");
21}
22
23static void ap_bus_class_init(ObjectClass *oc, void *data)
24{
25 BusClass *k = BUS_CLASS(oc);
26
27 k->get_dev_path = ap_bus_get_dev_path;
28 /* More than one ap device does not make sense */
29 k->max_dev = 1;
30}
31
32static const TypeInfo ap_bus_info = {
33 .name = TYPE_AP_BUS,
34 .parent = TYPE_BUS,
35 .instance_size = 0,
36 .class_init = ap_bus_class_init,
37};
38
39void s390_init_ap(void)
40{
41 DeviceState *dev;
374b78e3 42 BusState *bus;
a51b3153
TK
43
44 /* If no AP instructions then no need for AP bridge */
45 if (!s390_has_feat(S390_FEAT_AP)) {
46 return;
47 }
48
49 /* Create bridge device */
50 dev = qdev_create(NULL, TYPE_AP_BRIDGE);
51 object_property_add_child(qdev_get_machine(), TYPE_AP_BRIDGE,
52 OBJECT(dev), NULL);
53 qdev_init_nofail(dev);
54
55 /* Create bus on bridge device */
374b78e3
TK
56 bus = qbus_create(TYPE_AP_BUS, dev, TYPE_AP_BUS);
57
58 /* Enable hotplugging */
59 qbus_set_hotplug_handler(bus, OBJECT(dev), &error_abort);
a51b3153
TK
60 }
61
62static void ap_bridge_class_init(ObjectClass *oc, void *data)
63{
64 DeviceClass *dc = DEVICE_CLASS(oc);
374b78e3 65 HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
a51b3153 66
374b78e3 67 hc->unplug = qdev_simple_device_unplug_cb;
a51b3153
TK
68 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
69}
70
71static const TypeInfo ap_bridge_info = {
72 .name = TYPE_AP_BRIDGE,
73 .parent = TYPE_SYS_BUS_DEVICE,
74 .instance_size = 0,
75 .class_init = ap_bridge_class_init,
374b78e3
TK
76 .interfaces = (InterfaceInfo[]) {
77 { TYPE_HOTPLUG_HANDLER },
78 { }
79 }
a51b3153
TK
80};
81
82static void ap_register(void)
83{
84 type_register_static(&ap_bridge_info);
85 type_register_static(&ap_bus_info);
86}
87
88type_init(ap_register)