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 S390FLICState *fs; 25 26 fs = S390_FLIC_COMMON(object_resolve_path(TYPE_KVM_S390_FLIC, NULL)); 27 if (!fs) { 28 fs = S390_FLIC_COMMON(object_resolve_path(TYPE_QEMU_S390_FLIC, NULL)); 29 } 30 return fs; 31 } 32 33 void s390_flic_init(void) 34 { 35 DeviceState *dev; 36 37 dev = s390_flic_kvm_create(); 38 if (!dev) { 39 dev = qdev_create(NULL, TYPE_QEMU_S390_FLIC); 40 object_property_add_child(qdev_get_machine(), TYPE_QEMU_S390_FLIC, 41 OBJECT(dev), NULL); 42 } 43 qdev_init_nofail(dev); 44 } 45 46 static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id, 47 uint8_t isc, bool swap, 48 bool is_maskable) 49 { 50 /* nothing to do */ 51 return 0; 52 } 53 54 static int qemu_s390_io_adapter_map(S390FLICState *fs, uint32_t id, 55 uint64_t map_addr, bool do_map) 56 { 57 /* nothing to do */ 58 return 0; 59 } 60 61 static int qemu_s390_add_adapter_routes(S390FLICState *fs, 62 AdapterRoutes *routes) 63 { 64 return -ENOSYS; 65 } 66 67 static void qemu_s390_release_adapter_routes(S390FLICState *fs, 68 AdapterRoutes *routes) 69 { 70 } 71 72 static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id, 73 uint16_t subchannel_nr) 74 { 75 /* Fixme TCG */ 76 return -ENOSYS; 77 } 78 79 static void qemu_s390_flic_class_init(ObjectClass *oc, void *data) 80 { 81 S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc); 82 83 fsc->register_io_adapter = qemu_s390_register_io_adapter; 84 fsc->io_adapter_map = qemu_s390_io_adapter_map; 85 fsc->add_adapter_routes = qemu_s390_add_adapter_routes; 86 fsc->release_adapter_routes = qemu_s390_release_adapter_routes; 87 fsc->clear_io_irq = qemu_s390_clear_io_flic; 88 } 89 90 static Property s390_flic_common_properties[] = { 91 DEFINE_PROP_UINT32("adapter_routes_max_batch", S390FLICState, 92 adapter_routes_max_batch, ADAPTER_ROUTES_MAX_GSI), 93 DEFINE_PROP_END_OF_LIST(), 94 }; 95 96 static void s390_flic_common_realize(DeviceState *dev, Error **errp) 97 { 98 uint32_t max_batch = S390_FLIC_COMMON(dev)->adapter_routes_max_batch; 99 100 if (max_batch > ADAPTER_ROUTES_MAX_GSI) { 101 error_setg(errp, "flic adapter_routes_max_batch too big" 102 "%d (%d allowed)", max_batch, ADAPTER_ROUTES_MAX_GSI); 103 } 104 } 105 106 static void s390_flic_class_init(ObjectClass *oc, void *data) 107 { 108 DeviceClass *dc = DEVICE_CLASS(oc); 109 110 dc->props = s390_flic_common_properties; 111 dc->realize = s390_flic_common_realize; 112 } 113 114 static const TypeInfo qemu_s390_flic_info = { 115 .name = TYPE_QEMU_S390_FLIC, 116 .parent = TYPE_S390_FLIC_COMMON, 117 .instance_size = sizeof(QEMUS390FLICState), 118 .class_init = qemu_s390_flic_class_init, 119 }; 120 121 122 static const TypeInfo s390_flic_common_info = { 123 .name = TYPE_S390_FLIC_COMMON, 124 .parent = TYPE_SYS_BUS_DEVICE, 125 .instance_size = sizeof(S390FLICState), 126 .class_init = s390_flic_class_init, 127 .class_size = sizeof(S390FLICStateClass), 128 }; 129 130 static void qemu_s390_flic_register_types(void) 131 { 132 type_register_static(&s390_flic_common_info); 133 type_register_static(&qemu_s390_flic_info); 134 } 135 136 type_init(qemu_s390_flic_register_types) 137