virtio_sys/
virtio_ring.rs

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