xref: /openbmc/qemu/hw/vfio/calxeda-xgmac.c (revision 1be82d89)
1 /*
2  * calxeda xgmac VFIO device
3  *
4  * Copyright Linaro Limited, 2014
5  *
6  * Authors:
7  *  Eric Auger <eric.auger@linaro.org>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  *
12  */
13 
14 #include "qemu/osdep.h"
15 #include "hw/vfio/vfio-calxeda-xgmac.h"
16 
17 static void calxeda_xgmac_realize(DeviceState *dev, Error **errp)
18 {
19     VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
20     VFIOCalxedaXgmacDeviceClass *k = VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(dev);
21 
22     vdev->compat = g_strdup("calxeda,hb-xgmac");
23     vdev->num_compat = 1;
24 
25     k->parent_realize(dev, errp);
26 }
27 
28 static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = {
29     .name = TYPE_VFIO_CALXEDA_XGMAC,
30     .unmigratable = 1,
31 };
32 
33 static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data)
34 {
35     DeviceClass *dc = DEVICE_CLASS(klass);
36     VFIOCalxedaXgmacDeviceClass *vcxc =
37         VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass);
38     device_class_set_parent_realize(dc, calxeda_xgmac_realize,
39                                     &vcxc->parent_realize);
40     dc->desc = "VFIO Calxeda XGMAC";
41     dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate;
42     /* Supported by TYPE_VIRT_MACHINE */
43     dc->user_creatable = true;
44 }
45 
46 static const TypeInfo vfio_calxeda_xgmac_dev_info = {
47     .name = TYPE_VFIO_CALXEDA_XGMAC,
48     .parent = TYPE_VFIO_PLATFORM,
49     .instance_size = sizeof(VFIOCalxedaXgmacDevice),
50     .class_init = vfio_calxeda_xgmac_class_init,
51     .class_size = sizeof(VFIOCalxedaXgmacDeviceClass),
52 };
53 
54 static void register_calxeda_xgmac_dev_type(void)
55 {
56     type_register_static(&vfio_calxeda_xgmac_dev_info);
57 }
58 
59 type_init(register_calxeda_xgmac_dev_type)
60