2 * libqos virtio PCI definitions
4 * Copyright (c) 2014 Marc MarĂ
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
10 #ifndef LIBQOS_VIRTIO_PCI_H
11 #define LIBQOS_VIRTIO_PCI_H
13 #include "libqos/virtio.h"
14 #include "libqos/pci.h"
16 #define QVIRTIO_DEVICE_FEATURES 0x00
17 #define QVIRTIO_GUEST_FEATURES 0x04
18 #define QVIRTIO_QUEUE_ADDRESS 0x08
19 #define QVIRTIO_QUEUE_SIZE 0x0C
20 #define QVIRTIO_QUEUE_SELECT 0x0E
21 #define QVIRTIO_QUEUE_NOTIFY 0x10
22 #define QVIRTIO_DEVICE_STATUS 0x12
23 #define QVIRTIO_ISR_STATUS 0x13
24 #define QVIRTIO_MSIX_CONF_VECTOR 0x14
25 #define QVIRTIO_MSIX_QUEUE_VECTOR 0x16
26 #define QVIRTIO_DEVICE_SPECIFIC_MSIX 0x18
27 #define QVIRTIO_DEVICE_SPECIFIC_NO_MSIX 0x14
29 #define QVIRTIO_PCI_ALIGN 4096
31 #define QVIRTIO_MSI_NO_VECTOR 0xFFFF
33 typedef struct QVirtioPCIDevice
{
37 uint16_t config_msix_entry
;
38 uint64_t config_msix_addr
;
39 uint32_t config_msix_data
;
42 typedef struct QVirtQueuePCI
{
49 extern const QVirtioBus qvirtio_pci
;
51 void qvirtio_pci_foreach(QPCIBus
*bus
, uint16_t device_type
,
52 void (*func
)(QVirtioDevice
*d
, void *data
), void *data
);
53 QVirtioPCIDevice
*qvirtio_pci_device_find(QPCIBus
*bus
, uint16_t device_type
);
54 void qvirtio_pci_device_enable(QVirtioPCIDevice
*d
);
55 void qvirtio_pci_device_disable(QVirtioPCIDevice
*d
);
57 void qvirtio_pci_set_msix_configuration_vector(QVirtioPCIDevice
*d
,
58 QGuestAllocator
*alloc
, uint16_t entry
);
59 void qvirtqueue_pci_msix_setup(QVirtioPCIDevice
*d
, QVirtQueuePCI
*vqpci
,
60 QGuestAllocator
*alloc
, uint16_t entry
);