Go to the source code of this file.
Data Structures | |
| struct | virtio_device_id |
| Virtio device identifier. More... | |
| struct | virtio_feature_desc |
| Device features. More... | |
| struct | virtio_vring_info |
| Virtio vring data structure. More... | |
| struct | virtio_device |
| Structure definition for virtio devices for use by the applications/drivers. More... | |
| struct | virtio_dispatch |
| Virtio device dispatcher functions. More... | |
| struct | virtio_memory_ops |
Typedefs | |
| typedef void(* | virtio_dev_reset_cb) (struct virtio_device *vdev) |
Functions | |
| int | virtio_create_virtqueues (struct virtio_device *vdev, unsigned int flags, unsigned int nvqs, const char *names[], vq_callback callbacks[], void *callback_args[]) |
| Create the virtio device virtqueue. More... | |
| static void | virtio_delete_virtqueues (struct virtio_device *vdev) |
| Delete the virtio device virtqueue. More... | |
| static uint32_t | virtio_get_devid (const struct virtio_device *vdev) |
| Get device ID. More... | |
| static int | virtio_get_status (struct virtio_device *vdev, uint8_t *status) |
| Retrieve device status. More... | |
| static int | virtio_set_status (struct virtio_device *vdev, uint8_t status) |
| Set device status. More... | |
| static int | virtio_read_config (struct virtio_device *vdev, uint32_t offset, void *dst, int len) |
| Retrieve configuration data from the device. More... | |
| static int | virtio_write_config (struct virtio_device *vdev, uint32_t offset, void *src, int len) |
| Write configuration data to the device. More... | |
| static int | virtio_get_features (struct virtio_device *vdev, uint32_t *features) |
| Get the virtio device features. More... | |
| static int | virtio_set_features (struct virtio_device *vdev, uint32_t features) |
| Set features supported by the VIRTIO driver. More... | |
| static int | virtio_negotiate_features (struct virtio_device *vdev, uint32_t features, uint32_t *final_features) |
| Negotiate features between virtio device and driver. More... | |
| static int | virtio_reset_device (struct virtio_device *vdev) |
| Reset virtio device. More... | |
| static int | virtio_alloc_buf (struct virtio_device *vdev, void **buf, size_t size, size_t align) |
| Allocate buffer from the virtio device. More... | |
| static int | virtio_free_buf (struct virtio_device *vdev, void *buf) |
| Free the buffer allocated by virtio_alloc_buf from the virtio device. More... | |
| static bool | virtio_has_feature (struct virtio_device *vdev, unsigned int feature_bit) |
| Check if the virtio device support a specific feature. More... | |
| #define VIRTIO_ASSERT | ( | _exp, | |
| _msg | |||
| ) | metal_assert(_exp) |
| #define VIRTIO_CONFIG_FEATURES_OK 0x08 |
| #define VIRTIO_CONFIG_STATUS_ACK 0x01 |
| #define VIRTIO_CONFIG_STATUS_DRIVER 0x02 |
| #define VIRTIO_CONFIG_STATUS_DRIVER_OK 0x04 |
| #define VIRTIO_CONFIG_STATUS_FAILED 0x80 |
| #define VIRTIO_CONFIG_STATUS_NEEDS_RESET 0x40 |
| #define VIRTIO_CONFIG_STATUS_RESET 0x00 |
| #define VIRTIO_DEV_ANY_ID -1UL |
| #define VIRTIO_DEV_DEVICE 1UL |
| #define VIRTIO_DEV_DRIVER 0UL |
| #define VIRTIO_ENABLED | ( | option | ) | (option == 1) |
| #define VIRTIO_F_ANY_LAYOUT (1 << 27) |
| #define VIRTIO_F_BAD_FEATURE (1 << 30) |
| #define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24) |
| #define VIRTIO_ID_9P 9UL |
| #define VIRTIO_ID_AUDIO_POLICY 39UL |
| #define VIRTIO_ID_BALLOON 5UL |
| #define VIRTIO_ID_BLOCK 2UL |
| #define VIRTIO_ID_BT 40UL |
| #define VIRTIO_ID_CAIF 12UL |
| #define VIRTIO_ID_CAN 36UL |
| #define VIRTIO_ID_CLOCK 17UL |
| #define VIRTIO_ID_CONSOLE 3UL |
| #define VIRTIO_ID_CRYPTO 20UL |
| #define VIRTIO_ID_ENTROPY 4UL |
| #define VIRTIO_ID_FS 26UL |
| #define VIRTIO_ID_GPIO 41UL |
| #define VIRTIO_ID_GPU 16UL |
| #define VIRTIO_ID_I2C_ADAPTER 34UL |
| #define VIRTIO_ID_INPUT 18UL |
| #define VIRTIO_ID_IOMEMORY 6UL |
| #define VIRTIO_ID_IOMMU 23UL |
| #define VIRTIO_ID_MAC80211_HWSIM 29UL |
| #define VIRTIO_ID_MAC80211_WLAN 10UL |
| #define VIRTIO_ID_MEM 24UL |
| #define VIRTIO_ID_MEMORY_BALLOON 13UL |
| #define VIRTIO_ID_NETWORK 1UL |
| #define VIRTIO_ID_NITRO_SEC_MOD 33UL |
| #define VIRTIO_ID_PARAM_SERV 38UL |
| #define VIRTIO_ID_PMEM 27UL |
| #define VIRTIO_ID_PSTORE 22UL |
| #define VIRTIO_ID_RDMA 42UL |
| #define VIRTIO_ID_RPMB 28UL |
| #define VIRTIO_ID_RPMSG 7UL /* remote processor messaging */ |
| #define VIRTIO_ID_RPROC_SERIAL 11UL |
| #define VIRTIO_ID_SCMI 32UL |
| #define VIRTIO_ID_SCSI 8UL |
| #define VIRTIO_ID_SIGNAL_DIST 21UL |
| #define VIRTIO_ID_SOUND 25UL |
| #define VIRTIO_ID_VIDEO_DECODER 31UL |
| #define VIRTIO_ID_VIDEO_ENCODER 30UL |
| #define VIRTIO_ID_VSOCK 19UL |
| #define VIRTIO_ID_WATCHDOG 35UL |
| #define VIRTIO_MMIO_VRING_ALIGNMENT 4096 |
| #define VIRTIO_ROLE_IS_DEVICE | ( | vdev | ) | ((vdev)->role == VIRTIO_DEV_DEVICE) |
| #define VIRTIO_ROLE_IS_DRIVER | ( | vdev | ) | ((vdev)->role == VIRTIO_DEV_DRIVER) |
| #define VIRTIO_TRANSPORT_F_END 32 |
| #define VIRTIO_TRANSPORT_F_START 28 |
| typedef void(* virtio_dev_reset_cb) (struct virtio_device *vdev) |
|
inlinestatic |
Allocate buffer from the virtio device.
| vdev | Pointer to virtio device structure. |
| buf | Pointer to the allocated buffer (virtual address). |
| size | Allocated buffer size. |
| align | Allocated buffer alignment. |
| int virtio_create_virtqueues | ( | struct virtio_device * | vdev, |
| unsigned int | flags, | ||
| unsigned int | nvqs, | ||
| const char * | names[], | ||
| vq_callback | callbacks[], | ||
| void * | callback_args[] | ||
| ) |
Create the virtio device virtqueue.
| vdev | Pointer to virtio device structure. |
| flags | Create flag. |
| nvqs | The virtqueue number. |
| names | Virtqueue names. |
| callbacks | Virtqueue callback functions. |
| callback_args | Virtqueue callback function arguments. |
|
inlinestatic |
Delete the virtio device virtqueue.
| vdev | Pointer to virtio device structure. |
|
inlinestatic |
Free the buffer allocated by virtio_alloc_buf from the virtio device.
| vdev | Pointer to virtio device structure. |
| buf | Buffer need to be freed. |
|
inlinestatic |
Get device ID.
| vdev | Pointer to device structure. |
|
inlinestatic |
Get the virtio device features.
| vdev | Pointer to device structure. |
| features | Pointer to features supported by both the driver and the device as a bitfield. |
|
inlinestatic |
Retrieve device status.
| vdev | Pointer to device structure. |
| status | Pointer to the virtio device status. |
|
inlinestatic |
Check if the virtio device support a specific feature.
| vdev | Pointer to device structure. |
| feature_bit | Feature bit to check. |
|
inlinestatic |
Negotiate features between virtio device and driver.
| vdev | Pointer to device structure. |
| features | Supported features. |
| final_features | Pointer to the final features after negotiate. |
|
inlinestatic |
Retrieve configuration data from the device.
| vdev | Pointer to device structure. |
| offset | Offset of the data within the configuration area. |
| dst | Address of the buffer that will hold the data. |
| len | Length of the data to be retrieved. |
|
inlinestatic |
Reset virtio device.
| vdev | Pointer to virtio_device structure. |
|
inlinestatic |
Set features supported by the VIRTIO driver.
| vdev | Pointer to device structure. |
| features | Features supported by the driver as a bitfield. |
|
inlinestatic |
Set device status.
| vdev | Pointer to device structure. |
| status | Value to be set as device status. |
|
inlinestatic |
Write configuration data to the device.
| vdev | Pointer to device structure. |
| offset | Offset of the data within the configuration area. |
| src | Address of the buffer that holds the data to write. |
| len | Length of the data to be written. |