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::{AsBytes, FromZeroes, FromBytes} 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::AsBytes; 34 use zerocopy::FromBytes; 35 use zerocopy::FromZeroes; 36 37 pub const VIRTIO_IOMMU_F_INPUT_RANGE: u32 = 0; 38 pub const VIRTIO_IOMMU_F_DOMAIN_RANGE: u32 = 1; 39 pub const VIRTIO_IOMMU_F_MAP_UNMAP: u32 = 2; 40 pub const VIRTIO_IOMMU_F_BYPASS: u32 = 3; 41 pub const VIRTIO_IOMMU_F_PROBE: u32 = 4; 42 pub const VIRTIO_IOMMU_F_MMIO: u32 = 5; 43 pub const VIRTIO_IOMMU_T_ATTACH: u8 = 1; 44 pub const VIRTIO_IOMMU_T_DETACH: u8 = 2; 45 pub const VIRTIO_IOMMU_T_MAP: u8 = 3; 46 pub const VIRTIO_IOMMU_T_UNMAP: u8 = 4; 47 pub const VIRTIO_IOMMU_T_PROBE: u8 = 5; 48 pub const VIRTIO_IOMMU_S_OK: u8 = 0; 49 pub const VIRTIO_IOMMU_S_IOERR: u8 = 1; 50 pub const VIRTIO_IOMMU_S_UNSUPP: u8 = 2; 51 pub const VIRTIO_IOMMU_S_DEVERR: u8 = 3; 52 pub const VIRTIO_IOMMU_S_INVAL: u8 = 4; 53 pub const VIRTIO_IOMMU_S_RANGE: u8 = 5; 54 pub const VIRTIO_IOMMU_S_NOENT: u8 = 6; 55 pub const VIRTIO_IOMMU_S_FAULT: u8 = 7; 56 pub const VIRTIO_IOMMU_S_NOMEM: u8 = 8; 57 pub const VIRTIO_IOMMU_MAP_F_READ: u32 = 1; 58 pub const VIRTIO_IOMMU_MAP_F_WRITE: u32 = 2; 59 pub const VIRTIO_IOMMU_MAP_F_MMIO: u32 = 4; 60 pub const VIRTIO_IOMMU_MAP_F_MASK: u32 = 7; 61 pub const VIRTIO_IOMMU_PROBE_T_NONE: u32 = 0; 62 pub const VIRTIO_IOMMU_PROBE_T_RESV_MEM: u32 = 1; 63 pub const VIRTIO_IOMMU_PROBE_T_MASK: u32 = 4095; 64 pub const VIRTIO_IOMMU_RESV_MEM_T_RESERVED: u32 = 0; 65 pub const VIRTIO_IOMMU_RESV_MEM_T_MSI: u32 = 1; 66 pub const VIRTIO_IOMMU_FAULT_R_UNKNOWN: u32 = 0; 67 pub const VIRTIO_IOMMU_FAULT_R_DOMAIN: u32 = 1; 68 pub const VIRTIO_IOMMU_FAULT_R_MAPPING: u32 = 2; 69 pub const VIRTIO_IOMMU_FAULT_F_READ: u32 = 1; 70 pub const VIRTIO_IOMMU_FAULT_F_WRITE: u32 = 2; 71 pub const VIRTIO_IOMMU_FAULT_F_EXEC: u32 = 4; 72 pub const VIRTIO_IOMMU_FAULT_F_ADDRESS: u32 = 256; 73 74 #[repr(C, packed)] 75 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 76 pub struct virtio_iommu_range_64 { 77 pub start: Le64, 78 pub end: Le64, 79 } 80 81 #[repr(C, packed)] 82 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 83 pub struct virtio_iommu_range_32 { 84 pub start: Le32, 85 pub end: Le32, 86 } 87 88 #[repr(C, packed)] 89 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 90 pub struct virtio_iommu_config { 91 pub page_size_mask: Le64, 92 pub input_range: virtio_iommu_range_64, 93 pub domain_range: virtio_iommu_range_32, 94 pub probe_size: Le32, 95 } 96 97 #[repr(C, packed)] 98 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 99 pub struct virtio_iommu_req_head { 100 pub type_: u8, 101 pub reserved: [u8; 3usize], 102 } 103 104 #[repr(C, packed)] 105 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 106 pub struct virtio_iommu_req_tail { 107 pub status: u8, 108 pub reserved: [u8; 3usize], 109 } 110 111 #[repr(C, packed)] 112 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 113 pub struct virtio_iommu_req_attach { 114 pub domain: Le32, 115 pub endpoint: Le32, 116 pub reserved: [u8; 8usize], 117 } 118 119 #[repr(C, packed)] 120 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 121 pub struct virtio_iommu_req_detach { 122 pub domain: Le32, 123 pub endpoint: Le32, 124 pub reserved: [u8; 8usize], 125 } 126 127 #[repr(C, packed)] 128 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 129 pub struct virtio_iommu_req_map { 130 pub domain: Le32, 131 pub virt_start: Le64, 132 pub virt_end: Le64, 133 pub phys_start: Le64, 134 pub flags: Le32, 135 } 136 137 #[repr(C, packed)] 138 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 139 pub struct virtio_iommu_req_unmap { 140 pub domain: Le32, 141 pub virt_start: Le64, 142 pub virt_end: Le64, 143 pub reserved: [u8; 4usize], 144 } 145 146 #[repr(C, packed)] 147 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 148 pub struct virtio_iommu_probe_property { 149 pub type_: Le16, 150 pub length: Le16, 151 } 152 153 #[repr(C, packed)] 154 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 155 pub struct virtio_iommu_probe_resv_mem { 156 pub head: virtio_iommu_probe_property, 157 pub subtype: u8, 158 pub reserved: [u8; 3usize], 159 pub start: Le64, 160 pub end: Le64, 161 } 162 163 #[repr(C, packed)] 164 #[derive(Debug, Default, Copy, Clone, AsBytes, FromZeroes, FromBytes)] 165 pub struct virtio_iommu_req_probe { 166 pub endpoint: Le32, 167 pub reserved: [u64; 8usize], 168 } 169 170 #[repr(C, packed)] 171 #[derive(Debug, Default, Copy, Clone)] 172 pub struct virtio_iommu_fault { 173 pub reason: u8, 174 pub reserved: [u8; 3usize], 175 pub flags: Le32, 176 pub endpoint: Le32, 177 pub reserved2: [u8; 4usize], 178 pub address: Le64, 179 } 180