vfio_sys/
lib.rs

1// Copyright 2019 The ChromiumOS Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5//! Linux VFIO (Virtual Function I/O) bindings.
6//!
7//! <https://www.kernel.org/doc/html/latest/driver-api/vfio.html>
8
9#![allow(non_upper_case_globals)]
10#![allow(non_camel_case_types)]
11#![allow(non_snake_case)]
12
13use base::ioctl_io_nr;
14
15pub mod plat;
16pub mod vfio;
17
18use crate::plat::ACPI_EVT_FORWARD_BASE;
19use crate::plat::PLAT_IRQ_FORWARD_BASE;
20use crate::plat::PLAT_IRQ_FORWARD_TYPE;
21pub use crate::vfio::vfio_device_feature;
22pub use crate::vfio::vfio_device_info;
23pub use crate::vfio::vfio_device_low_power_entry_with_wakeup;
24pub use crate::vfio::vfio_group_status;
25pub use crate::vfio::vfio_info_cap_header;
26pub use crate::vfio::vfio_iommu_type1_dma_map;
27pub use crate::vfio::vfio_iommu_type1_dma_unmap;
28pub use crate::vfio::vfio_iommu_type1_info;
29pub use crate::vfio::vfio_iommu_type1_info_cap_iova_range;
30pub use crate::vfio::vfio_iommu_type1_info_cap_iova_range_header;
31pub use crate::vfio::vfio_iova_range;
32pub use crate::vfio::vfio_irq_info;
33pub use crate::vfio::vfio_irq_set;
34pub use crate::vfio::vfio_region_info;
35pub use crate::vfio::vfio_region_info_cap_sparse_mmap;
36pub use crate::vfio::vfio_region_info_cap_type;
37pub use crate::vfio::vfio_region_info_with_cap;
38pub use crate::vfio::vfio_region_sparse_mmap_area;
39pub use crate::vfio::VFIO_TYPE1v2_IOMMU;
40use crate::vfio::VFIO_BASE;
41pub use crate::vfio::VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY;
42pub use crate::vfio::VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP;
43pub use crate::vfio::VFIO_DEVICE_FEATURE_LOW_POWER_EXIT;
44pub use crate::vfio::VFIO_DEVICE_FEATURE_PROBE;
45pub use crate::vfio::VFIO_DEVICE_FEATURE_SET;
46pub use crate::vfio::VFIO_DEVICE_FLAGS_PCI;
47pub use crate::vfio::VFIO_DEVICE_FLAGS_PLATFORM;
48pub use crate::vfio::VFIO_DMA_MAP_FLAG_READ;
49pub use crate::vfio::VFIO_DMA_MAP_FLAG_WRITE;
50pub use crate::vfio::VFIO_GROUP_FLAGS_VIABLE;
51pub use crate::vfio::VFIO_IOMMU_INFO_CAPS;
52pub use crate::vfio::VFIO_IOMMU_INFO_PGSIZES;
53pub use crate::vfio::VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE;
54pub use crate::vfio::VFIO_IRQ_INFO_AUTOMASKED;
55pub use crate::vfio::VFIO_IRQ_SET_ACTION_MASK;
56pub use crate::vfio::VFIO_IRQ_SET_ACTION_TRIGGER;
57pub use crate::vfio::VFIO_IRQ_SET_ACTION_UNMASK;
58pub use crate::vfio::VFIO_IRQ_SET_DATA_EVENTFD;
59pub use crate::vfio::VFIO_IRQ_SET_DATA_NONE;
60pub use crate::vfio::VFIO_PCI_BAR0_REGION_INDEX;
61pub use crate::vfio::VFIO_PCI_CONFIG_REGION_INDEX;
62pub use crate::vfio::VFIO_PCI_INTX_IRQ_INDEX;
63pub use crate::vfio::VFIO_PCI_MSIX_IRQ_INDEX;
64pub use crate::vfio::VFIO_PCI_MSI_IRQ_INDEX;
65pub use crate::vfio::VFIO_PCI_REQ_IRQ_INDEX;
66pub use crate::vfio::VFIO_PCI_ROM_REGION_INDEX;
67pub use crate::vfio::VFIO_PKVM_PVIOMMU;
68pub use crate::vfio::VFIO_REGION_INFO_CAP_MSIX_MAPPABLE;
69pub use crate::vfio::VFIO_REGION_INFO_CAP_SPARSE_MMAP;
70pub use crate::vfio::VFIO_REGION_INFO_CAP_TYPE;
71pub use crate::vfio::VFIO_REGION_INFO_FLAG_CAPS;
72pub use crate::vfio::VFIO_REGION_INFO_FLAG_MMAP;
73pub use crate::vfio::VFIO_REGION_INFO_FLAG_WRITE;
74pub use crate::vfio::VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION;
75pub use crate::vfio::VFIO_REGION_TYPE_PCI_VENDOR_TYPE;
76use crate::vfio::VFIO_TYPE;
77
78ioctl_io_nr!(VFIO_GET_API_VERSION, VFIO_TYPE, VFIO_BASE);
79ioctl_io_nr!(VFIO_CHECK_EXTENSION, VFIO_TYPE, VFIO_BASE + 1);
80ioctl_io_nr!(VFIO_SET_IOMMU, VFIO_TYPE, VFIO_BASE + 2);
81ioctl_io_nr!(VFIO_GROUP_GET_STATUS, VFIO_TYPE, VFIO_BASE + 3);
82ioctl_io_nr!(VFIO_GROUP_SET_CONTAINER, VFIO_TYPE, VFIO_BASE + 4);
83ioctl_io_nr!(VFIO_GROUP_UNSET_CONTAINER, VFIO_TYPE, VFIO_BASE + 5);
84ioctl_io_nr!(VFIO_GROUP_GET_DEVICE_FD, VFIO_TYPE, VFIO_BASE + 6);
85ioctl_io_nr!(VFIO_DEVICE_GET_INFO, VFIO_TYPE, VFIO_BASE + 7);
86ioctl_io_nr!(VFIO_DEVICE_GET_REGION_INFO, VFIO_TYPE, VFIO_BASE + 8);
87ioctl_io_nr!(VFIO_DEVICE_GET_IRQ_INFO, VFIO_TYPE, VFIO_BASE + 9);
88ioctl_io_nr!(VFIO_DEVICE_SET_IRQS, VFIO_TYPE, VFIO_BASE + 10);
89ioctl_io_nr!(VFIO_DEVICE_RESET, VFIO_TYPE, VFIO_BASE + 11);
90ioctl_io_nr!(
91    VFIO_DEVICE_GET_PCI_HOT_RESET_INFO,
92    VFIO_TYPE,
93    VFIO_BASE + 12
94);
95ioctl_io_nr!(VFIO_DEVICE_PCI_HOT_RESET, VFIO_TYPE, VFIO_BASE + 13);
96ioctl_io_nr!(VFIO_DEVICE_QUERY_GFX_PLANE, VFIO_TYPE, VFIO_BASE + 14);
97ioctl_io_nr!(VFIO_DEVICE_GET_GFX_DMABUF, VFIO_TYPE, VFIO_BASE + 15);
98ioctl_io_nr!(VFIO_DEVICE_IOEVENTFD, VFIO_TYPE, VFIO_BASE + 16);
99ioctl_io_nr!(VFIO_IOMMU_GET_INFO, VFIO_TYPE, VFIO_BASE + 12);
100ioctl_io_nr!(VFIO_IOMMU_MAP_DMA, VFIO_TYPE, VFIO_BASE + 13);
101ioctl_io_nr!(VFIO_IOMMU_UNMAP_DMA, VFIO_TYPE, VFIO_BASE + 14);
102ioctl_io_nr!(VFIO_IOMMU_ENABLE, VFIO_TYPE, VFIO_BASE + 15);
103ioctl_io_nr!(VFIO_IOMMU_DISABLE, VFIO_TYPE, VFIO_BASE + 16);
104ioctl_io_nr!(VFIO_DEVICE_FEATURE, VFIO_TYPE, VFIO_BASE + 17);
105ioctl_io_nr!(VFIO_DEVICE_ACPI_DSM, VFIO_TYPE, VFIO_BASE + 18);
106
107ioctl_io_nr!(
108    PLAT_IRQ_FORWARD_SET,
109    PLAT_IRQ_FORWARD_TYPE,
110    PLAT_IRQ_FORWARD_BASE
111);
112
113ioctl_io_nr!(
114    ACPI_EVT_FORWARD_SET,
115    PLAT_IRQ_FORWARD_TYPE,
116    ACPI_EVT_FORWARD_BASE
117);