diff --git a/src/drivers/mod.rs b/src/drivers/mod.rs index 90adec18a57281fcef019869ea65b92dc46a04dd..c521ae6363edb1043d5508e64bb4a142e0a2bf31 100644 --- a/src/drivers/mod.rs +++ b/src/drivers/mod.rs @@ -16,17 +16,22 @@ //#[cfg(not(feature = "newlib"))] pub mod net; +#[cfg(feature = "pci")] pub mod virtio; +#[cfg(feature = "pci")] use crate::drivers::error::DriverError; +#[cfg(feature = "pci")] pub type Result<T> = core::result::Result<T, DriverError>; /// A common error module for drivers. /// [DriverError](enums.drivererror.html) values will be /// passed on to higher layers. +#[cfg(feature = "pci")] pub mod error { use crate::drivers::virtio::error::VirtioError; use core::fmt; + #[derive(Debug)] pub enum DriverError { InitVirtioDevFail(VirtioError), diff --git a/src/drivers/net/mod.rs b/src/drivers/net/mod.rs index 04f2dbd47bbdcebc6ddb0a33ed1d1097530c37fa..19682cfe2e2f71e8c48c0cba933bcdc48bd7f1a8 100644 --- a/src/drivers/net/mod.rs +++ b/src/drivers/net/mod.rs @@ -5,6 +5,8 @@ // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to those terms. + +#[cfg(feature = "pci")] pub mod virtio_net; use crate::arch::kernel::percore::*; diff --git a/src/syscalls/interfaces/mod.rs b/src/syscalls/interfaces/mod.rs index abcb41d13baf541a3c488a54b5db229cbca9518c..bac29dafdd1d43651271a9309683037feb5f8706 100644 --- a/src/syscalls/interfaces/mod.rs +++ b/src/syscalls/interfaces/mod.rs @@ -166,6 +166,7 @@ pub trait SyscallInterface: Send + Sync { } fn receive_rx_buffer(&self) -> Result<(&'static [u8], usize), ()> { + #[cfg(feature = "pci")] match arch::kernel::pci::get_network_driver() { Some(driver) => driver.lock().receive_rx_buffer(), _ => Err(()), @@ -175,6 +176,7 @@ pub trait SyscallInterface: Send + Sync { } fn rx_buffer_consumed(&self, handle: usize) -> Result<(), ()> { + #[cfg(feature = "pci")] match arch::kernel::pci::get_network_driver() { Some(driver) => { driver.lock().rx_buffer_consumed(handle);