Skip to content

Commit

Permalink
feat(drivers/net): add GEM driver
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Kröning <[email protected]>
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
simonschoening and mkroening committed Nov 2, 2023
1 parent 80f1248 commit ac29025
Show file tree
Hide file tree
Showing 5 changed files with 762 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Check each feature
run: cargo hack check --package hermit-kernel --each-feature --no-dev-deps --target x86_64-unknown-none
run: cargo hack check --package hermit-kernel --each-feature --skip gem-net --no-dev-deps --target x86_64-unknown-none
env:
RUSTFLAGS:

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dhcpv4 = [
]
fs = ["pci"]
fsgsbase = []
gem-net = ["tcp"]
newlib = []
pci = []
rtl8139 = ["tcp", "pci"]
Expand Down
15 changes: 15 additions & 0 deletions src/drivers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub mod virtio;
pub mod error {
use core::fmt;

#[cfg(feature = "gem-net")]
use crate::drivers::net::gem::GEMError;
#[cfg(feature = "rtl8139")]
use crate::drivers::net::rtl8139::RTL8139Error;
#[cfg(any(
Expand All @@ -37,6 +39,8 @@ pub mod error {
InitVirtioDevFail(VirtioError),
#[cfg(feature = "rtl8139")]
InitRTL8139DevFail(RTL8139Error),
#[cfg(feature = "gem-net")]
InitGEMDevFail(GEMError),
}

#[cfg(any(
Expand All @@ -56,6 +60,13 @@ pub mod error {
}
}

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

impl fmt::Display for DriverError {
#[allow(unused_variables)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand All @@ -71,6 +82,10 @@ pub mod error {
DriverError::InitRTL8139DevFail(ref err) => {
write!(f, "RTL8139 driver failed: {err:?}")
}
#[cfg(feature = "gem-net")]
DriverError::InitGEMDevFail(ref err) => {
write!(f, "GEM driver failed: {err:?}")
}
}
}
}
Expand Down
Loading

0 comments on commit ac29025

Please sign in to comment.