1 /* 2 * QEMU S390x floating interrupt controller (flic) 3 * 4 * Copyright 2014 IBM Corp. 5 * Author(s): Jens Freimann <jfrei@linux.vnet.ibm.com> 6 * Cornelia Huck <cornelia.huck@de.ibm.com> 7 * 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 10 * directory. 11 */ 12 13 #include "qemu/osdep.h" 14 #include "qemu/error-report.h" 15 #include "hw/sysbus.h" 16 #include "migration/qemu-file.h" 17 #include "hw/s390x/s390_flic.h" 18 #include "trace.h" 19 #include "hw/qdev.h" 20 #include "qapi/error.h" 21 22 S390FLICState *s390_get_flic(void) 23 { 24 static S390FLICState *fs; 25 26 if (!fs) { 27 fs = S390_FLIC_COMMON(object_resolve_path(TYPE_KVM_S390_FLIC, NULL)); 28 if (!fs) { 29 fs = S390_FLIC_COMMON(object_resolve_path(TYPE_QEMU_S390_FLIC, 30 NULL)); 31 } 32 } 33 return fs; 34 } 35 36 void s390_flic_init(void) 37 { 38 DeviceState *dev; 39 40 dev = s390_flic_kvm_create(); 41 if (!dev) { 42 dev = qdev_create(NULL, TYPE_QEMU_S390_FLIC); 43 object_property_add_child(qdev_get_machine(), TYPE_QEMU_S390_FLIC, 44 OBJECT(dev), NULL); 45 } 46 qdev_init_nofail(dev); 47 } 48 49 static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id, 50 uint8_t isc, bool swap, 51 bool is_maskable) 52 { 53 /* nothing to do */ 54 return 0; 55 } 56 57 static int qemu_s390_io_adapter_map(S390FLICState *fs, uint32_t id, 58 uint64_t map_addr, bool do_map) 59 { 60 /* nothing to do */ 61 return 0; 62 } 63 64 static int qemu_s390_add_adapter_routes(S390FLICState *fs, 65 AdapterRoutes *routes) 66 { 67 return -ENOSYS; 68 } 69 70 static void qemu_s390_release_adapter_routes(S390FLICState *fs, 71 AdapterRoutes *routes) 72 { 73 } 74 75 static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id, 76 uint16_t subchannel_nr) 77 { 78 /* Fixme TCG */ 79 return -ENOSYS; 80 } 81 82 static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) 83 { 84 S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc); 85 86 fsc->register_io_adapter = qemu_s390_register_io_adapter; 87 fsc->io_adapter_map = qemu_s390_io_adapter_map; 88 fsc->add_adapter_routes = qemu_s390_add_adapter_routes; 89 fsc->release_adapter_routes = qemu_s390_release_adapter_routes; 90 fsc->clear_io_irq = qemu_s390_clear_io_flic; 91 } 92 93 static Property s390_flic_common_properties[] = { 94 DEFINE_PROP_UINT32("adapter_routes_max_batch", S390FLICState, 95 adapter_routes_max_batch, ADAPTER_ROUTES_MAX_GSI), 96 DEFINE_PROP_END_OF_LIST(), 97 }; 98 99 static void s390_flic_common_realize(DeviceState *dev, Error **errp) 100 { 101 uint32_t max_batch = S390_FLIC_COMMON(dev)->adapter_routes_max_batch; 102 103 if (max_batch > ADAPTER_ROUTES_MAX_GSI) { 104 error_setg(errp, "flic adapter_routes_max_batch too big" 105 "%d (%d allowed)", max_batch, ADAPTER_ROUTES_MAX_GSI); 106 } 107 } 108 109 static void s390_flic_class_init(ObjectClass *oc, void *data) 110 { 111 DeviceClass *dc = DEVICE_CLASS(oc); 112 113 dc->props = s390_flic_common_properties; 114 dc->realize = s390_flic_common_realize; 115 } 116 117 static const TypeInfo qemu_s390_flic_info = { 118 .name = TYPE_QEMU_S390_FLIC, 119 .parent = TYPE_S390_FLIC_COMMON, 120 .instance_size = sizeof(QEMUS390FLICState), 121 .class_init = qemu_s390_flic_class_init, 122 }; 123 124 125 static const TypeInfo s390_flic_common_info = { 126 .name = TYPE_S390_FLIC_COMMON, 127 .parent = TYPE_SYS_BUS_DEVICE, 128 .instance_size = sizeof(S390FLICState), 129 .class_init = s390_flic_class_init, 130 .class_size = sizeof(S390FLICStateClass), 131 }; 132 133 static void qemu_s390_flic_register_types(void) 134 { 135 type_register_static(&s390_flic_common_info); 136 type_register_static(&qemu_s390_flic_info); 137 } 138 139 type_init(qemu_s390_flic_register_types) 140