]> git.proxmox.com Git - mirror_qemu.git/blame - hw/virtio/virtio-9p-pci.c
hw/arm/bcm2836: Introduce BCM283XClass::core_count
[mirror_qemu.git] / hw / virtio / virtio-9p-pci.c
CommitLineData
ddac19f5
JQ
1/*
2 * Virtio 9p PCI Bindings
3 *
4 * Copyright IBM, Corp. 2010
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
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 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
14 */
15
16#include "qemu/osdep.h"
17
18#include "virtio-pci.h"
19#include "hw/9pfs/virtio-9p.h"
a27bd6c7 20#include "hw/qdev-properties.h"
0b8fa32f 21#include "qemu/module.h"
db1015e9 22#include "qom/object.h"
ddac19f5
JQ
23
24/*
25 * virtio-9p-pci: This extends VirtioPCIProxy.
26 */
27
28#define TYPE_VIRTIO_9P_PCI "virtio-9p-pci-base"
db1015e9 29typedef struct V9fsPCIState V9fsPCIState;
8110fa1d
EH
30DECLARE_INSTANCE_CHECKER(V9fsPCIState, VIRTIO_9P_PCI,
31 TYPE_VIRTIO_9P_PCI)
ddac19f5 32
db1015e9 33struct V9fsPCIState {
ddac19f5
JQ
34 VirtIOPCIProxy parent_obj;
35 V9fsVirtioState vdev;
db1015e9 36};
ddac19f5
JQ
37
38static void virtio_9p_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
39{
40 V9fsPCIState *dev = VIRTIO_9P_PCI(vpci_dev);
41 DeviceState *vdev = DEVICE(&dev->vdev);
42
99ba777e 43 qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
ddac19f5
JQ
44}
45
46static Property virtio_9p_pci_properties[] = {
47 DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
48 VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
49 DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
50 DEFINE_PROP_END_OF_LIST(),
51};
52
53static void virtio_9p_pci_class_init(ObjectClass *klass, void *data)
54{
55 DeviceClass *dc = DEVICE_CLASS(klass);
56 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
57 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
58
59 k->realize = virtio_9p_pci_realize;
60 pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
61 pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_9P;
62 pcidev_k->revision = VIRTIO_PCI_ABI_VERSION;
63 pcidev_k->class_id = 0x2;
64 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
4f67d30b 65 device_class_set_props(dc, virtio_9p_pci_properties);
ddac19f5
JQ
66}
67
68static void virtio_9p_pci_instance_init(Object *obj)
69{
70 V9fsPCIState *dev = VIRTIO_9P_PCI(obj);
71
72 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
73 TYPE_VIRTIO_9P);
74}
75
76static const VirtioPCIDeviceTypeInfo virtio_9p_pci_info = {
77 .base_name = TYPE_VIRTIO_9P_PCI,
78 .generic_name = "virtio-9p-pci",
79 .transitional_name = "virtio-9p-pci-transitional",
80 .non_transitional_name = "virtio-9p-pci-non-transitional",
81 .instance_size = sizeof(V9fsPCIState),
82 .instance_init = virtio_9p_pci_instance_init,
83 .class_init = virtio_9p_pci_class_init,
84};
85
86static void virtio_9p_pci_register(void)
87{
88 virtio_pci_types_register(&virtio_9p_pci_info);
89}
90
91type_init(virtio_9p_pci_register)