|
XenevaOS
|
#include <stdint.h>#include <stddef.h>

Go to the source code of this file.
Classes | |
| struct | VirtioCommonCfg |
| struct | VirtioDeviceConfig |
| struct | VirtioBuffer |
| struct | VirtioAvail |
| struct | VirtioRing |
| struct | VirtioUsed |
| struct | VirtioQueue |
| struct | VirtioInputEvent |
| struct | _virtio_net_hdr_ |
| struct | virtio_pci_cap |
| struct | virtio_notifier_cap |
| struct | VirtqDesc |
| struct | VirtqAvailHdr |
| struct | VirtqUsedElem |
| struct | VirtqUsedHdr |
| struct | VirtioPCIDevice |
| a mapped, reset-and-negotiated modern virtio-pci device. Per-device drivers build their own virtqueues and config parsing on top of this. More... | |
Macros | |
| #define | OFFSETOF(s, m) ((size_t)&(((s*)0)->m)) |
| #define | VIRTIO_NET_F_CSUM (1ULL << 0) |
| #define | VIRTIO_NET_F_GUEST_CSUM (1ULL << 2) |
| #define | VIRTIO_NET_F_MAC (1ULL << 5) |
| #define | VIRTIO_NET_F_CTRL_VQ (1ULL << 17) |
| #define | VIRTIO_NET_HDR_GSO_NONE 0 |
| #define | VIRTIO_PCI_CAP_VENDOR_ID 0x09 /* PCI capability ID for "vendor specific" */ |
| #define | VIRTIO_PCI_CAP_COMMON_CFG 1 |
| #define | VIRTIO_PCI_CAP_NOTIFY_CFG 2 |
| #define | VIRTIO_PCI_CAP_ISR_CFG 3 |
| #define | VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| #define | VIRTIO_PCI_CAP_PCI_CFG 5 |
| #define | VIRTIO_STATUS_ACKNOWLEDGE 0x01 |
| #define | VIRTIO_STATUS_DRIVER 0x02 |
| #define | VIRTIO_STATUS_DRIVER_OK 0x04 |
| #define | VIRTIO_STATUS_FEATURES_OK 0x08 |
| #define | VIRTIO_STATUS_DEVICE_NEEDS_RESET 0x40 |
| #define | VIRTIO_STATUS_FAILED 0x80 |
| #define | VIRTIO_F_VERSION_1_BIT 32 |
| #define | VIRTQ_DESC_F_NEXT 1 |
| #define | VIRTQ_DESC_F_WRITE 2 |
| #define | VIRTIO_MSI_NO_VECTOR 0xFFFF |
Typedefs | |
| typedef struct _virtio_net_hdr_ | virtio_net_hdr_t |
Functions | |
| bool | AuVirtioPCIInit (uint64_t address, int bus, int dev, int func, uint32_t wantedFeaturesLow, struct VirtioPCIDevice *out) |
| AuVirtioPCIInit – walks the PCI capability list of a modern virtio-pci device, maps its common/notify/isr/device config BARs, resets it and negotiates VIRTIO_F_VERSION_1 plus wantedFeaturesLow (bits 0-31). | |
| uint16_t | AuVirtioPCISetupQueue (struct VirtioPCIDevice *dev, uint16_t qidx, struct VirtqDesc **outDesc, struct VirtqAvailHdr **outAvail, struct VirtqUsedHdr **outUsed, uint16_t msixVector) |
| AuVirtioPCISetupQueue – selects queue qidx, allocates desc/avail/used rings sized to the device-reported queue size and enables the queue. | |
| void | AuVirtioPCINotifyQueue (struct VirtioPCIDevice *dev, uint16_t qidx) |
| AuVirtioPCINotifyQueue – kicks the device for queue qidx. | |
| void | AuVirtioBlkInitialize (uint64_t device, int bus, int dev, int func) |
| AuVirtioBlkInitialize – initialize the virtio block device. | |
| void | AuVirtioKbdInitialize (uint64_t device, int bus, int dev, int func) |
| AuVirtioKbdInitialize – initialize the virtio keyboard. | |
| void | AuVirtioTabletInitialize (uint64_t device, int bus, int dev, int func) |
| AuVirtioTabletInitialize – initialize virtio tablet. | |
| void | AuVirtioKbdDown () |
| void | AuVirtioTabletDown () |
| void | AuVirtioNetInitialize (uint64_t device) |
| AuVirtioNetInitialize – initialize the virtio network device. | |
BSD 2-Clause License
Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| #define OFFSETOF | ( | s, | |
| m | |||
| ) | ((size_t)&(((s*)0)->m)) |
| #define VIRTIO_F_VERSION_1_BIT 32 |
| #define VIRTIO_MSI_NO_VECTOR 0xFFFF |
| #define VIRTIO_NET_F_CSUM (1ULL << 0) |
| #define VIRTIO_NET_F_CTRL_VQ (1ULL << 17) |
| #define VIRTIO_NET_F_GUEST_CSUM (1ULL << 2) |
| #define VIRTIO_NET_F_MAC (1ULL << 5) |
| #define VIRTIO_NET_HDR_GSO_NONE 0 |
| #define VIRTIO_PCI_CAP_COMMON_CFG 1 |
| #define VIRTIO_PCI_CAP_DEVICE_CFG 4 |
| #define VIRTIO_PCI_CAP_ISR_CFG 3 |
| #define VIRTIO_PCI_CAP_NOTIFY_CFG 2 |
| #define VIRTIO_PCI_CAP_PCI_CFG 5 |
| #define VIRTIO_PCI_CAP_VENDOR_ID 0x09 /* PCI capability ID for "vendor specific" */ |
| #define VIRTIO_STATUS_ACKNOWLEDGE 0x01 |
| #define VIRTIO_STATUS_DEVICE_NEEDS_RESET 0x40 |
| #define VIRTIO_STATUS_DRIVER 0x02 |
| #define VIRTIO_STATUS_DRIVER_OK 0x04 |
| #define VIRTIO_STATUS_FAILED 0x80 |
| #define VIRTIO_STATUS_FEATURES_OK 0x08 |
| #define VIRTQ_DESC_F_NEXT 1 |
| #define VIRTQ_DESC_F_WRITE 2 |
| typedef struct _virtio_net_hdr_ virtio_net_hdr_t |
|
extern |
AuVirtioBlkInitialize – initialize the virtio block device.
| device | – pcie config space address |
| bus,dev,func | – pcie location of the device |
|
extern |
|
extern |
AuVirtioKbdInitialize – initialize the virtio keyboard.
|
extern |
AuVirtioNetInitialize – initialize the virtio network device.
| device | – virtio network device address |
| device | – device address passed by PCIe |
feature negotiation
enable RX+TX queue
feature negotiation
enable RX+TX queue
|
extern |
AuVirtioPCIInit – walks the PCI capability list of a modern virtio-pci device, maps its common/notify/isr/device config BARs, resets it and negotiates VIRTIO_F_VERSION_1 plus wantedFeaturesLow (bits 0-31).
AuVirtioPCIInit – walks the PCI capability list of a modern virtio-pci device, maps its common/notify/isr/device config BARs, resets it and negotiates VIRTIO_F_VERSION_1 plus wantedFeaturesLow (bits 0-31).
|
extern |
AuVirtioPCINotifyQueue – kicks the device for queue qidx.
AuVirtioPCINotifyQueue – kicks the device for queue qidx.
|
extern |
AuVirtioPCISetupQueue – selects queue qidx, allocates desc/avail/used rings sized to the device-reported queue size and enables the queue.
| msixVector | – MSI-X table index to bind the queue to, or VIRTIO_MSI_NO_VECTOR for polling (no queue interrupt) |
AuVirtioPCISetupQueue – selects queue qidx, allocates desc/avail/used rings sized to the device-reported queue size and enables the queue.
|
extern |
|
extern |
AuVirtioTabletInitialize – initialize virtio tablet.
AuVirtioTabletInitialize – initialize virtio tablet.