2013-07-16 09:04:04 +02:00
|
|
|
/*
|
2014-04-17 15:59:48 +02:00
|
|
|
* QEMU S390x floating interrupt controller (flic)
|
2013-07-16 09:04:04 +02:00
|
|
|
*
|
|
|
|
* Copyright 2014 IBM Corp.
|
|
|
|
* Author(s): Jens Freimann <jfrei@linux.vnet.ibm.com>
|
2014-04-17 15:59:48 +02:00
|
|
|
* Cornelia Huck <cornelia.huck@de.ibm.com>
|
2013-07-16 09:04:04 +02:00
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:19 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-07-16 09:04:04 +02:00
|
|
|
#include "qemu/error-report.h"
|
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/s390x/s390_flic.h"
|
|
|
|
#include "trace.h"
|
2016-12-09 13:51:46 +01:00
|
|
|
#include "hw/qdev.h"
|
|
|
|
#include "qapi/error.h"
|
2013-07-16 09:04:04 +02:00
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
S390FLICState *s390_get_flic(void)
|
2013-09-05 13:54:39 +02:00
|
|
|
{
|
2017-03-17 10:28:30 +01:00
|
|
|
static S390FLICState *fs;
|
2013-09-05 13:54:39 +02:00
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
if (!fs) {
|
2017-03-17 10:28:30 +01:00
|
|
|
fs = S390_FLIC_COMMON(object_resolve_path(TYPE_KVM_S390_FLIC, NULL));
|
|
|
|
if (!fs) {
|
|
|
|
fs = S390_FLIC_COMMON(object_resolve_path(TYPE_QEMU_S390_FLIC,
|
|
|
|
NULL));
|
|
|
|
}
|
2013-09-05 13:54:39 +02:00
|
|
|
}
|
2014-04-17 15:59:48 +02:00
|
|
|
return fs;
|
2013-09-05 13:54:39 +02:00
|
|
|
}
|
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
void s390_flic_init(void)
|
2013-07-16 09:04:04 +02:00
|
|
|
{
|
2014-04-17 15:59:48 +02:00
|
|
|
DeviceState *dev;
|
2013-07-16 09:04:04 +02:00
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
dev = s390_flic_kvm_create();
|
|
|
|
if (!dev) {
|
|
|
|
dev = qdev_create(NULL, TYPE_QEMU_S390_FLIC);
|
|
|
|
object_property_add_child(qdev_get_machine(), TYPE_QEMU_S390_FLIC,
|
|
|
|
OBJECT(dev), NULL);
|
2013-07-16 09:04:04 +02:00
|
|
|
}
|
2015-02-05 10:34:49 +01:00
|
|
|
qdev_init_nofail(dev);
|
2013-07-16 09:04:04 +02:00
|
|
|
}
|
|
|
|
|
2013-07-15 17:45:03 +02:00
|
|
|
static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
|
|
|
|
uint8_t isc, bool swap,
|
|
|
|
bool is_maskable)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-15 17:45:03 +02:00
|
|
|
static int qemu_s390_io_adapter_map(S390FLICState *fs, uint32_t id,
|
|
|
|
uint64_t map_addr, bool do_map)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qemu_s390_add_adapter_routes(S390FLICState *fs,
|
|
|
|
AdapterRoutes *routes)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qemu_s390_release_adapter_routes(S390FLICState *fs,
|
|
|
|
AdapterRoutes *routes)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-27 13:03:44 +01:00
|
|
|
static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
|
|
|
|
uint16_t subchannel_nr)
|
|
|
|
{
|
|
|
|
/* Fixme TCG */
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
2013-07-15 17:45:03 +02:00
|
|
|
static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
|
|
|
|
|
|
|
|
fsc->register_io_adapter = qemu_s390_register_io_adapter;
|
2013-07-15 17:45:03 +02:00
|
|
|
fsc->io_adapter_map = qemu_s390_io_adapter_map;
|
|
|
|
fsc->add_adapter_routes = qemu_s390_add_adapter_routes;
|
|
|
|
fsc->release_adapter_routes = qemu_s390_release_adapter_routes;
|
2016-01-27 13:03:44 +01:00
|
|
|
fsc->clear_io_irq = qemu_s390_clear_io_flic;
|
2013-07-15 17:45:03 +02:00
|
|
|
}
|
|
|
|
|
2016-12-09 13:51:46 +01:00
|
|
|
static Property s390_flic_common_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("adapter_routes_max_batch", S390FLICState,
|
|
|
|
adapter_routes_max_batch, ADAPTER_ROUTES_MAX_GSI),
|
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void s390_flic_common_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
|
|
|
uint32_t max_batch = S390_FLIC_COMMON(dev)->adapter_routes_max_batch;
|
|
|
|
|
|
|
|
if (max_batch > ADAPTER_ROUTES_MAX_GSI) {
|
|
|
|
error_setg(errp, "flic adapter_routes_max_batch too big"
|
|
|
|
"%d (%d allowed)", max_batch, ADAPTER_ROUTES_MAX_GSI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void s390_flic_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
|
|
|
|
dc->props = s390_flic_common_properties;
|
|
|
|
dc->realize = s390_flic_common_realize;
|
|
|
|
}
|
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
static const TypeInfo qemu_s390_flic_info = {
|
|
|
|
.name = TYPE_QEMU_S390_FLIC,
|
|
|
|
.parent = TYPE_S390_FLIC_COMMON,
|
|
|
|
.instance_size = sizeof(QEMUS390FLICState),
|
2013-07-15 17:45:03 +02:00
|
|
|
.class_init = qemu_s390_flic_class_init,
|
2014-04-17 15:59:48 +02:00
|
|
|
};
|
2013-07-16 09:04:04 +02:00
|
|
|
|
2016-12-09 13:51:46 +01:00
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
static const TypeInfo s390_flic_common_info = {
|
|
|
|
.name = TYPE_S390_FLIC_COMMON,
|
2013-07-16 09:04:04 +02:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
2014-04-17 15:59:48 +02:00
|
|
|
.instance_size = sizeof(S390FLICState),
|
2016-12-09 13:51:46 +01:00
|
|
|
.class_init = s390_flic_class_init,
|
2014-04-17 15:59:48 +02:00
|
|
|
.class_size = sizeof(S390FLICStateClass),
|
2013-07-16 09:04:04 +02:00
|
|
|
};
|
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
static void qemu_s390_flic_register_types(void)
|
2013-07-16 09:04:04 +02:00
|
|
|
{
|
2014-04-17 15:59:48 +02:00
|
|
|
type_register_static(&s390_flic_common_info);
|
|
|
|
type_register_static(&qemu_s390_flic_info);
|
2013-07-16 09:04:04 +02:00
|
|
|
}
|
|
|
|
|
2014-04-17 15:59:48 +02:00
|
|
|
type_init(qemu_s390_flic_register_types)
|