Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ pub const DEFAULT_STACK_SIZE: usize = 0x0001_0000;
pub(crate) const USER_STACK_SIZE: usize = 0x0010_0000;

#[cfg(any(
all(
not(any(
all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci")),
feature = "rtl8139",
)),
feature = "virtio-net",
),
feature = "virtio-net",
feature = "fuse",
feature = "vsock",
feature = "console",
Expand Down
43 changes: 5 additions & 38 deletions src/drivers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,7 @@ pub mod mmio;
pub mod net;
#[cfg(feature = "pci")]
pub mod pci;
#[cfg(any(
all(
not(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci"))),
not(feature = "rtl8139"),
feature = "virtio-net",
),
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[cfg(feature = "virtio")]
pub mod virtio;
#[cfg(feature = "vsock")]
pub mod vsock;
Expand All @@ -38,51 +29,27 @@ pub(crate) type InterruptHandlerQueue = VecDeque<fn()>;
/// passed on to higher layers.
pub mod error {
#[cfg(any(
feature = "virtio",
all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci")),
feature = "rtl8139",
feature = "virtio-net",
feature = "fuse",
feature = "vsock",
feature = "console",
))]
use thiserror::Error;

#[cfg(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci")))]
use crate::drivers::net::gem::GEMError;
#[cfg(feature = "rtl8139")]
use crate::drivers::net::rtl8139::RTL8139Error;
#[cfg(any(
all(
not(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci"))),
not(feature = "rtl8139"),
feature = "virtio-net",
),
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[cfg(feature = "virtio")]
use crate::drivers::virtio::error::VirtioError;

#[cfg(any(
feature = "virtio",
all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci")),
feature = "rtl8139",
feature = "virtio-net",
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[derive(Error, Debug)]
pub enum DriverError {
#[cfg(any(
all(
not(all(target_arch = "riscv64", feature = "gem-net", not(feature = "pci"))),
not(feature = "rtl8139"),
feature = "virtio-net",
),
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[cfg(feature = "virtio")]
#[error("Virtio driver failed: {0:?}")]
InitVirtioDevFail(#[from] VirtioError),

Expand Down
29 changes: 7 additions & 22 deletions src/drivers/pci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,17 @@ use crate::drivers::console::{VirtioConsoleDriver, VirtioUART};
use crate::drivers::fs::virtio_fs::VirtioFsDriver;
#[cfg(feature = "rtl8139")]
use crate::drivers::net::rtl8139::{self, RTL8139Driver};
#[cfg(all(not(feature = "rtl8139"), feature = "virtio-net",))]
#[cfg(all(not(feature = "rtl8139"), feature = "virtio-net"))]
use crate::drivers::net::virtio::VirtioNetDriver;
#[cfg(any(
all(feature = "virtio-net", not(feature = "rtl8139"),),
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[cfg(feature = "virtio")]
use crate::drivers::virtio::transport::pci as pci_virtio;
#[cfg(any(
all(feature = "virtio-net", not(feature = "rtl8139"),),
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[cfg(feature = "virtio")]
use crate::drivers::virtio::transport::pci::VirtioDriver;
#[cfg(feature = "vsock")]
use crate::drivers::vsock::VirtioVsockDriver;
#[allow(unused_imports)]
use crate::drivers::{Driver, InterruptHandlerQueue};
#[cfg(any(feature = "rtl8139", feature = "virtio-net",))]
#[cfg(any(feature = "rtl8139", feature = "virtio-net"))]
use crate::executor::device::NETWORK_DEVICE;
use crate::init_cell::InitCell;

Expand Down Expand Up @@ -449,7 +439,7 @@ pub(crate) fn get_interrupt_handlers() -> HashMap<InterruptLine, InterruptHandle
}
}

#[cfg(any(feature = "rtl8139", feature = "virtio-net",))]
#[cfg(any(feature = "rtl8139", feature = "virtio-net"))]
if let Some(device) = NETWORK_DEVICE.lock().as_ref() {
handlers
.entry(device.get_interrupt_number())
Expand Down Expand Up @@ -502,14 +492,9 @@ pub(crate) fn init() {
adapter.device_id()
);

#[cfg(any(
all(feature = "virtio-net", not(feature = "rtl8139"),),
feature = "fuse",
feature = "vsock",
feature = "console",
))]
#[cfg(feature = "virtio")]
match pci_virtio::init_device(adapter) {
#[cfg(all(not(feature = "rtl8139"), feature = "virtio-net",))]
#[cfg(all(not(feature = "rtl8139"), feature = "virtio-net"))]
Ok(VirtioDriver::Network(drv)) => *crate::executor::device::NETWORK_DEVICE.lock() = Some(drv),

#[cfg(feature = "console")]
Expand Down
Loading