Skip to content
Snippets Groups Projects
Unverified Commit 4daec2a2 authored by bors[bot]'s avatar bors[bot] Committed by GitHub
Browse files

Merge #144


144: reactivate the possibility to disable pci/acpi support r=stlankes a=stlankes



Co-authored-by: Stefan Lankes's avatarStefan Lankes <slankes@eonerc.rwth-aachen.de>
parents 535eef9a 71118509
No related branches found
No related tags found
No related merge requests found
......@@ -180,7 +180,7 @@ pub fn add_local_apic_id(id: u8) {
}
#[cfg(not(feature = "acpi"))]
fn detect_from_acpi() -> Result<usize, ()> {
fn detect_from_acpi() -> Result<PhysAddr, ()> {
// dummy implementation if acpi support is disabled
Err(())
}
......
......@@ -25,6 +25,7 @@ use crate::scheduler::CoreId;
#[cfg(feature = "acpi")]
pub mod acpi;
pub mod apic;
#[cfg(feature = "pci")]
pub mod fuse;
pub mod gdt;
pub mod idt;
......@@ -44,8 +45,11 @@ mod smp_boot_code;
pub mod systemtime;
#[cfg(feature = "vga")]
mod vga;
#[cfg(feature = "pci")]
pub mod virtio;
#[cfg(feature = "pci")]
pub mod virtio_fs;
#[cfg(feature = "pci")]
pub mod virtio_net;
#[cfg(not(test))]
......
......@@ -24,6 +24,7 @@ const POLL_PERIOD: u64 = 20_000;
fn set_polling_mode(value: bool) {
// is the driver already in polling mode?
if POLLING.swap(value, Ordering::SeqCst) != value {
#[cfg(feature = "pci")]
if let Some(driver) = crate::arch::kernel::pci::get_network_driver() {
driver.lock().set_polling_mode(value);
}
......@@ -65,6 +66,7 @@ pub fn netwait_and_wakeup(handles: &[usize], millis: Option<u64>) {
}
if reset_nic {
#[cfg(feature = "pci")]
if let Some(driver) = crate::arch::kernel::pci::get_network_driver() {
driver.lock().set_polling_mode(false);
};
......
......@@ -287,7 +287,7 @@ extern "C" fn initd(_arg: usize) {
}
// Initialize PCI Drivers if on x86_64
#[cfg(target_arch = "x86_64")]
#[cfg(all(target_arch = "x86_64", feature = "pci"))]
x86_64::kernel::pci::init_drivers();
syscalls::init();
......
......@@ -116,48 +116,67 @@ pub trait SyscallInterface: Send + Sync {
}
fn get_mac_address(&self) -> Result<[u8; 6], ()> {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => Ok(driver.lock().get_mac_address()),
_ => Err(()),
}
#[cfg(not(feature = "pci"))]
Err(())
}
fn get_mtu(&self) -> Result<u16, ()> {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => Ok(driver.lock().get_mtu()),
_ => Err(()),
}
#[cfg(not(feature = "pci"))]
Err(())
}
fn has_packet(&self) -> bool {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => driver.lock().has_packet(),
_ => false,
}
#[cfg(not(feature = "pci"))]
false
}
fn get_tx_buffer(&self, len: usize) -> Result<(*mut u8, usize), ()> {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => driver.lock().get_tx_buffer(len),
_ => Err(()),
}
#[cfg(not(feature = "pci"))]
Err(())
}
fn send_tx_buffer(&self, handle: usize, len: usize) -> Result<(), ()> {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => driver.lock().send_tx_buffer(handle, len),
_ => Err(()),
}
#[cfg(not(feature = "pci"))]
Err(())
}
fn receive_rx_buffer(&self) -> Result<&'static [u8], ()> {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => driver.lock().receive_rx_buffer(),
_ => Err(()),
}
#[cfg(not(feature = "pci"))]
Err(())
}
fn rx_buffer_consumed(&self) -> Result<(), ()> {
#[cfg(feature = "pci")]
match arch::kernel::pci::get_network_driver() {
Some(driver) => {
driver.lock().rx_buffer_consumed();
......@@ -165,6 +184,8 @@ pub trait SyscallInterface: Send + Sync {
}
_ => Err(()),
}
#[cfg(not(feature = "pci"))]
Err(())
}
#[cfg(not(target_arch = "x86_64"))]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment