msb_krun_devices/virtio/
mod.rs1use std;
10use std::any::Any;
11use std::io::Error as IOError;
12
13#[cfg(not(feature = "tee"))]
14pub mod balloon;
15#[allow(dead_code)]
16#[allow(non_camel_case_types)]
17pub mod bindings;
18#[cfg(feature = "blk")]
19pub mod block;
20pub mod console;
21pub mod descriptor_utils;
22pub mod device;
23pub mod file_traits;
24#[cfg(not(any(feature = "tee", feature = "aws-nitro")))]
25pub mod fs;
26#[cfg(feature = "gpu")]
27pub mod gpu;
28#[cfg(feature = "input")]
29pub mod input;
30pub mod linux_errno;
31mod mmio;
32#[cfg(feature = "net")]
33pub mod net;
34mod queue;
35#[cfg(not(feature = "tee"))]
36pub mod rng;
37#[cfg(feature = "snd")]
38pub mod snd;
39pub mod vsock;
40
41#[cfg(not(feature = "tee"))]
42pub use self::balloon::*;
43#[cfg(feature = "blk")]
44pub use self::block::{Block, CacheType};
45pub use self::console::*;
46pub use self::device::*;
47#[cfg(not(any(feature = "tee", feature = "aws-nitro")))]
48pub use self::fs::*;
49#[cfg(feature = "gpu")]
50pub use self::gpu::*;
51pub use self::mmio::*;
52#[cfg(feature = "net")]
53pub use self::net::Net;
54pub use self::queue::{Descriptor, DescriptorChain, Queue};
55#[cfg(not(feature = "tee"))]
56pub use self::rng::*;
57#[cfg(feature = "snd")]
58pub use self::snd::Snd;
59pub use self::vsock::*;
60
61mod device_status {
70 pub const INIT: u32 = 0;
71 pub const ACKNOWLEDGE: u32 = 1;
72 pub const DRIVER: u32 = 2;
73 pub const FAILED: u32 = 128;
74 pub const FEATURES_OK: u32 = 8;
75 pub const DRIVER_OK: u32 = 4;
76}
77
78pub const TYPE_NET: u32 = 1;
81pub const TYPE_BLOCK: u32 = 2;
82
83pub const VIRTIO_MMIO_INT_VRING: u32 = 0x01;
86pub const VIRTIO_MMIO_INT_CONFIG: u32 = 0x02;
87
88pub const NOTIFY_REG_OFFSET: u32 = 0x50;
91
92#[derive(Debug)]
93pub enum ActivateError {
94 EpollCtl(IOError),
95 BadActivate,
96}
97
98pub type ActivateResult = std::result::Result<(), ActivateError>;
99
100pub trait AsAny {
102 fn as_any(&self) -> &dyn Any;
103
104 fn as_mut_any(&mut self) -> &mut dyn Any;
105}
106impl<T: Any> AsAny for T {
107 fn as_any(&self) -> &dyn Any {
108 self
109 }
110
111 fn as_mut_any(&mut self) -> &mut dyn Any {
112 self
113 }
114}