Skip to content

Commit 657edb5

Browse files
committed
feat(newlib): remove lwIP support
Signed-off-by: Martin Kröning <[email protected]>
1 parent 7a27cd7 commit 657edb5

File tree

13 files changed

+13
-112
lines changed

13 files changed

+13
-112
lines changed

src/arch/aarch64/mm/paging.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<PhysAddr> {
578578
get_physical_address::<BasePageSize>(virtual_address)
579579
}
580580

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

src/arch/riscv64/mm/paging.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<PhysAddr> {
584584
panic!("virtual_to_physical should never reach this point");
585585
}
586586

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

src/arch/x86_64/kernel/apic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ fn default_apic() -> PhysAddr {
453453
default_address
454454
}
455455

456-
#[no_mangle]
457-
pub extern "C" fn eoi() {
456+
pub fn eoi() {
458457
local_apic_write(IA32_X2APIC_EOI, APIC_EOI_ACK);
459458
}
460459

src/arch/x86_64/kernel/interrupts.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ use hashbrown::HashMap;
77
use hermit_sync::{InterruptSpinMutex, InterruptTicketMutex};
88
pub use x86_64::instructions::interrupts::{disable, enable, enable_and_hlt as enable_and_wait};
99
use x86_64::set_general_handler;
10+
#[cfg(any(feature = "fuse", feature = "tcp", feature = "udp"))]
11+
use x86_64::structures::idt;
12+
use x86_64::structures::idt::InterruptDescriptorTable;
1013
pub use x86_64::structures::idt::InterruptStackFrame as ExceptionStackFrame;
11-
use x86_64::structures::idt::{self, InterruptDescriptorTable};
1214

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

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

115117
let mut idt = IDT.lock();

src/arch/x86_64/mm/paging.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> Option<PhysAddr> {
118118
}
119119
}
120120

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

src/console.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ impl fmt::Write for Console {
2121
}
2222
}
2323

24-
#[cfg(feature = "newlib")]
25-
pub static CONSOLE: InterruptTicketMutex<Console> = InterruptTicketMutex::new(Console(()));
26-
#[cfg(not(feature = "newlib"))]
2724
static CONSOLE: InterruptTicketMutex<Console> = InterruptTicketMutex::new(Console(()));
2825

2926
#[doc(hidden)]

src/lib.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,9 @@ extern "C" fn initd(_arg: usize) {
130130
fn runtime_entry(argc: i32, argv: *const *const u8, env: *const *const u8) -> !;
131131
#[cfg(all(not(test), any(feature = "nostd", feature = "common-os")))]
132132
fn main(argc: i32, argv: *const *const u8, env: *const *const u8);
133-
#[cfg(feature = "newlib")]
134-
fn init_lwip();
135-
#[cfg(feature = "newlib")]
136-
fn init_rtl8139_netif(freq: u32) -> i32;
137133
}
138134

139135
if !env::is_uhyve() {
140-
// initialize LwIP library for newlib-based applications
141-
#[cfg(feature = "newlib")]
142-
unsafe {
143-
init_lwip();
144-
init_rtl8139_netif(processor::get_frequency() as u32);
145-
}
146-
147136
info!("Hermit is running on common system!");
148137
} else {
149138
info!("Hermit is running on uhyve!");

src/scheduler/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -442,18 +442,6 @@ impl PerCoreScheduler {
442442
})
443443
}
444444

445-
#[cfg(feature = "newlib")]
446-
#[inline]
447-
pub fn set_lwip_errno(&self, errno: i32) {
448-
without_interrupts(|| self.current_task.borrow_mut().lwip_errno = errno);
449-
}
450-
451-
#[cfg(feature = "newlib")]
452-
#[inline]
453-
pub fn get_lwip_errno(&self) -> i32 {
454-
without_interrupts(|| self.current_task.borrow().lwip_errno)
455-
}
456-
457445
#[inline]
458446
pub fn get_current_task_id(&self) -> TaskId {
459447
without_interrupts(|| self.current_task.borrow().id)

src/scheduler/task.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,6 @@ pub(crate) struct Task {
399399
// Physical address of the 1st level page table
400400
#[cfg(all(target_arch = "x86_64", feature = "common-os"))]
401401
pub root_page_table: usize,
402-
/// lwIP error code for this task
403-
#[cfg(feature = "newlib")]
404-
pub lwip_errno: i32,
405402
}
406403

407404
pub(crate) trait TaskFrame {
@@ -437,8 +434,6 @@ impl Task {
437434
tls: None,
438435
#[cfg(all(target_arch = "x86_64", feature = "common-os"))]
439436
root_page_table: arch::create_new_root_page_table(),
440-
#[cfg(feature = "newlib")]
441-
lwip_errno: 0,
442437
}
443438
}
444439

@@ -507,8 +502,6 @@ impl Task {
507502
tls: None,
508503
#[cfg(all(target_arch = "x86_64", feature = "common-os"))]
509504
root_page_table: *crate::scheduler::BOOT_ROOT_PAGE_TABLE.get().unwrap(),
510-
#[cfg(feature = "newlib")]
511-
lwip_errno: 0,
512505
}
513506
}
514507
}

src/syscalls/interfaces/uhyve.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,11 @@ use x86::io::*;
99
use crate::arch;
1010
use crate::arch::mm::{paging, PhysAddr, VirtAddr};
1111
use crate::syscalls::interfaces::SyscallInterface;
12-
#[cfg(feature = "newlib")]
13-
use crate::syscalls::lwip::sys_lwip_get_errno;
14-
#[cfg(feature = "newlib")]
15-
use crate::syscalls::{LWIP_FD_BIT, LWIP_LOCK};
1612

1713
const UHYVE_PORT_EXIT: u16 = 0x540;
1814
const UHYVE_PORT_CMDSIZE: u16 = 0x740;
1915
const UHYVE_PORT_CMDVAL: u16 = 0x780;
2016

21-
#[cfg(feature = "newlib")]
22-
extern "C" {
23-
fn lwip_write(fd: i32, buf: *const u8, len: usize) -> i32;
24-
fn lwip_read(fd: i32, buf: *mut u8, len: usize) -> i32;
25-
}
26-
2717
/// forward a request to the hypervisor uhyve
2818
#[inline]
2919
#[cfg(target_arch = "x86_64")]

src/syscalls/lwip.rs

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/syscalls/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ mod condvar;
3434
mod entropy;
3535
mod futex;
3636
mod interfaces;
37-
#[cfg(feature = "newlib")]
38-
mod lwip;
3937
mod processor;
4038
#[cfg(feature = "newlib")]
4139
mod recmutex;
@@ -49,12 +47,6 @@ pub(crate) mod table;
4947
mod tasks;
5048
mod timer;
5149

52-
#[cfg(feature = "newlib")]
53-
const LWIP_FD_BIT: i32 = 1 << 30;
54-
55-
#[cfg(feature = "newlib")]
56-
pub(crate) static LWIP_LOCK: InterruptTicketMutex<()> = InterruptTicketMutex::new(());
57-
5850
pub(crate) static SYS: Lazy<&'static dyn SyscallInterface> = Lazy::new(|| {
5951
if env::is_uhyve() {
6052
&self::interfaces::Uhyve

xtask/src/build.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,7 @@ impl Build {
109109
let archive = self.cargo_build.artifact.dist_archive();
110110

111111
let syscall_symbols = archive.syscall_symbols()?;
112-
let explicit_exports = [
113-
"_start",
114-
"__bss_start",
115-
"mcount",
116-
"runtime_entry",
117-
// lwIP functions (C runtime)
118-
"init_lwip",
119-
"lwip_read",
120-
"lwip_write",
121-
// lwIP rtl8139 driver
122-
"init_rtl8139_netif",
123-
"irq_install_handler",
124-
"virt_to_phys",
125-
"eoi",
126-
]
127-
.into_iter();
112+
let explicit_exports = ["_start", "__bss_start", "mcount", "runtime_entry"].into_iter();
128113

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

0 commit comments

Comments
 (0)