39#ifndef _LINUX_VIRTIO_PCI_H
40#define _LINUX_VIRTIO_PCI_H
42#include "linux/types.h"
45#ifndef VIRTIO_PCI_NO_LEGACY
48#define VIRTIO_PCI_HOST_FEATURES 0
51#define VIRTIO_PCI_GUEST_FEATURES 4
54#define VIRTIO_PCI_QUEUE_PFN 8
57#define VIRTIO_PCI_QUEUE_NUM 12
60#define VIRTIO_PCI_QUEUE_SEL 14
63#define VIRTIO_PCI_QUEUE_NOTIFY 16
66#define VIRTIO_PCI_STATUS 18
71#define VIRTIO_PCI_ISR 19
75#define VIRTIO_MSI_CONFIG_VECTOR 20
77#define VIRTIO_MSI_QUEUE_VECTOR 22
81#define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20)
83#define VIRTIO_PCI_CONFIG(msix_enabled) VIRTIO_PCI_CONFIG_OFF(msix_enabled)
87#define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12
91#define VIRTIO_PCI_VRING_ALIGN 4096
96#define VIRTIO_PCI_ISR_CONFIG 0x2
98#define VIRTIO_MSI_NO_VECTOR 0xffff
103#define VIRTIO_PCI_CAP_COMMON_CFG 1
105#define VIRTIO_PCI_CAP_NOTIFY_CFG 2
107#define VIRTIO_PCI_CAP_ISR_CFG 3
109#define VIRTIO_PCI_CAP_DEVICE_CFG 4
111#define VIRTIO_PCI_CAP_PCI_CFG 5
156#define MAX_QUEUES_PER_DEVICE_DEFAULT 8
223 unsigned index,
unsigned short *pNumEntries,
224 unsigned long *pRingSize,
225 unsigned long *pHeapSize);
230 unsigned idx,
u16 msix_vec);
311#define virtio_is_feature_enabled(FeaturesList, Feature) (!!((FeaturesList) & (1ULL << (Feature))))
312#define virtio_feature_enable(FeaturesList, Feature) ((FeaturesList) |= (1ULL << (Feature)))
313#define virtio_feature_disable(FeaturesList, Feature) ((FeaturesList) &= ~(1ULL << (Feature)))
339 unsigned short *pNumEntries,
340 unsigned long *pRingSize,
341 unsigned long *pHeapSize);
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum const GLvoid * addr
_In_ PNDIS_STRING _In_opt_ NDIS_HANDLE DeviceContext
NTSTATUS(* set_features)(VirtIODevice *vdev, u64 features)
u16(* set_config_vector)(VirtIODevice *vdev, u16 vector)
void(* get_config)(VirtIODevice *vdev, unsigned offset, void *buf, unsigned len)
u8(* get_status)(VirtIODevice *vdev)
void(* set_config)(VirtIODevice *vdev, unsigned offset, const void *buf, unsigned len)
NTSTATUS(* setup_queue)(struct virtqueue **queue, VirtIODevice *vdev, VirtIOQueueInfo *info, unsigned idx, u16 msix_vec)
void(* set_status)(VirtIODevice *vdev, u8 status)
u16(* set_queue_vector)(struct virtqueue *vq, u16 vector)
void(* delete_queue)(VirtIOQueueInfo *info)
u64(* get_features)(VirtIODevice *vdev)
u32(* get_config_generation)(VirtIODevice *vdev)
NTSTATUS(* query_queue_alloc)(VirtIODevice *vdev, unsigned index, unsigned short *pNumEntries, unsigned long *pRingSize, unsigned long *pHeapSize)
bool event_suppression_enabled
volatile unsigned char * config
volatile struct virtio_pci_common_cfg * common
const struct virtio_system_ops * system
const struct virtio_device_ops * device
volatile unsigned char * notify_base
u32 notify_offset_multiplier
VirtIOQueueInfo inline_info[MAX_QUEUES_PER_DEVICE_DEFAULT]
__le32 guest_feature_select
__le32 device_feature_select
__le32 notify_off_multiplier
void(* mem_free_nonpaged_block)(void *context, void *addr)
void(* mem_free_contiguous_pages)(void *context, void *virt)
u16(* vdev_read_word)(ULONG_PTR ulRegister)
void(* vdev_sleep)(void *context, unsigned int msecs)
void(* vdev_write_byte)(ULONG_PTR ulRegister, u8 bValue)
u16(* vdev_get_msix_vector)(void *context, int queue)
u8(* vdev_read_byte)(ULONG_PTR ulRegister)
void(* vdev_write_dword)(ULONG_PTR ulRegister, u32 ulValue)
u32(* vdev_read_dword)(ULONG_PTR ulRegister)
size_t(* pci_get_resource_len)(void *context, int bar)
int(* pci_read_config_dword)(void *context, int where, u32 *dwVal)
int(* pci_read_config_byte)(void *context, int where, u8 *bVal)
ULONGLONG(* mem_get_physical_address)(void *context, void *virt)
void(* vdev_write_word)(ULONG_PTR ulRegister, u16 wValue)
int(* pci_read_config_word)(void *context, int where, u16 *wVal)
int virtio_get_bar_index(PPCI_COMMON_HEADER pPCIHeader, PHYSICAL_ADDRESS BasePA)
u32 virtio_get_queue_size(struct virtqueue *vq)
struct virtio_queue_info VirtIOQueueInfo
NTSTATUS virtio_find_queues(VirtIODevice *vdev, unsigned nvqs, struct virtqueue *vqs[])
NTSTATUS virtio_device_initialize(VirtIODevice *vdev, const VirtIOSystemOps *pSystemOps, void *DeviceContext, bool msix_used)
void virtio_device_shutdown(VirtIODevice *vdev)
u16 virtio_set_queue_vector(struct virtqueue *vq, u16 vector)
struct virtio_system_ops VirtIOSystemOps
void virtio_delete_queues(VirtIODevice *vdev)
#define MAX_QUEUES_PER_DEVICE_DEFAULT
void virtio_set_status(VirtIODevice *vdev, u8 status)
void virtio_add_status(VirtIODevice *vdev, u8 status)
void virtio_device_ready(VirtIODevice *vdev)
void virtio_set_config(VirtIODevice *vdev, unsigned offset, void *buf, unsigned len)
static ULONG FORCEINLINE virtio_get_queue_descriptor_size()
NTSTATUS virtio_find_queue(VirtIODevice *vdev, unsigned index, struct virtqueue **vq)
NTSTATUS virtio_reserve_queue_memory(VirtIODevice *vdev, unsigned nvqs)
u8 virtio_read_isr_status(VirtIODevice *vdev)
u64 virtio_get_features(VirtIODevice *dev)
u8 virtio_get_status(VirtIODevice *vdev)
void virtio_delete_queue(struct virtqueue *vq)
void virtio_device_reset(VirtIODevice *vdev)
NTSTATUS virtio_query_queue_allocation(VirtIODevice *vdev, unsigned index, unsigned short *pNumEntries, unsigned long *pRingSize, unsigned long *pHeapSize)
void virtio_get_config(VirtIODevice *vdev, unsigned offset, void *buf, unsigned len)
u16 virtio_set_config_vector(VirtIODevice *vdev, u16 vector)
unsigned long virtio_get_indirect_page_capacity()
NTSTATUS virtio_set_features(VirtIODevice *vdev, u64 features)