Skip to content

Commit

Permalink
Merge pull request syswonder#27 from syswonder/dev
Browse files Browse the repository at this point in the history
Merge Dev into Main
  • Loading branch information
caodg authored Nov 25, 2023
2 parents 14bf167 + 9ca28f0 commit f86128e
Show file tree
Hide file tree
Showing 148 changed files with 6,250 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build CI
on: [push, pull_request]

env:
rust-toolchain: nightly
rust-toolchain: nightly-2023-09-01

jobs:
clippy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build & Deploy docs
on: [push, pull_request]

env:
rust-toolchain: nightly
rust-toolchain: nightly-2023-09-01

jobs:
doc:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

env:
qemu-version: 7.1.0
rust-toolchain: nightly
rust-toolchain: nightly-2023-09-01

jobs:
unit-test:
Expand Down
65 changes: 64 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ members = [

"ulib/axstd",
"ulib/axlibc",
"ulib/axmusl",

"apps/display/basic_painting",
"apps/display/draw_map",
Expand Down
31 changes: 28 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,29 @@
# - `ENVS`: Environment variables, separated by comma between key value pairs. Only available when feature `alloc` is enabled.
# * App options:
# - `A` or `APP`: Path to the application
# - `FEATURES`: Features os ArceOS modules to be enabled.
# - `FEATURES`: Features of ArceOS modules to be enabled.
# - `APP_FEATURES`: Features of (rust) apps to be enabled.
# * QEMU options:
# - `BLK`: Enable storage devices (virtio-blk)
# - `NET`: Enable network devices (virtio-net)
# - `GRAPHIC`: Enable display devices and graphic output (virtio-gpu)
# - `V9P`: Enable virtio-9p devices
# - `BUS`: Device bus type: mmio, pci
# - `DISK_IMG`: Path to the virtual disk image
# - `ACCEL`: Enable hardware acceleration (KVM on linux)
# - `QEMU_LOG`: Enable QEMU logging (log file is "qemu.log")
# - `NET_DUMP`: Enable network packet dump (log file is "netdump.pcap")
# - `NET_DEV`: QEMU netdev backend types: user, tap
# * 9P options:
# - `V9P_PATH`: Host path for backend of virtio-9p
# - `NET_9P_ADDR`: Server address and port for 9P netdev
# - `ANAME_9P`: Path for root of 9pfs(parameter of TATTACH for root)
# - `PROTOCOL_9P`: Default protocol version selected for 9P
# * Network options:
# - `IP`: ArceOS IPv4 address (default is 10.0.2.15 for QEMU user netdev)
# - `GW`: Gateway IPv4 address (default is 10.0.2.2 for QEMU user netdev)
# * Libc options:
# - `MUSL`: Link C app with musl libc

# General options
ARCH ?= x86_64
Expand All @@ -44,12 +52,18 @@ APP_FEATURES ?=
BLK ?= n
NET ?= n
GRAPHIC ?= n
V9P ?= n
BUS ?= mmio


DISK_IMG ?= disk.img
QEMU_LOG ?= n
NET_DUMP ?= n
NET_DEV ?= user
V9P_PATH ?= ./
NET_9P_ADDR ?= 127.0.0.1:564
ANAME_9P ?= ./
PROTOCOL_9P ?= 9P2000.L

# Network options
IP ?= 10.0.2.15
Expand All @@ -59,6 +73,9 @@ GW ?= 10.0.2.2
ARGS ?=
ENVS ?=

# Libc options
MUSL ?= n

# App type
ifeq ($(wildcard $(APP)),)
$(error Application path "$(APP)" is not valid)
Expand Down Expand Up @@ -121,6 +138,10 @@ export AX_LOG=$(LOG)
export AX_TARGET=$(TARGET)
export AX_IP=$(IP)
export AX_GW=$(GW)
export AX_9P_ADDR = $(NET_9P_ADDR)
export AX_ANAME_9P = $(ANAME_9P)
export AX_PROTOCOL_9P = $(PROTOCOL_9P)
export AX_MUSL=$(MUSL)

# Binutils
CROSS_COMPILE ?= $(ARCH)-linux-musl-
Expand Down Expand Up @@ -207,12 +228,16 @@ else
$(call make_disk_image,fat32,$(DISK_IMG))
endif

clean: clean_c
clean: clean_c clean_musl
rm -rf $(APP)/*.bin $(APP)/*.elf
cargo clean

clean_c::
rm -rf ulib/axlibc/build_*
rm -rf $(app-objs)

.PHONY: all build disasm run justrun debug clippy fmt fmt_c test test_no_fail_fast clean clean_c doc disk_image
clean_musl:
rm -rf ulib/axmusl/build_*
rm -rf ulib/axmusl/install

.PHONY: all build disasm run justrun debug clippy fmt fmt_c test test_no_fail_fast clean clean_c clean_musl doc disk_image
1 change: 1 addition & 0 deletions api/arceos_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ documentation = "https://rcore-os.github.io/arceos/arceos_api/index.html"
default = []

irq = ["axfeat/irq"]
rtc = ["axfeat/rtc"]
alloc = ["dep:axalloc", "axfeat/alloc"]
multitask = ["axtask/multitask", "axfeat/multitask"]
fs = ["dep:axfs", "axfeat/fs"]
Expand Down
5 changes: 5 additions & 0 deletions api/arceos_posix_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ multitask = ["axtask/multitask", "axfeat/multitask", "axsync/multitask"]
fd = ["alloc"]
fs = ["dep:axfs", "axfeat/fs", "fd"]
net = ["dep:axnet", "axfeat/net", "fd"]
signal = ["axfeat/signal"]
pipe = ["fd"]
select = ["fd"]
epoll = ["fd"]
poll = ["fd"]
tls = ["axfeat/tls"]
irq = ["axfeat/irq"]

musl = ["axfeat/musl"]

[dependencies]
# ArceOS modules
Expand Down
13 changes: 13 additions & 0 deletions api/arceos_posix_api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ typedef struct {{
"sock.*",
"fd_set",
"timeval",
"itimerval",
"pthread_t",
"pthread_attr_t",
"pthread_mutex_t",
"pthread_mutexattr_t",
"pthread_key_t",
"pollfd",
"nfds_t",
"epoll_event",
Expand All @@ -95,6 +97,12 @@ typedef struct {{
"pthread_cond_t",
"pthread_condattr_t",
"sysinfo",
"sigaction",
"k_sigaction",
"pid_t",
"sigset_t",
"sigaction",
"kstat",
];
let allow_vars = [
"O_.*",
Expand All @@ -109,6 +117,11 @@ typedef struct {{
"RLIMIT_.*",
"EAI_.*",
"MAXADDRS",
"ITIMER_.*",
"SIG.*",
"EINVAL",
"CLONE_.*",
"AT_.*",
];

#[derive(Debug)]
Expand Down
11 changes: 8 additions & 3 deletions api/arceos_posix_api/ctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A
* PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.
*/

#include <errno.h>
#include <fcntl.h>
#include <ksigaction.h>
#include <netdb.h>
#include <netinet/in.h>
#include <poll.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
#include <stddef.h>
#include <poll.h>
#include <sys/epoll.h>
#include <sys/resource.h>
#include <sys/select.h>
Expand Down
23 changes: 23 additions & 0 deletions api/arceos_posix_api/src/imp/fd_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ pub fn sys_dup2(old_fd: c_int, new_fd: c_int) -> c_int {
})
}

/// `dup3` used by A64 for MUSL
#[cfg(feature = "musl")]
pub fn sys_dup3(old_fd: c_int, new_fd: c_int, flags: c_int) -> c_int {
debug!(
"sys_dup3 <= old_fd: {}, new_fd: {}, flags: {:x}",
old_fd, new_fd, flags
);
syscall_body!(sys_dup3, {
if old_fd == new_fd {
return Err(LinuxError::EINVAL);
}
sys_dup2(old_fd, new_fd);
if flags as u32 & ctypes::O_CLOEXEC != 0 {
sys_fcntl(
new_fd,
ctypes::F_SETFD as c_int,
ctypes::FD_CLOEXEC as usize,
);
}
Ok(new_fd)
})
}

/// Manipulate file descriptor.
///
/// TODO: `SET/GET` command is ignored, hard-code stdin/stdout
Expand Down
Loading

0 comments on commit f86128e

Please sign in to comment.