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 13 use base::ioctl_io_nr; 14 15 pub mod plat; 16 pub mod vfio; 17 18 use crate::plat::ACPI_EVT_FORWARD_BASE; 19 use crate::plat::PLAT_IRQ_FORWARD_BASE; 20 use crate::plat::PLAT_IRQ_FORWARD_TYPE; 21 pub use crate::vfio::vfio_device_feature; 22 pub use crate::vfio::vfio_device_info; 23 pub use crate::vfio::vfio_device_low_power_entry_with_wakeup; 24 pub use crate::vfio::vfio_group_status; 25 pub use crate::vfio::vfio_info_cap_header; 26 pub use crate::vfio::vfio_iommu_type1_dma_map; 27 pub use crate::vfio::vfio_iommu_type1_dma_unmap; 28 pub use crate::vfio::vfio_iommu_type1_info; 29 pub use crate::vfio::vfio_iommu_type1_info_cap_iova_range; 30 pub use crate::vfio::vfio_iommu_type1_info_cap_iova_range_header; 31 pub use crate::vfio::vfio_iova_range; 32 pub use crate::vfio::vfio_irq_info; 33 pub use crate::vfio::vfio_irq_set; 34 pub use crate::vfio::vfio_region_info; 35 pub use crate::vfio::vfio_region_info_cap_sparse_mmap; 36 pub use crate::vfio::vfio_region_info_cap_type; 37 pub use crate::vfio::vfio_region_info_with_cap; 38 pub use crate::vfio::vfio_region_sparse_mmap_area; 39 pub use crate::vfio::VFIO_TYPE1v2_IOMMU; 40 use crate::vfio::VFIO_BASE; 41 pub use crate::vfio::VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY; 42 pub use crate::vfio::VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP; 43 pub use crate::vfio::VFIO_DEVICE_FEATURE_LOW_POWER_EXIT; 44 pub use crate::vfio::VFIO_DEVICE_FEATURE_SET; 45 pub use crate::vfio::VFIO_DEVICE_FLAGS_PCI; 46 pub use crate::vfio::VFIO_DEVICE_FLAGS_PLATFORM; 47 pub use crate::vfio::VFIO_DMA_MAP_FLAG_READ; 48 pub use crate::vfio::VFIO_DMA_MAP_FLAG_WRITE; 49 pub use crate::vfio::VFIO_GROUP_FLAGS_VIABLE; 50 pub use crate::vfio::VFIO_IOMMU_INFO_CAPS; 51 pub use crate::vfio::VFIO_IOMMU_INFO_PGSIZES; 52 pub use crate::vfio::VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE; 53 pub use crate::vfio::VFIO_IRQ_INFO_AUTOMASKED; 54 pub use crate::vfio::VFIO_IRQ_SET_ACTION_MASK; 55 pub use crate::vfio::VFIO_IRQ_SET_ACTION_TRIGGER; 56 pub use crate::vfio::VFIO_IRQ_SET_ACTION_UNMASK; 57 pub use crate::vfio::VFIO_IRQ_SET_DATA_EVENTFD; 58 pub use crate::vfio::VFIO_IRQ_SET_DATA_NONE; 59 pub use crate::vfio::VFIO_PCI_BAR0_REGION_INDEX; 60 pub use crate::vfio::VFIO_PCI_CONFIG_REGION_INDEX; 61 pub use crate::vfio::VFIO_PCI_INTX_IRQ_INDEX; 62 pub use crate::vfio::VFIO_PCI_MSIX_IRQ_INDEX; 63 pub use crate::vfio::VFIO_PCI_MSI_IRQ_INDEX; 64 pub use crate::vfio::VFIO_PCI_REQ_IRQ_INDEX; 65 pub use crate::vfio::VFIO_PCI_ROM_REGION_INDEX; 66 pub use crate::vfio::VFIO_PKVM_PVIOMMU; 67 pub use crate::vfio::VFIO_REGION_INFO_CAP_MSIX_MAPPABLE; 68 pub use crate::vfio::VFIO_REGION_INFO_CAP_SPARSE_MMAP; 69 pub use crate::vfio::VFIO_REGION_INFO_CAP_TYPE; 70 pub use crate::vfio::VFIO_REGION_INFO_FLAG_CAPS; 71 pub use crate::vfio::VFIO_REGION_INFO_FLAG_MMAP; 72 pub use crate::vfio::VFIO_REGION_INFO_FLAG_WRITE; 73 pub use crate::vfio::VFIO_REGION_SUBTYPE_INTEL_IGD_OPREGION; 74 pub use crate::vfio::VFIO_REGION_TYPE_PCI_VENDOR_TYPE; 75 use crate::vfio::VFIO_TYPE; 76 77 ioctl_io_nr!(VFIO_GET_API_VERSION, VFIO_TYPE, VFIO_BASE); 78 ioctl_io_nr!(VFIO_CHECK_EXTENSION, VFIO_TYPE, VFIO_BASE + 1); 79 ioctl_io_nr!(VFIO_SET_IOMMU, VFIO_TYPE, VFIO_BASE + 2); 80 ioctl_io_nr!(VFIO_GROUP_GET_STATUS, VFIO_TYPE, VFIO_BASE + 3); 81 ioctl_io_nr!(VFIO_GROUP_SET_CONTAINER, VFIO_TYPE, VFIO_BASE + 4); 82 ioctl_io_nr!(VFIO_GROUP_UNSET_CONTAINER, VFIO_TYPE, VFIO_BASE + 5); 83 ioctl_io_nr!(VFIO_GROUP_GET_DEVICE_FD, VFIO_TYPE, VFIO_BASE + 6); 84 ioctl_io_nr!(VFIO_DEVICE_GET_INFO, VFIO_TYPE, VFIO_BASE + 7); 85 ioctl_io_nr!(VFIO_DEVICE_GET_REGION_INFO, VFIO_TYPE, VFIO_BASE + 8); 86 ioctl_io_nr!(VFIO_DEVICE_GET_IRQ_INFO, VFIO_TYPE, VFIO_BASE + 9); 87 ioctl_io_nr!(VFIO_DEVICE_SET_IRQS, VFIO_TYPE, VFIO_BASE + 10); 88 ioctl_io_nr!(VFIO_DEVICE_RESET, VFIO_TYPE, VFIO_BASE + 11); 89 ioctl_io_nr!( 90 VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, 91 VFIO_TYPE, 92 VFIO_BASE + 12 93 ); 94 ioctl_io_nr!(VFIO_DEVICE_PCI_HOT_RESET, VFIO_TYPE, VFIO_BASE + 13); 95 ioctl_io_nr!(VFIO_DEVICE_QUERY_GFX_PLANE, VFIO_TYPE, VFIO_BASE + 14); 96 ioctl_io_nr!(VFIO_DEVICE_GET_GFX_DMABUF, VFIO_TYPE, VFIO_BASE + 15); 97 ioctl_io_nr!(VFIO_DEVICE_IOEVENTFD, VFIO_TYPE, VFIO_BASE + 16); 98 ioctl_io_nr!(VFIO_IOMMU_GET_INFO, VFIO_TYPE, VFIO_BASE + 12); 99 ioctl_io_nr!(VFIO_IOMMU_MAP_DMA, VFIO_TYPE, VFIO_BASE + 13); 100 ioctl_io_nr!(VFIO_IOMMU_UNMAP_DMA, VFIO_TYPE, VFIO_BASE + 14); 101 ioctl_io_nr!(VFIO_IOMMU_ENABLE, VFIO_TYPE, VFIO_BASE + 15); 102 ioctl_io_nr!(VFIO_IOMMU_DISABLE, VFIO_TYPE, VFIO_BASE + 16); 103 ioctl_io_nr!(VFIO_DEVICE_FEATURE, VFIO_TYPE, VFIO_BASE + 17); 104 ioctl_io_nr!(VFIO_DEVICE_ACPI_DSM, VFIO_TYPE, VFIO_BASE + 18); 105 106 ioctl_io_nr!( 107 PLAT_IRQ_FORWARD_SET, 108 PLAT_IRQ_FORWARD_TYPE, 109 PLAT_IRQ_FORWARD_BASE 110 ); 111 112 ioctl_io_nr!( 113 ACPI_EVT_FORWARD_SET, 114 PLAT_IRQ_FORWARD_TYPE, 115 ACPI_EVT_FORWARD_BASE 116 ); 117