virtio_sys/
virtio_ring.rs

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)]
13pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]);
14impl<T> __IncompleteArrayField<T> {
15    #[inline]
16    pub const fn new() -> Self {
17        __IncompleteArrayField(::std::marker::PhantomData, [])
18    }
19    #[inline]
20    pub fn as_ptr(&self) -> *const T {
21        self as *const _ as *const T
22    }
23    #[inline]
24    pub fn as_mut_ptr(&mut self) -> *mut T {
25        self as *mut _ as *mut T
26    }
27    #[inline]
28    pub unsafe fn as_slice(&self, len: usize) -> &[T] {
29        ::std::slice::from_raw_parts(self.as_ptr(), len)
30    }
31    #[inline]
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}
36impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
37    fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
38        fmt.write_str("__IncompleteArrayField")
39    }
40}
41pub const VRING_DESC_F_NEXT: u32 = 1;
42pub const VRING_DESC_F_WRITE: u32 = 2;
43pub const VRING_DESC_F_INDIRECT: u32 = 4;
44pub const VRING_PACKED_DESC_F_AVAIL: u32 = 7;
45pub const VRING_PACKED_DESC_F_USED: u32 = 15;
46pub const VRING_USED_F_NO_NOTIFY: u32 = 1;
47pub const VRING_AVAIL_F_NO_INTERRUPT: u32 = 1;
48pub const VRING_PACKED_EVENT_FLAG_ENABLE: u32 = 0;
49pub const VRING_PACKED_EVENT_FLAG_DISABLE: u32 = 1;
50pub const VRING_PACKED_EVENT_FLAG_DESC: u32 = 2;
51pub const VRING_PACKED_EVENT_F_WRAP_CTR: u32 = 15;
52pub const VIRTIO_RING_F_INDIRECT_DESC: u32 = 28;
53pub const VIRTIO_RING_F_EVENT_IDX: u32 = 29;
54pub const VRING_AVAIL_ALIGN_SIZE: u32 = 2;
55pub const VRING_USED_ALIGN_SIZE: u32 = 4;
56pub const VRING_DESC_ALIGN_SIZE: u32 = 16;
57pub type __le16 = u16;
58pub type __le32 = u32;
59pub type __le64 = u64;
60pub type __virtio16 = u16;
61pub type __virtio32 = u32;
62pub type __virtio64 = u64;
63#[repr(C)]
64#[derive(Debug, Default, Copy, Clone)]
65pub 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)]
73pub 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)]
80pub struct vring_used_elem {
81    pub id: __virtio32,
82    pub len: __virtio32,
83}
84pub type vring_used_elem_t = vring_used_elem;
85#[repr(C)]
86#[derive(Debug, Default)]
87pub struct vring_used {
88    pub flags: __virtio16,
89    pub idx: __virtio16,
90    pub ring: __IncompleteArrayField<vring_used_elem_t>,
91}
92pub type vring_desc_t = vring_desc;
93pub type vring_avail_t = vring_avail;
94pub type vring_used_t = vring_used;
95#[repr(C)]
96#[derive(Debug, Copy, Clone)]
97pub 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}
103impl Default for vring {
104    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)]
114pub struct vring_packed_desc_event {
115    pub off_wrap: __le16,
116    pub flags: __le16,
117}
118#[repr(C)]
119#[derive(Debug, Default, Copy, Clone)]
120pub struct vring_packed_desc {
121    pub addr: __le64,
122    pub len: __le32,
123    pub id: __le16,
124    pub flags: __le16,
125}