Skip to content

Commit

Permalink
porting lwip
Browse files Browse the repository at this point in the history
  • Loading branch information
lhw2002426 committed Jun 5, 2024
1 parent 8a729f8 commit 634aa1f
Show file tree
Hide file tree
Showing 54 changed files with 2,466 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ jobs:
components: rust-src, clippy, rustfmt
- name: Clippy for the default target
run: make clippy
with:
submodules: true
- name: Clippy for x86_64
run: make clippy ARCH=x86_64
with:
submodules: true
- name: Clippy for riscv64
run: make clippy ARCH=riscv64
with:
submodules: true
- name: Clippy for aarch64
run: make clippy ARCH=aarch64
with:
submodules: true
- name: Check code format
run: cargo fmt --all -- --check

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "patches/opensbi"]
path = patches/opensbi
url = https://github.com/Sssssaltyfish/opensbi.git
[submodule "crates/lwip_rust/depend/lwip"]
path = crates/lwip_rust/depend/lwip
url = https://github.com/lwip-tcpip/lwip.git
133 changes: 125 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"crates/flatten_objects",
"crates/lazy_init",
"crates/linked_list",
"crates/lwip_rust",
"crates/page_table",
"crates/page_table_entry",
"crates/percpu",
Expand Down Expand Up @@ -58,7 +59,7 @@ members = [

"apps/display/basic_painting",
"apps/display/draw_map",
"apps/fs/shell",
"apps/fs/shell", "crates/lwip_rust",
]

[profile.release]
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,24 @@ ifeq ($(ARCH), x86_64)
ACCEL ?= $(if $(findstring -microsoft, $(shell uname -r | tr '[:upper:]' '[:lower:]')),n,y)
PLATFORM_NAME ?= x86_64-qemu-q35
TARGET := x86_64-unknown-none
TARGET_CFLAGS := -mno-sse
BUS := pci
else ifeq ($(ARCH), riscv64)
ACCEL ?= n
PLATFORM_NAME ?= riscv64-qemu-virt
TARGET := riscv64gc-unknown-none-elf
TARGET_CFLAGS := -mabi=lp64d
else ifeq ($(ARCH), aarch64)
ACCEL ?= n
PLATFORM_NAME ?= aarch64-qemu-virt
TARGET := aarch64-unknown-none-softfloat
TARGET_CFLAGS := -mgeneral-regs-only
else
$(error "ARCH" must be one of "x86_64", "riscv64", or "aarch64")
endif

export TARGET_CC = $(CC)
export TARGET_CFLAGS
export RUX_ARCH=$(ARCH)
export RUX_PLATFORM=$(PLATFORM_NAME)
export RUX_SMP=$(SMP)
Expand Down
1 change: 1 addition & 0 deletions api/arceos_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ paging = ["alloc", "ruxfeat/paging"]
multitask = ["ruxtask/multitask", "ruxfeat/multitask"]
fs = ["dep:ruxfs", "ruxfeat/fs"]
net = ["dep:axnet", "ruxfeat/net"]
lwip = ["ruxfeat/lwip"]
display = ["dep:ruxdisplay", "ruxfeat/display"]

myfs = ["ruxfeat/myfs"]
Expand Down
2 changes: 1 addition & 1 deletion api/arceos_api/src/imp/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn ax_tcp_bind(socket: &AxTcpSocketHandle, addr: SocketAddr) -> AxResult {
socket.0.bind(addr)
}

pub fn ax_tcp_listen(socket: &AxTcpSocketHandle, _backlog: usize) -> AxResult {
pub fn ax_tcp_listen(socket: &mut AxTcpSocketHandle, _backlog: usize) -> AxResult {
socket.0.listen()
}

Expand Down
2 changes: 1 addition & 1 deletion api/arceos_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub mod net {
/// Binds the TCP socket to the given address and port.
pub fn ax_tcp_bind(socket: &AxTcpSocketHandle, addr: SocketAddr) -> AxResult;
/// Starts listening on the bound address and port.
pub fn ax_tcp_listen(socket: &AxTcpSocketHandle, _backlog: usize) -> AxResult;
pub fn ax_tcp_listen(socket: &mut AxTcpSocketHandle, _backlog: usize) -> AxResult;
/// Accepts a new connection on the TCP socket.
///
/// This function will block the calling thread until a new TCP connection
Expand Down
2 changes: 2 additions & 0 deletions api/ruxfeat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ myfs = ["ruxfs?/myfs"]

# Networking
net = ["alloc", "ruxdriver/virtio-net", "dep:axnet", "ruxruntime/net"]
lwip = ["axnet/lwip"]
smoltcp = ["axnet/smoltcp"]

# Display
display = ["alloc", "ruxdriver/virtio-gpu", "dep:ruxdisplay", "ruxruntime/display"]
Expand Down
2 changes: 1 addition & 1 deletion api/ruxos_posix_api/src/imp/fd_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub fn close_file_like(fd: c_int) -> LinuxResult {

/// Close a file by `fd`.
pub fn sys_close(fd: c_int) -> c_int {
debug!("sys_close <= {}", fd);
info!("sys_close <= {}", fd);
if (0..=2).contains(&fd) {
return 0; // stdin, stdout, stderr
}
Expand Down
3 changes: 1 addition & 2 deletions api/ruxos_posix_api/src/imp/io_mpx/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ pub unsafe fn sys_epoll_wait(
loop {
#[cfg(feature = "net")]
axnet::poll_interfaces();

let poll_all_res = epoll_instance.poll_all(events);
let mut events_num = 0;
match poll_all_res {
Expand All @@ -237,8 +236,8 @@ pub unsafe fn sys_epoll_wait(
}
Err(_) => {}
}

if events_num > 0 {
//info!("lhw debug in sys_epoll wait normal return");
return Ok(events_num as c_int);
}

Expand Down
Loading

0 comments on commit 634aa1f

Please sign in to comment.