s390x: introduce 4.0 compat machine
[qemu.git] / hw / s390x / ap-bridge.c
blob3795d30dd7c93960644d1feed7341ef4516a6541
1 /*
2 * ap bridge
4 * Copyright 2018 IBM Corp.
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"
17 static char *ap_bus_get_dev_path(DeviceState *dev)
19 /* at most one */
20 return g_strdup_printf("/1");
23 static void ap_bus_class_init(ObjectClass *oc, void *data)
25 BusClass *k = BUS_CLASS(oc);
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;
32 static 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,
39 void s390_init_ap(void)
41 DeviceState *dev;
43 /* If no AP instructions then no need for AP bridge */
44 if (!s390_has_feat(S390_FEAT_AP)) {
45 return;
48 /* Create bridge device */
49 dev = qdev_create(NULL, TYPE_AP_BRIDGE);
50 object_property_add_child(qdev_get_machine(), TYPE_AP_BRIDGE,
51 OBJECT(dev), NULL);
52 qdev_init_nofail(dev);
54 /* Create bus on bridge device */
55 qbus_create(TYPE_AP_BUS, dev, TYPE_AP_BUS);
58 static void ap_bridge_class_init(ObjectClass *oc, void *data)
60 DeviceClass *dc = DEVICE_CLASS(oc);
62 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
65 static const TypeInfo ap_bridge_info = {
66 .name = TYPE_AP_BRIDGE,
67 .parent = TYPE_SYS_BUS_DEVICE,
68 .instance_size = 0,
69 .class_init = ap_bridge_class_init,
72 static void ap_register(void)
74 type_register_static(&ap_bridge_info);
75 type_register_static(&ap_bus_info);
78 type_init(ap_register)