Skip to content

Commit

Permalink
Add GEM network driver
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed Jul 22, 2023
1 parent d0d7081 commit 1684bd0
Show file tree
Hide file tree
Showing 3 changed files with 779 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/drivers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub mod virtio;
pub mod error {
use core::fmt;

#[cfg(target_arch = "riscv64")]
use crate::drivers::net::gem::GEMError;
#[cfg(all(feature = "pci", not(target_arch = "aarch64")))]
use crate::drivers::net::rtl8139::RTL8139Error;
use crate::drivers::virtio::error::VirtioError;
Expand All @@ -21,6 +23,8 @@ pub mod error {
InitVirtioDevFail(VirtioError),
#[cfg(all(feature = "pci", not(target_arch = "aarch64")))]
InitRTL8139DevFail(RTL8139Error),
#[cfg(target_arch = "riscv64")]
InitGEMDevFail(GEMError),
}

impl From<VirtioError> for DriverError {
Expand All @@ -36,6 +40,13 @@ pub mod error {
}
}

#[cfg(target_arch = "riscv64")]
impl From<GEMError> for DriverError {
fn from(err: GEMError) -> Self {
DriverError::InitGEMDevFail(err)
}
}

impl fmt::Display for DriverError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Expand All @@ -46,6 +57,10 @@ pub mod error {
DriverError::InitRTL8139DevFail(ref err) => {
write!(f, "RTL8139 driver failed: {err:?}")
}
#[cfg(target_arch = "riscv64")]
DriverError::InitGEMDevFail(ref err) => {
write!(f, "GEM driver failed: {err:?}")
}
}
}
}
Expand Down
Loading

0 comments on commit 1684bd0

Please sign in to comment.