17a8d15d7SEric Auger /*
27a8d15d7SEric Auger * calxeda xgmac VFIO device
37a8d15d7SEric Auger *
47a8d15d7SEric Auger * Copyright Linaro Limited, 2014
57a8d15d7SEric Auger *
67a8d15d7SEric Auger * Authors:
77a8d15d7SEric Auger * Eric Auger <eric.auger@linaro.org>
87a8d15d7SEric Auger *
97a8d15d7SEric Auger * This work is licensed under the terms of the GNU GPL, version 2. See
107a8d15d7SEric Auger * the COPYING file in the top-level directory.
117a8d15d7SEric Auger *
127a8d15d7SEric Auger */
137a8d15d7SEric Auger
14c6eacb1aSPeter Maydell #include "qemu/osdep.h"
157a8d15d7SEric Auger #include "hw/vfio/vfio-calxeda-xgmac.h"
16*d6454270SMarkus Armbruster #include "migration/vmstate.h"
170b8fa32fSMarkus Armbruster #include "qemu/module.h"
187a8d15d7SEric Auger
calxeda_xgmac_realize(DeviceState * dev,Error ** errp)197a8d15d7SEric Auger static void calxeda_xgmac_realize(DeviceState *dev, Error **errp)
207a8d15d7SEric Auger {
217a8d15d7SEric Auger VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(dev);
227a8d15d7SEric Auger VFIOCalxedaXgmacDeviceClass *k = VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(dev);
237a8d15d7SEric Auger
247a8d15d7SEric Auger vdev->compat = g_strdup("calxeda,hb-xgmac");
25a49531ebSEric Auger vdev->num_compat = 1;
267a8d15d7SEric Auger
277a8d15d7SEric Auger k->parent_realize(dev, errp);
287a8d15d7SEric Auger }
297a8d15d7SEric Auger
307a8d15d7SEric Auger static const VMStateDescription vfio_platform_calxeda_xgmac_vmstate = {
31da56e330SLi Qiang .name = "vfio-calxeda-xgmac",
327a8d15d7SEric Auger .unmigratable = 1,
337a8d15d7SEric Auger };
347a8d15d7SEric Auger
vfio_calxeda_xgmac_class_init(ObjectClass * klass,void * data)357a8d15d7SEric Auger static void vfio_calxeda_xgmac_class_init(ObjectClass *klass, void *data)
367a8d15d7SEric Auger {
377a8d15d7SEric Auger DeviceClass *dc = DEVICE_CLASS(klass);
387a8d15d7SEric Auger VFIOCalxedaXgmacDeviceClass *vcxc =
397a8d15d7SEric Auger VFIO_CALXEDA_XGMAC_DEVICE_CLASS(klass);
40bf853881SPhilippe Mathieu-Daudé device_class_set_parent_realize(dc, calxeda_xgmac_realize,
41bf853881SPhilippe Mathieu-Daudé &vcxc->parent_realize);
427a8d15d7SEric Auger dc->desc = "VFIO Calxeda XGMAC";
437a8d15d7SEric Auger dc->vmsd = &vfio_platform_calxeda_xgmac_vmstate;
44e4f4fb1eSEduardo Habkost /* Supported by TYPE_VIRT_MACHINE */
45e4f4fb1eSEduardo Habkost dc->user_creatable = true;
467a8d15d7SEric Auger }
477a8d15d7SEric Auger
487a8d15d7SEric Auger static const TypeInfo vfio_calxeda_xgmac_dev_info = {
497a8d15d7SEric Auger .name = TYPE_VFIO_CALXEDA_XGMAC,
507a8d15d7SEric Auger .parent = TYPE_VFIO_PLATFORM,
517a8d15d7SEric Auger .instance_size = sizeof(VFIOCalxedaXgmacDevice),
527a8d15d7SEric Auger .class_init = vfio_calxeda_xgmac_class_init,
537a8d15d7SEric Auger .class_size = sizeof(VFIOCalxedaXgmacDeviceClass),
547a8d15d7SEric Auger };
557a8d15d7SEric Auger
register_calxeda_xgmac_dev_type(void)567a8d15d7SEric Auger static void register_calxeda_xgmac_dev_type(void)
577a8d15d7SEric Auger {
587a8d15d7SEric Auger type_register_static(&vfio_calxeda_xgmac_dev_info);
597a8d15d7SEric Auger }
607a8d15d7SEric Auger
617a8d15d7SEric Auger type_init(register_calxeda_xgmac_dev_type)
62