Skip to content

Commit

Permalink
feat: remove lwIP support
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 May 2, 2024
1 parent 7a27cd7 commit b909218
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 112 deletions.
4 changes: 2 additions & 2 deletions src/arch/aarch64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<PhysAddr> {
get_physical_address::<BasePageSize>(virtual_address)
}

#[no_mangle]
pub extern "C" fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
#[cfg(any(feature = "fuse", feature = "tcp", feature = "udp"))]
pub fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
virtual_to_physical(virtual_address).unwrap()
}

Expand Down
4 changes: 2 additions & 2 deletions src/arch/riscv64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,8 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<PhysAddr> {
panic!("virtual_to_physical should never reach this point");
}

#[no_mangle]
pub extern "C" fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
#[cfg(any(feature = "fuse", feature = "tcp", feature = "udp"))]
pub fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
virtual_to_physical(virtual_address).unwrap()
}

Expand Down
3 changes: 1 addition & 2 deletions src/arch/x86_64/kernel/apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ fn default_apic() -> PhysAddr {
default_address
}

#[no_mangle]
pub extern "C" fn eoi() {
pub fn eoi() {
local_apic_write(IA32_X2APIC_EOI, APIC_EOI_ACK);
}

Expand Down
8 changes: 5 additions & 3 deletions src/arch/x86_64/kernel/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ use hashbrown::HashMap;
use hermit_sync::{InterruptSpinMutex, InterruptTicketMutex};
pub use x86_64::instructions::interrupts::{disable, enable, enable_and_hlt as enable_and_wait};
use x86_64::set_general_handler;
#[cfg(any(feature = "fuse", feature = "tcp", feature = "udp"))]
use x86_64::structures::idt;
use x86_64::structures::idt::InterruptDescriptorTable;
pub use x86_64::structures::idt::InterruptStackFrame as ExceptionStackFrame;
use x86_64::structures::idt::{self, InterruptDescriptorTable};

use crate::arch::x86_64::kernel::core_local::{core_scheduler, increment_irq_counter};
use crate::arch::x86_64::kernel::{apic, processor};
Expand Down Expand Up @@ -108,8 +110,8 @@ pub(crate) fn install() {
IRQ_NAMES.lock().insert(7, "FPU");
}

#[no_mangle]
pub extern "C" fn irq_install_handler(irq_number: u8, handler: idt::HandlerFunc) {
#[cfg(any(feature = "fuse", feature = "tcp", feature = "udp"))]
pub fn irq_install_handler(irq_number: u8, handler: idt::HandlerFunc) {
debug!("Install handler for interrupt {}", irq_number);

let mut idt = IDT.lock();
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<PhysAddr> {
}
}

#[no_mangle]
pub extern "C" fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
#[cfg(any(feature = "fuse", feature = "tcp", feature = "udp"))]
pub fn virt_to_phys(virtual_address: VirtAddr) -> PhysAddr {
virtual_to_physical(virtual_address).unwrap()
}

Expand Down
3 changes: 0 additions & 3 deletions src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ impl fmt::Write for Console {
}
}

#[cfg(feature = "newlib")]
pub static CONSOLE: InterruptTicketMutex<Console> = InterruptTicketMutex::new(Console(()));
#[cfg(not(feature = "newlib"))]
static CONSOLE: InterruptTicketMutex<Console> = InterruptTicketMutex::new(Console(()));

#[doc(hidden)]
Expand Down
11 changes: 0 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,9 @@ extern "C" fn initd(_arg: usize) {
fn runtime_entry(argc: i32, argv: *const *const u8, env: *const *const u8) -> !;
#[cfg(all(not(test), any(feature = "nostd", feature = "common-os")))]
fn main(argc: i32, argv: *const *const u8, env: *const *const u8);
#[cfg(feature = "newlib")]
fn init_lwip();
#[cfg(feature = "newlib")]
fn init_rtl8139_netif(freq: u32) -> i32;
}

if !env::is_uhyve() {
// initialize LwIP library for newlib-based applications
#[cfg(feature = "newlib")]
unsafe {
init_lwip();
init_rtl8139_netif(processor::get_frequency() as u32);
}

info!("Hermit is running on common system!");
} else {
info!("Hermit is running on uhyve!");
Expand Down
12 changes: 0 additions & 12 deletions src/scheduler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,6 @@ impl PerCoreScheduler {
})
}

#[cfg(feature = "newlib")]
#[inline]
pub fn set_lwip_errno(&self, errno: i32) {
without_interrupts(|| self.current_task.borrow_mut().lwip_errno = errno);
}

#[cfg(feature = "newlib")]
#[inline]
pub fn get_lwip_errno(&self) -> i32 {
without_interrupts(|| self.current_task.borrow().lwip_errno)
}

#[inline]
pub fn get_current_task_id(&self) -> TaskId {
without_interrupts(|| self.current_task.borrow().id)
Expand Down
7 changes: 0 additions & 7 deletions src/scheduler/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,6 @@ pub(crate) struct Task {
// Physical address of the 1st level page table
#[cfg(all(target_arch = "x86_64", feature = "common-os"))]
pub root_page_table: usize,
/// lwIP error code for this task
#[cfg(feature = "newlib")]
pub lwip_errno: i32,
}

pub(crate) trait TaskFrame {
Expand Down Expand Up @@ -437,8 +434,6 @@ impl Task {
tls: None,
#[cfg(all(target_arch = "x86_64", feature = "common-os"))]
root_page_table: arch::create_new_root_page_table(),
#[cfg(feature = "newlib")]
lwip_errno: 0,
}
}

Expand Down Expand Up @@ -507,8 +502,6 @@ impl Task {
tls: None,
#[cfg(all(target_arch = "x86_64", feature = "common-os"))]
root_page_table: *crate::scheduler::BOOT_ROOT_PAGE_TABLE.get().unwrap(),
#[cfg(feature = "newlib")]
lwip_errno: 0,
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/syscalls/interfaces/uhyve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@ use x86::io::*;
use crate::arch;
use crate::arch::mm::{paging, PhysAddr, VirtAddr};
use crate::syscalls::interfaces::SyscallInterface;
#[cfg(feature = "newlib")]
use crate::syscalls::lwip::sys_lwip_get_errno;
#[cfg(feature = "newlib")]
use crate::syscalls::{LWIP_FD_BIT, LWIP_LOCK};

const UHYVE_PORT_EXIT: u16 = 0x540;
const UHYVE_PORT_CMDSIZE: u16 = 0x740;
const UHYVE_PORT_CMDVAL: u16 = 0x780;

#[cfg(feature = "newlib")]
extern "C" {
fn lwip_write(fd: i32, buf: *const u8, len: usize) -> i32;
fn lwip_read(fd: i32, buf: *mut u8, len: usize) -> i32;
}

/// forward a request to the hypervisor uhyve
#[inline]
#[cfg(target_arch = "x86_64")]
Expand Down
34 changes: 0 additions & 34 deletions src/syscalls/lwip.rs

This file was deleted.

8 changes: 0 additions & 8 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ mod condvar;
mod entropy;
mod futex;
mod interfaces;
#[cfg(feature = "newlib")]
mod lwip;
mod processor;
#[cfg(feature = "newlib")]
mod recmutex;
Expand All @@ -49,12 +47,6 @@ pub(crate) mod table;
mod tasks;
mod timer;

#[cfg(feature = "newlib")]
const LWIP_FD_BIT: i32 = 1 << 30;

#[cfg(feature = "newlib")]
pub(crate) static LWIP_LOCK: InterruptTicketMutex<()> = InterruptTicketMutex::new(());

pub(crate) static SYS: Lazy<&'static dyn SyscallInterface> = Lazy::new(|| {
if env::is_uhyve() {
&self::interfaces::Uhyve
Expand Down
17 changes: 1 addition & 16 deletions xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,7 @@ impl Build {
let archive = self.cargo_build.artifact.dist_archive();

let syscall_symbols = archive.syscall_symbols()?;
let explicit_exports = [
"_start",
"__bss_start",
"mcount",
"runtime_entry",
// lwIP functions (C runtime)
"init_lwip",
"lwip_read",
"lwip_write",
// lwIP rtl8139 driver
"init_rtl8139_netif",
"irq_install_handler",
"virt_to_phys",
"eoi",
]
.into_iter();
let explicit_exports = ["_start", "__bss_start", "mcount", "runtime_entry"].into_iter();

let symbols = explicit_exports.chain(syscall_symbols.iter().map(String::as_str));

Expand Down

0 comments on commit b909218

Please sign in to comment.