2 * Virtio 9p PCI Bindings
4 * Copyright IBM, Corp. 2010
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
16 #include "qemu/osdep.h"
18 #include "virtio-pci.h"
19 #include "hw/9pfs/virtio-9p.h"
22 * virtio-9p-pci: This extends VirtioPCIProxy.
25 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci-base"
26 #define VIRTIO_9P_PCI(obj) \
27 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
29 typedef struct V9fsPCIState
{
30 VirtIOPCIProxy parent_obj
;
34 static void virtio_9p_pci_realize(VirtIOPCIProxy
*vpci_dev
, Error
**errp
)
36 V9fsPCIState
*dev
= VIRTIO_9P_PCI(vpci_dev
);
37 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
39 qdev_set_parent_bus(vdev
, BUS(&vpci_dev
->bus
));
40 object_property_set_bool(OBJECT(vdev
), true, "realized", errp
);
43 static Property virtio_9p_pci_properties
[] = {
44 DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy
, flags
,
45 VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT
, true),
46 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy
, nvectors
, 2),
47 DEFINE_PROP_END_OF_LIST(),
50 static void virtio_9p_pci_class_init(ObjectClass
*klass
, void *data
)
52 DeviceClass
*dc
= DEVICE_CLASS(klass
);
53 PCIDeviceClass
*pcidev_k
= PCI_DEVICE_CLASS(klass
);
54 VirtioPCIClass
*k
= VIRTIO_PCI_CLASS(klass
);
56 k
->realize
= virtio_9p_pci_realize
;
57 pcidev_k
->vendor_id
= PCI_VENDOR_ID_REDHAT_QUMRANET
;
58 pcidev_k
->device_id
= PCI_DEVICE_ID_VIRTIO_9P
;
59 pcidev_k
->revision
= VIRTIO_PCI_ABI_VERSION
;
60 pcidev_k
->class_id
= 0x2;
61 set_bit(DEVICE_CATEGORY_STORAGE
, dc
->categories
);
62 dc
->props
= virtio_9p_pci_properties
;
65 static void virtio_9p_pci_instance_init(Object
*obj
)
67 V9fsPCIState
*dev
= VIRTIO_9P_PCI(obj
);
69 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
73 static const VirtioPCIDeviceTypeInfo virtio_9p_pci_info
= {
74 .base_name
= TYPE_VIRTIO_9P_PCI
,
75 .generic_name
= "virtio-9p-pci",
76 .transitional_name
= "virtio-9p-pci-transitional",
77 .non_transitional_name
= "virtio-9p-pci-non-transitional",
78 .instance_size
= sizeof(V9fsPCIState
),
79 .instance_init
= virtio_9p_pci_instance_init
,
80 .class_init
= virtio_9p_pci_class_init
,
83 static void virtio_9p_pci_register(void)
85 virtio_pci_types_register(&virtio_9p_pci_info
);
88 type_init(virtio_9p_pci_register
)