ReactOS 0.4.16-dev-320-g3bd9ddc
virtio_pci_common.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ioread8(vdev, addr)    vdev->system->vdev_read_byte((ULONG_PTR)(addr))
 
#define ioread16(vdev, addr)    vdev->system->vdev_read_word((ULONG_PTR)(addr))
 
#define ioread32(vdev, addr)    vdev->system->vdev_read_dword((ULONG_PTR)(addr))
 
#define iowrite8(vdev, val, addr)    vdev->system->vdev_write_byte((ULONG_PTR)(addr), val)
 
#define iowrite16(vdev, val, addr)    vdev->system->vdev_write_word((ULONG_PTR)(addr), val)
 
#define iowrite32(vdev, val, addr)    vdev->system->vdev_write_dword((ULONG_PTR)(addr), val)
 
#define iowrite64_twopart(vdev, val, lo_addr, hi_addr)
 
#define mem_alloc_contiguous_pages(vdev, size)    vdev->system->mem_alloc_contiguous_pages(vdev->DeviceContext, size)
 
#define mem_free_contiguous_pages(vdev, virt)    vdev->system->mem_free_contiguous_pages(vdev->DeviceContext, virt)
 
#define mem_get_physical_address(vdev, virt)    vdev->system->mem_get_physical_address(vdev->DeviceContext, virt)
 
#define mem_alloc_nonpaged_block(vdev, size)    vdev->system->mem_alloc_nonpaged_block(vdev->DeviceContext, size)
 
#define mem_free_nonpaged_block(vdev, addr)    vdev->system->mem_free_nonpaged_block(vdev->DeviceContext, addr)
 
#define pci_read_config_byte(vdev, where, bVal)    vdev->system->pci_read_config_byte(vdev->DeviceContext, where, bVal)
 
#define pci_read_config_word(vdev, where, wVal)    vdev->system->pci_read_config_word(vdev->DeviceContext, where, wVal)
 
#define pci_read_config_dword(vdev, where, dwVal)    vdev->system->pci_read_config_dword(vdev->DeviceContext, where, dwVal)
 
#define pci_get_resource_len(vdev, bar)    vdev->system->pci_get_resource_len(vdev->DeviceContext, bar)
 
#define pci_map_address_range(vdev, bar, offset, maxlen)    vdev->system->pci_map_address_range(vdev->DeviceContext, bar, offset, maxlen)
 
#define vdev_get_msix_vector(vdev, queue)    vdev->system->vdev_get_msix_vector(vdev->DeviceContext, queue)
 
#define vdev_sleep(vdev, msecs)    vdev->system->vdev_sleep(vdev->DeviceContext, msecs)
 

Functions

void vp_notify (struct virtqueue *vq)
 
NTSTATUS vio_legacy_initialize (VirtIODevice *vdev)
 
NTSTATUS vio_modern_initialize (VirtIODevice *vdev)
 

Macro Definition Documentation

◆ ioread16

#define ioread16 (   vdev,
  addr 
)     vdev->system->vdev_read_word((ULONG_PTR)(addr))

Definition at line 40 of file virtio_pci_common.h.

◆ ioread32

#define ioread32 (   vdev,
  addr 
)     vdev->system->vdev_read_dword((ULONG_PTR)(addr))

Definition at line 42 of file virtio_pci_common.h.

◆ ioread8

#define ioread8 (   vdev,
  addr 
)     vdev->system->vdev_read_byte((ULONG_PTR)(addr))

Definition at line 38 of file virtio_pci_common.h.

◆ iowrite16

#define iowrite16 (   vdev,
  val,
  addr 
)     vdev->system->vdev_write_word((ULONG_PTR)(addr), val)

Definition at line 46 of file virtio_pci_common.h.

◆ iowrite32

#define iowrite32 (   vdev,
  val,
  addr 
)     vdev->system->vdev_write_dword((ULONG_PTR)(addr), val)

Definition at line 48 of file virtio_pci_common.h.

◆ iowrite64_twopart

#define iowrite64_twopart (   vdev,
  val,
  lo_addr,
  hi_addr 
)
Value:
vdev->system->vdev_write_dword((ULONG_PTR)(lo_addr), (u32)(val)); \
vdev->system->vdev_write_dword((ULONG_PTR)(hi_addr), (val) >> 32)
ULONG32 u32
Definition: btrfs.h:14
GLuint GLfloat * val
Definition: glext.h:7180
uint32_t ULONG_PTR
Definition: typedefs.h:65

Definition at line 50 of file virtio_pci_common.h.

◆ iowrite8

#define iowrite8 (   vdev,
  val,
  addr 
)     vdev->system->vdev_write_byte((ULONG_PTR)(addr), val)

Definition at line 44 of file virtio_pci_common.h.

◆ mem_alloc_contiguous_pages

#define mem_alloc_contiguous_pages (   vdev,
  size 
)     vdev->system->mem_alloc_contiguous_pages(vdev->DeviceContext, size)

Definition at line 54 of file virtio_pci_common.h.

◆ mem_alloc_nonpaged_block

#define mem_alloc_nonpaged_block (   vdev,
  size 
)     vdev->system->mem_alloc_nonpaged_block(vdev->DeviceContext, size)

Definition at line 60 of file virtio_pci_common.h.

◆ mem_free_contiguous_pages

#define mem_free_contiguous_pages (   vdev,
  virt 
)     vdev->system->mem_free_contiguous_pages(vdev->DeviceContext, virt)

Definition at line 56 of file virtio_pci_common.h.

◆ mem_free_nonpaged_block

#define mem_free_nonpaged_block (   vdev,
  addr 
)     vdev->system->mem_free_nonpaged_block(vdev->DeviceContext, addr)

Definition at line 62 of file virtio_pci_common.h.

◆ mem_get_physical_address

#define mem_get_physical_address (   vdev,
  virt 
)     vdev->system->mem_get_physical_address(vdev->DeviceContext, virt)

Definition at line 58 of file virtio_pci_common.h.

◆ pci_get_resource_len

#define pci_get_resource_len (   vdev,
  bar 
)     vdev->system->pci_get_resource_len(vdev->DeviceContext, bar)

Definition at line 72 of file virtio_pci_common.h.

◆ pci_map_address_range

#define pci_map_address_range (   vdev,
  bar,
  offset,
  maxlen 
)     vdev->system->pci_map_address_range(vdev->DeviceContext, bar, offset, maxlen)

Definition at line 74 of file virtio_pci_common.h.

◆ pci_read_config_byte

#define pci_read_config_byte (   vdev,
  where,
  bVal 
)     vdev->system->pci_read_config_byte(vdev->DeviceContext, where, bVal)

Definition at line 65 of file virtio_pci_common.h.

◆ pci_read_config_dword

#define pci_read_config_dword (   vdev,
  where,
  dwVal 
)     vdev->system->pci_read_config_dword(vdev->DeviceContext, where, dwVal)

Definition at line 69 of file virtio_pci_common.h.

◆ pci_read_config_word

#define pci_read_config_word (   vdev,
  where,
  wVal 
)     vdev->system->pci_read_config_word(vdev->DeviceContext, where, wVal)

Definition at line 67 of file virtio_pci_common.h.

◆ vdev_get_msix_vector

#define vdev_get_msix_vector (   vdev,
  queue 
)     vdev->system->vdev_get_msix_vector(vdev->DeviceContext, queue)

Definition at line 77 of file virtio_pci_common.h.

◆ vdev_sleep

#define vdev_sleep (   vdev,
  msecs 
)     vdev->system->vdev_sleep(vdev->DeviceContext, msecs)

Definition at line 79 of file virtio_pci_common.h.

Function Documentation

◆ vio_legacy_initialize()

NTSTATUS vio_legacy_initialize ( VirtIODevice vdev)

Definition at line 269 of file VirtIOPCILegacy.c.

270{
271 size_t length = pci_get_resource_len(vdev, 0);
272 vdev->addr = (ULONG_PTR)pci_map_address_range(vdev, 0, 0, length);
273
274 if (!vdev->addr) {
276 }
277
278 vdev->isr = (u8 *)vdev->addr + VIRTIO_PCI_ISR;
279
281
282 return STATUS_SUCCESS;
283}
static const struct virtio_device_ops virtio_pci_device_ops
UCHAR u8
Definition: btrfs.h:12
#define ULONG_PTR
Definition: config.h:101
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define STATUS_SUCCESS
Definition: shellext.h:65
volatile u8 * isr
Definition: virtio_pci.h:260
ULONG_PTR addr
Definition: virtio_pci.h:239
const struct virtio_device_ops * device
Definition: virtio_pci.h:251
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define VIRTIO_PCI_ISR
Definition: virtio_pci.h:71
#define pci_map_address_range(vdev, bar, offset, maxlen)
#define pci_get_resource_len(vdev, bar)

Referenced by virtio_device_initialize().

◆ vio_modern_initialize()

NTSTATUS vio_modern_initialize ( VirtIODevice vdev)

Definition at line 516 of file VirtIOPCIModern.c.

517{
518 int capabilities[VIRTIO_PCI_CAP_PCI_CFG];
519
520 u32 notify_length;
521 u32 notify_offset;
522
523 RtlZeroMemory(capabilities, sizeof(capabilities));
525
526 /* Check for a common config, if not found use legacy mode */
527 if (!capabilities[VIRTIO_PCI_CAP_COMMON_CFG]) {
528 DPrintf(0, "%s(%p): device not found\n", __FUNCTION__, vdev);
530 }
531
532 /* Check isr and notify caps, if not found fail */
533 if (!capabilities[VIRTIO_PCI_CAP_ISR_CFG] || !capabilities[VIRTIO_PCI_CAP_NOTIFY_CFG]) {
534 DPrintf(0, "%s(%p): missing capabilities %i/%i/%i\n",
535 __FUNCTION__, vdev,
536 capabilities[VIRTIO_PCI_CAP_COMMON_CFG],
537 capabilities[VIRTIO_PCI_CAP_ISR_CFG],
538 capabilities[VIRTIO_PCI_CAP_NOTIFY_CFG]);
540 }
541
542 /* Map bars according to the capabilities */
544 capabilities[VIRTIO_PCI_CAP_COMMON_CFG],
545 sizeof(struct virtio_pci_common_cfg), 4);
546 if (!vdev->common) {
548 }
549
551 capabilities[VIRTIO_PCI_CAP_ISR_CFG],
552 sizeof(u8), 1);
553 if (!vdev->isr) {
555 }
556
557 /* Read notify_off_multiplier from config space. */
560 notify_off_multiplier),
562
563 /* Read notify length and offset from config space. */
566 cap.length),
567 &notify_length);
570 cap.offset),
571 &notify_offset);
572
573 /* Map the notify capability if it's small enough.
574 * Otherwise, map each VQ individually later.
575 */
576 if (notify_length + (notify_offset % PAGE_SIZE) <= PAGE_SIZE) {
578 capabilities[VIRTIO_PCI_CAP_NOTIFY_CFG], 2, 2,
579 0, notify_length,
580 &vdev->notify_len);
581 if (!vdev->notify_base) {
583 }
584 } else {
585 vdev->notify_map_cap = capabilities[VIRTIO_PCI_CAP_NOTIFY_CFG];
586 }
587
588 /* Map the device config capability, the PAGE_SIZE size is a guess */
589 if (capabilities[VIRTIO_PCI_CAP_DEVICE_CFG]) {
591 capabilities[VIRTIO_PCI_CAP_DEVICE_CFG], 0, 4,
592 0, PAGE_SIZE,
593 &vdev->config_len);
594 if (!vdev->config) {
596 }
597 }
598
600
601 return STATUS_SUCCESS;
602}
static void * vio_modern_map_simple_capability(VirtIODevice *vdev, int cap_offset, size_t length, u32 alignment)
static void find_pci_vendor_capabilities(VirtIODevice *vdev, int *Offsets, size_t nOffsets)
static const struct virtio_device_ops virtio_pci_device_ops
static void * vio_modern_map_capability(VirtIODevice *vdev, int cap_offset, size_t minlen, u32 alignment, u32 start, u32 size, size_t *len)
#define __FUNCTION__
Definition: types.h:116
#define DPrintf(Level, Fmt)
Definition: kdebugprint.h:61
#define PAGE_SIZE
Definition: env_spec_w32.h:49
GLenum cap
Definition: glext.h:9639
#define offsetof(TYPE, MEMBER)
volatile unsigned char * config
Definition: virtio_pci.h:264
volatile struct virtio_pci_common_cfg * common
Definition: virtio_pci.h:263
size_t notify_len
Definition: virtio_pci.h:270
int notify_map_cap
Definition: virtio_pci.h:266
volatile unsigned char * notify_base
Definition: virtio_pci.h:265
size_t config_len
Definition: virtio_pci.h:269
u32 notify_offset_multiplier
Definition: virtio_pci.h:267
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define VIRTIO_PCI_CAP_PCI_CFG
Definition: virtio_pci.h:111
#define VIRTIO_PCI_CAP_DEVICE_CFG
Definition: virtio_pci.h:109
#define VIRTIO_PCI_CAP_ISR_CFG
Definition: virtio_pci.h:107
#define VIRTIO_PCI_CAP_NOTIFY_CFG
Definition: virtio_pci.h:105
#define VIRTIO_PCI_CAP_COMMON_CFG
Definition: virtio_pci.h:103
#define pci_read_config_dword(vdev, where, dwVal)

Referenced by virtio_device_initialize().

◆ vp_notify()

void vp_notify ( struct virtqueue vq)

Definition at line 393 of file VirtIOPCICommon.c.

394{
395 /* we write the queue's selector into the notification register to
396 * signal the other end */
397 iowrite16(vq->vdev, (unsigned short)vq->index, vq->notification_addr);
398 DPrintf(6, "virtio: vp_notify vq->index = %x\n", vq->index);
399}
void * notification_addr
Definition: VirtIO.h:47
unsigned int index
Definition: VirtIO.h:45
VirtIODevice * vdev
Definition: VirtIO.h:44
#define iowrite16(vdev, val, addr)

Referenced by vio_legacy_setup_vq(), and vio_modern_setup_vq().