hermit/drivers/virtio/
mod.rs

1//! Virtio infrastructure.
2//!
3//! This module provides [`transport`] infrastructure as well as [`virtqueue`] infrastructure.
4
5pub mod transport;
6pub mod virtqueue;
7
8pub mod error {
9	use thiserror::Error;
10
11	#[cfg(feature = "console")]
12	pub use crate::drivers::console::error::VirtioConsoleError;
13	#[cfg(feature = "fuse")]
14	pub use crate::drivers::fs::virtio_fs::error::VirtioFsError;
15	#[cfg(all(
16		not(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci"))),
17		not(feature = "rtl8139"),
18		feature = "virtio-net",
19	))]
20	pub use crate::drivers::net::virtio::error::VirtioNetError;
21	#[cfg(feature = "pci")]
22	use crate::drivers::pci::error::PciError;
23	#[cfg(feature = "vsock")]
24	pub use crate::drivers::vsock::error::VirtioVsockError;
25
26	#[allow(dead_code)]
27	#[derive(Error, Debug)]
28	pub enum VirtioError {
29		#[cfg(feature = "pci")]
30		#[error(transparent)]
31		FromPci(PciError),
32
33		#[cfg(feature = "pci")]
34		#[error(
35			"Virtio driver failed, for device {0:x}, due to a missing or malformed common config!"
36		)]
37		NoComCfg(u16),
38
39		#[cfg(feature = "pci")]
40		#[error(
41			"Virtio driver failed, for device {0:x}, due to a missing or malformed ISR status config!"
42		)]
43		NoIsrCfg(u16),
44
45		#[cfg(feature = "pci")]
46		#[error(
47			"Virtio driver failed, for device {0:x}, due to a missing or malformed notification config!"
48		)]
49		NoNotifCfg(u16),
50
51		#[error("Device with id {0:#x} not supported.")]
52		DevNotSupported(u16),
53
54		#[cfg(all(
55			not(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci"))),
56			not(feature = "rtl8139"),
57			feature = "virtio-net",
58		))]
59		#[error(transparent)]
60		NetDriver(VirtioNetError),
61
62		#[cfg(feature = "fuse")]
63		#[error(transparent)]
64		FsDriver(VirtioFsError),
65
66		#[cfg(feature = "vsock")]
67		#[error(transparent)]
68		VsockDriver(VirtioVsockError),
69
70		#[cfg(feature = "console")]
71		#[error(transparent)]
72		ConsoleDriver(VirtioConsoleError),
73
74		#[cfg(not(feature = "pci"))]
75		#[error("Driver failure")]
76		Unknown,
77	}
78}