#[cfg(feature = "fs")]
pub mod fs;
#[cfg(not(feature = "pci"))]
pub mod mmio;
#[cfg(feature = "tcp")]
pub mod net;
#[cfg(feature = "pci")]
pub mod pci;
#[cfg(any(all(feature = "tcp", not(feature = "rtl8139")), feature = "fs"))]
pub mod virtio;
pub mod error {
use core::fmt;
#[cfg(feature = "rtl8139")]
use crate::drivers::net::rtl8139::RTL8139Error;
#[cfg(any(all(feature = "tcp", not(feature = "rtl8139")), feature = "fs"))]
use crate::drivers::virtio::error::VirtioError;
#[derive(Debug)]
pub enum DriverError {
#[cfg(any(all(feature = "tcp", not(feature = "rtl8139")), feature = "fs"))]
InitVirtioDevFail(VirtioError),
#[cfg(feature = "rtl8139")]
InitRTL8139DevFail(RTL8139Error),
}
#[cfg(any(all(feature = "tcp", not(feature = "rtl8139")), feature = "fs"))]
impl From<VirtioError> for DriverError {
fn from(err: VirtioError) -> Self {
DriverError::InitVirtioDevFail(err)
}
}
#[cfg(feature = "rtl8139")]
impl From<RTL8139Error> for DriverError {
fn from(err: RTL8139Error) -> Self {
DriverError::InitRTL8139DevFail(err)
}
}
impl fmt::Display for DriverError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
#[cfg(any(all(feature = "tcp", not(feature = "rtl8139")), feature = "fs"))]
DriverError::InitVirtioDevFail(ref err) => {
write!(f, "Virtio driver failed: {err:?}")
}
#[cfg(feature = "rtl8139")]
DriverError::InitRTL8139DevFail(ref err) => {
write!(f, "RTL8139 driver failed: {err:?}")
}
}
}
}
}