1 // Copyright 2022 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 //! This file was generated by the following commands and modified manually. 6 //! 7 //! ```shell 8 //! $ bindgen virtio_iommu.h \ 9 //! --allowlist-type "virtio_iommu.*" \ 10 //! --allowlist-var "VIRTIO_IOMMU_.*" \ 11 //! --with-derive-default \ 12 //! --no-layout-tests \ 13 //! --no-prepend-enum-name > protocol.rs 14 //! $ sed -i "s/__u/u/g" protocol.rs 15 //! $ sed -i "s/__le/Le/g" protocol.rs 16 //! 17 //! The main points of the manual modifications are as follows: 18 //! * Removed `head` and `tail` from each command struct. Instead, we process 19 //! them as separate payloads. 20 //! * Derive implementations of zerocopy traits as needed. 21 //! * Use of `packed` because removing `head` and `tail` introduces paddings 22 //! * Remove `IncompleteArrayField` 23 //! * Convert padding of [u8; 64usize] to [u64; 8usize]. According to the rust 24 //! doc, "Arrays of sizes from 0 to 32 (inclusive) implement the Default trait 25 //! if the element type allows it." 26 27 #![allow(dead_code)] 28 #![allow(non_camel_case_types)] 29 30 use data_model::Le16; 31 use data_model::Le32; 32 use data_model::Le64; 33 use zerocopy::FromBytes; 34 use zerocopy::Immutable; 35 use zerocopy::IntoBytes; 36 use zerocopy::KnownLayout; 37 38 pub const VIRTIO_IOMMU_F_INPUT_RANGE: u32 = 0; 39 pub const VIRTIO_IOMMU_F_DOMAIN_RANGE: u32 = 1; 40 pub const VIRTIO_IOMMU_F_MAP_UNMAP: u32 = 2; 41 pub const VIRTIO_IOMMU_F_BYPASS: u32 = 3; 42 pub const VIRTIO_IOMMU_F_PROBE: u32 = 4; 43 pub const VIRTIO_IOMMU_F_MMIO: u32 = 5; 44 pub const VIRTIO_IOMMU_T_ATTACH: u8 = 1; 45 pub const VIRTIO_IOMMU_T_DETACH: u8 = 2; 46 pub const VIRTIO_IOMMU_T_MAP: u8 = 3; 47 pub const VIRTIO_IOMMU_T_UNMAP: u8 = 4; 48 pub const VIRTIO_IOMMU_T_PROBE: u8 = 5; 49 pub const VIRTIO_IOMMU_S_OK: u8 = 0; 50 pub const VIRTIO_IOMMU_S_IOERR: u8 = 1; 51 pub const VIRTIO_IOMMU_S_UNSUPP: u8 = 2; 52 pub const VIRTIO_IOMMU_S_DEVERR: u8 = 3; 53 pub const VIRTIO_IOMMU_S_INVAL: u8 = 4; 54 pub const VIRTIO_IOMMU_S_RANGE: u8 = 5; 55 pub const VIRTIO_IOMMU_S_NOENT: u8 = 6; 56 pub const VIRTIO_IOMMU_S_FAULT: u8 = 7; 57 pub const VIRTIO_IOMMU_S_NOMEM: u8 = 8; 58 pub const VIRTIO_IOMMU_MAP_F_READ: u32 = 1; 59 pub const VIRTIO_IOMMU_MAP_F_WRITE: u32 = 2; 60 pub const VIRTIO_IOMMU_MAP_F_MMIO: u32 = 4; 61 pub const VIRTIO_IOMMU_MAP_F_MASK: u32 = 7; 62 pub const VIRTIO_IOMMU_PROBE_T_NONE: u32 = 0; 63 pub const VIRTIO_IOMMU_PROBE_T_RESV_MEM: u32 = 1; 64 pub const VIRTIO_IOMMU_PROBE_T_MASK: u32 = 4095; 65 pub const VIRTIO_IOMMU_RESV_MEM_T_RESERVED: u32 = 0; 66 pub const VIRTIO_IOMMU_RESV_MEM_T_MSI: u32 = 1; 67 pub const VIRTIO_IOMMU_FAULT_R_UNKNOWN: u32 = 0; 68 pub const VIRTIO_IOMMU_FAULT_R_DOMAIN: u32 = 1; 69 pub const VIRTIO_IOMMU_FAULT_R_MAPPING: u32 = 2; 70 pub const VIRTIO_IOMMU_FAULT_F_READ: u32 = 1; 71 pub const VIRTIO_IOMMU_FAULT_F_WRITE: u32 = 2; 72 pub const VIRTIO_IOMMU_FAULT_F_EXEC: u32 = 4; 73 pub const VIRTIO_IOMMU_FAULT_F_ADDRESS: u32 = 256; 74 75 #[repr(C, packed)] 76 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 77 pub struct virtio_iommu_range_64 { 78 pub start: Le64, 79 pub end: Le64, 80 } 81 82 #[repr(C, packed)] 83 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 84 pub struct virtio_iommu_range_32 { 85 pub start: Le32, 86 pub end: Le32, 87 } 88 89 #[repr(C, packed)] 90 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 91 pub struct virtio_iommu_config { 92 pub page_size_mask: Le64, 93 pub input_range: virtio_iommu_range_64, 94 pub domain_range: virtio_iommu_range_32, 95 pub probe_size: Le32, 96 } 97 98 #[repr(C, packed)] 99 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 100 pub struct virtio_iommu_req_head { 101 pub type_: u8, 102 pub reserved: [u8; 3usize], 103 } 104 105 #[repr(C, packed)] 106 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 107 pub struct virtio_iommu_req_tail { 108 pub status: u8, 109 pub reserved: [u8; 3usize], 110 } 111 112 #[repr(C, packed)] 113 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 114 pub struct virtio_iommu_req_attach { 115 pub domain: Le32, 116 pub endpoint: Le32, 117 pub reserved: [u8; 8usize], 118 } 119 120 #[repr(C, packed)] 121 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 122 pub struct virtio_iommu_req_detach { 123 pub domain: Le32, 124 pub endpoint: Le32, 125 pub reserved: [u8; 8usize], 126 } 127 128 #[repr(C, packed)] 129 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 130 pub struct virtio_iommu_req_map { 131 pub domain: Le32, 132 pub virt_start: Le64, 133 pub virt_end: Le64, 134 pub phys_start: Le64, 135 pub flags: Le32, 136 } 137 138 #[repr(C, packed)] 139 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 140 pub struct virtio_iommu_req_unmap { 141 pub domain: Le32, 142 pub virt_start: Le64, 143 pub virt_end: Le64, 144 pub reserved: [u8; 4usize], 145 } 146 147 #[repr(C, packed)] 148 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 149 pub struct virtio_iommu_probe_property { 150 pub type_: Le16, 151 pub length: Le16, 152 } 153 154 #[repr(C, packed)] 155 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 156 pub struct virtio_iommu_probe_resv_mem { 157 pub head: virtio_iommu_probe_property, 158 pub subtype: u8, 159 pub reserved: [u8; 3usize], 160 pub start: Le64, 161 pub end: Le64, 162 } 163 164 #[repr(C, packed)] 165 #[derive(Debug, Default, Copy, Clone, FromBytes, Immutable, IntoBytes, KnownLayout)] 166 pub struct virtio_iommu_req_probe { 167 pub endpoint: Le32, 168 pub reserved: [u64; 8usize], 169 } 170 171 #[repr(C, packed)] 172 #[derive(Debug, Default, Copy, Clone)] 173 pub struct virtio_iommu_fault { 174 pub reason: u8, 175 pub reserved: [u8; 3usize], 176 pub flags: Le32, 177 pub endpoint: Le32, 178 pub reserved2: [u8; 4usize], 179 pub address: Le64, 180 } 181