xref: /aosp_15_r20/external/crosvm/virtio_sys/src/virtio_ring.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 /* automatically generated by tools/bindgen-all-the-things */
2 
3 #![allow(clippy::missing_safety_doc)]
4 #![allow(clippy::undocumented_unsafe_blocks)]
5 #![allow(clippy::upper_case_acronyms)]
6 #![allow(non_upper_case_globals)]
7 #![allow(non_camel_case_types)]
8 #![allow(non_snake_case)]
9 #![allow(dead_code)]
10 
11 #[repr(C)]
12 #[derive(Default)]
13 pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
14 impl<T> __IncompleteArrayField<T> {
15     #[inline]
new() -> Self16     pub const fn new() -> Self {
17         __IncompleteArrayField(::std::marker::PhantomData, [])
18     }
19     #[inline]
as_ptr(&self) -> *const T20     pub fn as_ptr(&self) -> *const T {
21         self as *const _ as *const T
22     }
23     #[inline]
as_mut_ptr(&mut self) -> *mut T24     pub fn as_mut_ptr(&mut self) -> *mut T {
25         self as *mut _ as *mut T
26     }
27     #[inline]
as_slice(&self, len: usize) -> &[T]28     pub unsafe fn as_slice(&self, len: usize) -> &[T] {
29         ::std::slice::from_raw_parts(self.as_ptr(), len)
30     }
31     #[inline]
as_mut_slice(&mut self, len: usize) -> &mut [T]32     pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
33         ::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
34     }
35 }
36 impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result37     fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
38         fmt.write_str("__IncompleteArrayField")
39     }
40 }
41 pub const VRING_DESC_F_NEXT: u32 = 1;
42 pub const VRING_DESC_F_WRITE: u32 = 2;
43 pub const VRING_DESC_F_INDIRECT: u32 = 4;
44 pub const VRING_PACKED_DESC_F_AVAIL: u32 = 7;
45 pub const VRING_PACKED_DESC_F_USED: u32 = 15;
46 pub const VRING_USED_F_NO_NOTIFY: u32 = 1;
47 pub const VRING_AVAIL_F_NO_INTERRUPT: u32 = 1;
48 pub const VRING_PACKED_EVENT_FLAG_ENABLE: u32 = 0;
49 pub const VRING_PACKED_EVENT_FLAG_DISABLE: u32 = 1;
50 pub const VRING_PACKED_EVENT_FLAG_DESC: u32 = 2;
51 pub const VRING_PACKED_EVENT_F_WRAP_CTR: u32 = 15;
52 pub const VIRTIO_RING_F_INDIRECT_DESC: u32 = 28;
53 pub const VIRTIO_RING_F_EVENT_IDX: u32 = 29;
54 pub const VRING_AVAIL_ALIGN_SIZE: u32 = 2;
55 pub const VRING_USED_ALIGN_SIZE: u32 = 4;
56 pub const VRING_DESC_ALIGN_SIZE: u32 = 16;
57 pub type __le16 = u16;
58 pub type __le32 = u32;
59 pub type __le64 = u64;
60 pub type __virtio16 = u16;
61 pub type __virtio32 = u32;
62 pub type __virtio64 = u64;
63 #[repr(C)]
64 #[derive(Debug, Default, Copy, Clone)]
65 pub struct vring_desc {
66     pub addr: __virtio64,
67     pub len: __virtio32,
68     pub flags: __virtio16,
69     pub next: __virtio16,
70 }
71 #[repr(C)]
72 #[derive(Debug, Default)]
73 pub struct vring_avail {
74     pub flags: __virtio16,
75     pub idx: __virtio16,
76     pub ring: __IncompleteArrayField<__virtio16>,
77 }
78 #[repr(C)]
79 #[derive(Debug, Default, Copy, Clone)]
80 pub struct vring_used_elem {
81     pub id: __virtio32,
82     pub len: __virtio32,
83 }
84 pub type vring_used_elem_t = vring_used_elem;
85 #[repr(C)]
86 #[derive(Debug, Default)]
87 pub struct vring_used {
88     pub flags: __virtio16,
89     pub idx: __virtio16,
90     pub ring: __IncompleteArrayField<vring_used_elem_t>,
91 }
92 pub type vring_desc_t = vring_desc;
93 pub type vring_avail_t = vring_avail;
94 pub type vring_used_t = vring_used;
95 #[repr(C)]
96 #[derive(Debug, Copy, Clone)]
97 pub struct vring {
98     pub num: ::std::os::raw::c_uint,
99     pub desc: *mut vring_desc_t,
100     pub avail: *mut vring_avail_t,
101     pub used: *mut vring_used_t,
102 }
103 impl Default for vring {
default() -> Self104     fn default() -> Self {
105         let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
106         unsafe {
107             ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
108             s.assume_init()
109         }
110     }
111 }
112 #[repr(C)]
113 #[derive(Debug, Default, Copy, Clone)]
114 pub struct vring_packed_desc_event {
115     pub off_wrap: __le16,
116     pub flags: __le16,
117 }
118 #[repr(C)]
119 #[derive(Debug, Default, Copy, Clone)]
120 pub struct vring_packed_desc {
121     pub addr: __le64,
122     pub len: __le32,
123     pub id: __le16,
124     pub flags: __le16,
125 }
126