s390_flic.c 1.7 KB
Newer Older
1
/*
2
 * QEMU S390x floating interrupt controller (flic)
3 4 5
 *
 * Copyright 2014 IBM Corp.
 * Author(s): Jens Freimann <jfrei@linux.vnet.ibm.com>
6
 *            Cornelia Huck <cornelia.huck@de.ibm.com>
7 8 9 10 11 12 13 14 15 16 17 18
 *
 * 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.
 */

#include "qemu/error-report.h"
#include "hw/sysbus.h"
#include "migration/qemu-file.h"
#include "hw/s390x/s390_flic.h"
#include "trace.h"

19
S390FLICState *s390_get_flic(void)
20
{
21
    S390FLICState *fs;
22

23 24 25
    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));
26
    }
27
    return fs;
28 29
}

30
void s390_flic_init(void)
31
{
32
    DeviceState *dev;
33 34
    int r;

35 36 37 38 39
    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);
40
    }
41 42 43
    r = qdev_init(dev);
    if (r) {
        error_report("flic: couldn't create qdev");
44 45 46
    }
}

47 48 49 50 51
static const TypeInfo qemu_s390_flic_info = {
    .name          = TYPE_QEMU_S390_FLIC,
    .parent        = TYPE_S390_FLIC_COMMON,
    .instance_size = sizeof(QEMUS390FLICState),
};
52

53 54
static const TypeInfo s390_flic_common_info = {
    .name          = TYPE_S390_FLIC_COMMON,
55
    .parent        = TYPE_SYS_BUS_DEVICE,
56 57
    .instance_size = sizeof(S390FLICState),
    .class_size    = sizeof(S390FLICStateClass),
58 59
};

60
static void qemu_s390_flic_register_types(void)
61
{
62 63
    type_register_static(&s390_flic_common_info);
    type_register_static(&qemu_s390_flic_info);
64 65
}

66
type_init(qemu_s390_flic_register_types)