diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dcb849afd..914ed6ec9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,36 +47,12 @@ jobs: crate: cargo-binutils version: latest use-tool-cache: true - - name: Build helloworld - run: make ARCH=${{ matrix.arch }} A=apps/helloworld - - name: Build memtest - run: make ARCH=${{ matrix.arch }} A=apps/memtest - - name: Build exception - run: make ARCH=${{ matrix.arch }} A=apps/exception - name: Build display/basic_painting run: make ARCH=${{ matrix.arch }} A=apps/display/basic_painting - name: Build display/draw_map run: make ARCH=${{ matrix.arch }} A=apps/display/draw_map - - name: Build task/yield - run: make ARCH=${{ matrix.arch }} A=apps/task/yield - - name: Build task/parallel - run: make ARCH=${{ matrix.arch }} A=apps/task/parallel - - name: Build task/sleep - run: make ARCH=${{ matrix.arch }} A=apps/task/sleep - - name: Build task/priority - run: make ARCH=${{ matrix.arch }} A=apps/task/priority - - name: Build task/tls - run: make ARCH=${{ matrix.arch }} A=apps/task/tls - name: Build fs/shell run: make ARCH=${{ matrix.arch }} A=apps/fs/shell - - name: Build net/echoserver - run: make ARCH=${{ matrix.arch }} A=apps/net/echoserver - - name: Build net/httpclient - run: make ARCH=${{ matrix.arch }} A=apps/net/httpclient - - name: Build net/httpserver - run: make ARCH=${{ matrix.arch }} A=apps/net/httpserver - - name: Build net/udpserver - run: make ARCH=${{ matrix.arch }} A=apps/net/udpserver - uses: ./.github/workflows/actions/setup-musl with: @@ -98,45 +74,6 @@ jobs: - name: Build c/redis run: make ARCH=${{ matrix.arch }} A=apps/c/redis SMP=4 - build-apps-for-other-platforms: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ env.rust-toolchain }} - components: rust-src - - uses: actions-rs/install@v0.1 - with: - crate: cargo-binutils - version: latest - use-tool-cache: true - - uses: ./.github/workflows/actions/setup-musl - with: - arch: x86_64 - - - name: Build helloworld for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/helloworld - - name: Build net/httpserver for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/net/httpserver FEATURES=driver-ixgbe - - name: Build c/iperf for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/c/iperf FEATURES=driver-ixgbe,driver-ramdisk - - name: Build c/redis for x86_64-pc-oslab - run: make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdisk SMP=4 - - - name: Build helloworld for aarch64-raspi4 - run: make PLATFORM=aarch64-raspi4 A=apps/helloworld - - name: Build fs/shell for aarch64-raspi4 - run: make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci - - - name: Build helloworld for aarch64-bsta1000b - run: make PLATFORM=aarch64-bsta1000b A=apps/helloworld - build-apps-for-std: runs-on: ${{ matrix.os }} strategy: @@ -150,29 +87,5 @@ jobs: with: profile: minimal toolchain: ${{ env.rust-toolchain }} - - name: Build helloworld - run: cargo build -p arceos-helloworld - - name: Build memtest - run: cargo build -p arceos-memtest - - name: Build exception - run: cargo build -p arceos-exception - - name: Build task/yield - run: cargo build -p arceos-yield - - name: Build task/parallel - run: cargo build -p arceos-parallel - - name: Build task/sleep - run: cargo build -p arceos-sleep - - name: Build task/priority - run: cargo build -p arceos-priority - - name: Build task/tls - run: cargo build -p arceos-tls - name: Build fs/shell run: cargo build -p arceos-shell - - name: Build net/echoserver - run: cargo build -p arceos-echoserver - - name: Build net/httpclient - run: cargo build -p arceos-httpclient - - name: Build net/httpserver - run: cargo build -p arceos-httpserver - - name: Build net/udpserver - run: cargo build -p arceos-udpserver diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0246bb92e..dee04f8fa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,10 +23,3 @@ jobs: - name: Build docs continue-on-error: ${{ github.ref != env.default-branch && github.event_name != 'pull_request' }} run: make doc_check_missing - - name: Deploy to Github Pages - if: ${{ github.ref == env.default-branch }} - uses: JamesIves/github-pages-deploy-action@v4 - with: - single-commit: true - branch: gh-pages - folder: target/doc diff --git a/.gitignore b/.gitignore index 9d91ac572..ed439fc5d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ /.vscode .DS_Store *.asm -*.img +disk.img actual.out qemu.log rusty-tags.vi diff --git a/Cargo.lock b/Cargo.lock index cbb859a16..2a260ff8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,89 +60,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" -[[package]] -name = "arceos-bwbench" -version = "0.1.0" -dependencies = [ - "axnet", - "axstd", -] - -[[package]] -name = "arceos-display-basic-painting" -version = "0.1.0" -dependencies = [ - "axstd", - "embedded-graphics", -] - -[[package]] -name = "arceos-display-draw-map" -version = "0.1.0" -dependencies = [ - "axstd", - "embedded-graphics", - "tinybmp", -] - -[[package]] -name = "arceos-echoserver" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-exception" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-helloworld" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-httpclient" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-httpserver" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-memtest" -version = "0.1.0" -dependencies = [ - "axstd", - "rand", -] - -[[package]] -name = "arceos-parallel" -version = "0.1.0" -dependencies = [ - "axstd", - "rand", -] - -[[package]] -name = "arceos-priority" -version = "0.1.0" -dependencies = [ - "axstd", -] - [[package]] name = "arceos-shell" version = "0.1.0" @@ -153,74 +70,22 @@ dependencies = [ "crate_interface", ] -[[package]] -name = "arceos-sleep" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-tls" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-udpserver" -version = "0.1.0" -dependencies = [ - "axstd", -] - -[[package]] -name = "arceos-yield" -version = "0.1.0" -dependencies = [ - "axstd", -] - [[package]] name = "arceos_api" version = "0.1.0" dependencies = [ "axalloc", - "axconfig", - "axdisplay", - "axerrno", - "axfeat", - "axfs", - "axhal", - "axio", - "axlog", - "axnet", - "axruntime", - "axtask", -] - -[[package]] -name = "arceos_posix_api" -version = "0.1.0" -dependencies = [ - "axalloc", - "axconfig", "axerrno", - "axfeat", - "axfs", - "axhal", "axio", "axlog", "axnet", - "axruntime", - "axsync", - "axtask", - "bindgen", - "flatten_objects", - "lazy_static", - "memory_addr", - "spin 0.9.8", - "static_assertions", + "ruxconfig", + "ruxdisplay", + "ruxfeat", + "ruxfs", + "ruxhal", + "ruxruntime", + "ruxtask", ] [[package]] @@ -252,20 +117,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "ax9p" -version = "0.1.0" -dependencies = [ - "axdriver", - "axfs", - "axfs_vfs", - "axnet", - "driver_9p", - "driver_common", - "log", - "spin 0.9.8", -] - [[package]] name = "axalloc" version = "0.1.0" @@ -278,43 +129,6 @@ dependencies = [ "spinlock", ] -[[package]] -name = "axconfig" -version = "0.1.0" -dependencies = [ - "serde", - "toml_edit", -] - -[[package]] -name = "axdisplay" -version = "0.1.0" -dependencies = [ - "axdriver", - "axsync", - "driver_display", - "lazy_init", - "log", -] - -[[package]] -name = "axdriver" -version = "0.1.0" -dependencies = [ - "axalloc", - "axconfig", - "axhal", - "cfg-if", - "driver_9p", - "driver_block", - "driver_common", - "driver_display", - "driver_net", - "driver_pci", - "driver_virtio", - "log", -] - [[package]] name = "axerrno" version = "0.1.0" @@ -322,45 +136,6 @@ dependencies = [ "log", ] -[[package]] -name = "axfeat" -version = "0.1.0" -dependencies = [ - "ax9p", - "axalloc", - "axdisplay", - "axdriver", - "axfs", - "axhal", - "axlog", - "axnet", - "axruntime", - "axsync", - "axtask", - "spinlock", -] - -[[package]] -name = "axfs" -version = "0.1.0" -dependencies = [ - "axdriver", - "axerrno", - "axfs_devfs", - "axfs_ramfs", - "axfs_vfs", - "axio", - "axsync", - "axtask", - "capability", - "cfg-if", - "crate_interface", - "driver_block", - "fatfs", - "lazy_init", - "log", -] - [[package]] name = "axfs_devfs" version = "0.1.0" @@ -388,42 +163,6 @@ dependencies = [ "log", ] -[[package]] -name = "axhal" -version = "0.1.0" -dependencies = [ - "aarch64-cpu", - "arm_gic", - "arm_pl011", - "axalloc", - "axconfig", - "axlog", - "bitflags 2.4.0", - "cfg-if", - "crate_interface", - "dtb", - "dw_apb_uart", - "embedded-hal", - "handler_table", - "kernel_guard", - "lazy_init", - "log", - "memory_addr", - "page_table", - "page_table_entry", - "percpu", - "ratio", - "raw-cpuid 11.0.1", - "riscv", - "sbi-rt", - "spinlock", - "static_assertions", - "tock-registers", - "x2apic", - "x86", - "x86_64", -] - [[package]] name = "axio" version = "0.1.0" @@ -431,17 +170,6 @@ dependencies = [ "axerrno", ] -[[package]] -name = "axlibc" -version = "0.1.0" -dependencies = [ - "arceos_posix_api", - "axerrno", - "axfeat", - "axio", - "bindgen", -] - [[package]] name = "axlog" version = "0.1.0" @@ -454,67 +182,32 @@ dependencies = [ "spinlock", ] -[[package]] -name = "axmusl" -version = "0.1.0" -dependencies = [ - "arceos_posix_api", - "axfeat", - "axhal", - "axlog", - "crate_interface", - "kernel_guard", - "num_enum", -] - [[package]] name = "axnet" version = "0.1.0" dependencies = [ - "axdriver", "axerrno", - "axhal", "axio", "axsync", - "axtask", "cfg-if", "driver_net", "lazy_init", "log", + "ruxdriver", + "ruxhal", + "ruxtask", "smoltcp", "spin 0.9.8", ] -[[package]] -name = "axruntime" -version = "0.1.0" -dependencies = [ - "ax9p", - "axalloc", - "axconfig", - "axdisplay", - "axdriver", - "axfs", - "axhal", - "axlog", - "axnet", - "axtask", - "cfg-if", - "crate_interface", - "dtb", - "kernel_guard", - "lazy_init", - "percpu", -] - [[package]] name = "axstd" version = "0.1.0" dependencies = [ "arceos_api", "axerrno", - "axfeat", "axio", + "ruxfeat", "spinlock", ] @@ -523,29 +216,9 @@ name = "axsync" version = "0.1.0" dependencies = [ "axsync", - "axtask", - "rand", - "spinlock", -] - -[[package]] -name = "axtask" -version = "0.1.0" -dependencies = [ - "axconfig", - "axhal", - "axtask", - "cfg-if", - "crate_interface", - "kernel_guard", - "lazy_init", - "log", - "memory_addr", - "percpu", "rand", - "scheduler", + "ruxtask", "spinlock", - "timer_list", ] [[package]] @@ -1753,6 +1426,241 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" +[[package]] +name = "rux9p" +version = "0.1.0" +dependencies = [ + "axfs_vfs", + "axnet", + "driver_9p", + "driver_common", + "log", + "ruxdriver", + "ruxfs", + "spin 0.9.8", +] + +[[package]] +name = "ruxconfig" +version = "0.1.0" +dependencies = [ + "serde", + "toml_edit", +] + +[[package]] +name = "ruxdisplay" +version = "0.1.0" +dependencies = [ + "axsync", + "driver_display", + "lazy_init", + "log", + "ruxdriver", +] + +[[package]] +name = "ruxdriver" +version = "0.1.0" +dependencies = [ + "axalloc", + "cfg-if", + "driver_9p", + "driver_block", + "driver_common", + "driver_display", + "driver_net", + "driver_pci", + "driver_virtio", + "log", + "ruxconfig", + "ruxhal", +] + +[[package]] +name = "ruxfeat" +version = "0.1.0" +dependencies = [ + "axalloc", + "axlog", + "axnet", + "axsync", + "rux9p", + "ruxdisplay", + "ruxdriver", + "ruxfs", + "ruxhal", + "ruxruntime", + "ruxtask", + "spinlock", +] + +[[package]] +name = "ruxfs" +version = "0.1.0" +dependencies = [ + "axalloc", + "axerrno", + "axfs_devfs", + "axfs_ramfs", + "axfs_vfs", + "axio", + "axsync", + "capability", + "cfg-if", + "crate_interface", + "driver_block", + "fatfs", + "lazy_init", + "log", + "memory_addr", + "ruxdriver", + "ruxtask", +] + +[[package]] +name = "ruxhal" +version = "0.1.0" +dependencies = [ + "aarch64-cpu", + "arm_gic", + "arm_pl011", + "axalloc", + "axlog", + "bitflags 2.4.0", + "cfg-if", + "crate_interface", + "dtb", + "dw_apb_uart", + "embedded-hal", + "handler_table", + "kernel_guard", + "lazy_init", + "log", + "memory_addr", + "page_table", + "page_table_entry", + "percpu", + "ratio", + "raw-cpuid 11.0.1", + "riscv", + "ruxconfig", + "sbi-rt", + "spinlock", + "static_assertions", + "tock-registers", + "x2apic", + "x86", + "x86_64", +] + +[[package]] +name = "ruxlibc" +version = "0.1.0" +dependencies = [ + "axerrno", + "axio", + "bindgen", + "ruxfeat", + "ruxos_posix_api", +] + +[[package]] +name = "ruxmusl" +version = "0.1.0" +dependencies = [ + "axlog", + "crate_interface", + "kernel_guard", + "num_enum", + "ruxfeat", + "ruxhal", + "ruxos_posix_api", +] + +[[package]] +name = "ruxos-display-basic-painting" +version = "0.1.0" +dependencies = [ + "axstd", + "embedded-graphics", +] + +[[package]] +name = "ruxos-display-draw-map" +version = "0.1.0" +dependencies = [ + "axstd", + "embedded-graphics", + "tinybmp", +] + +[[package]] +name = "ruxos_posix_api" +version = "0.1.0" +dependencies = [ + "axalloc", + "axerrno", + "axio", + "axlog", + "axnet", + "axsync", + "bindgen", + "flatten_objects", + "lazy_static", + "memory_addr", + "ruxconfig", + "ruxfeat", + "ruxfs", + "ruxhal", + "ruxruntime", + "ruxtask", + "spin 0.9.8", + "static_assertions", +] + +[[package]] +name = "ruxruntime" +version = "0.1.0" +dependencies = [ + "axalloc", + "axlog", + "axnet", + "cfg-if", + "crate_interface", + "dtb", + "kernel_guard", + "lazy_init", + "percpu", + "rux9p", + "ruxconfig", + "ruxdisplay", + "ruxdriver", + "ruxfs", + "ruxhal", + "ruxtask", +] + +[[package]] +name = "ruxtask" +version = "0.1.0" +dependencies = [ + "cfg-if", + "crate_interface", + "kernel_guard", + "lazy_init", + "log", + "memory_addr", + "percpu", + "rand", + "ruxconfig", + "ruxhal", + "ruxtask", + "scheduler", + "spinlock", + "timer_list", +] + [[package]] name = "ryu" version = "1.0.15" diff --git a/Cargo.toml b/Cargo.toml index 4e6a14dc9..c53e5c188 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "crates/axio", "crates/capability", "crates/crate_interface", + "crates/driver_9p", "crates/driver_block", "crates/driver_common", "crates/driver_display", @@ -38,41 +39,29 @@ members = [ "crates/tuple_for_each", "modules/axalloc", - "modules/axconfig", - "modules/axdisplay", - "modules/axdriver", - "modules/axfs", - "modules/axhal", "modules/axlog", "modules/axnet", - "modules/axruntime", "modules/axsync", - "modules/axtask", + "modules/rux9p", + "modules/ruxconfig", + "modules/ruxdisplay", + "modules/ruxdriver", + "modules/ruxfs", + "modules/ruxhal", + "modules/ruxruntime", + "modules/ruxtask", - "api/axfeat", + "api/ruxfeat", "api/arceos_api", - "api/arceos_posix_api", + "api/ruxos_posix_api", "ulib/axstd", - "ulib/axlibc", - "ulib/axmusl", + "ulib/ruxlibc", + "ulib/ruxmusl", "apps/display/basic_painting", "apps/display/draw_map", - "apps/exception", - "apps/helloworld", - "apps/memtest", "apps/fs/shell", - "apps/net/echoserver", - "apps/net/httpclient", - "apps/net/httpserver", - "apps/net/udpserver", - "apps/net/bwbench", - "apps/task/parallel", - "apps/task/sleep", - "apps/task/yield", - "apps/task/priority", - "apps/task/tls", ] [profile.release] diff --git a/LICENSE.MulanPSL2 b/LICENSE.MulanPSL2 index 7cf215730..6bf65053e 100644 --- a/LICENSE.MulanPSL2 +++ b/LICENSE.MulanPSL2 @@ -54,7 +54,7 @@ 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [2023] [Syswonder Community] - [Rukos] is licensed under Mulan PSL v2. + [Ruxos] is licensed under Mulan PSL v2. 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 @@ -119,7 +119,7 @@ Copyright (c) [2023] [Syswonder Community] - [Rukos] is licensed under Mulan PSL v2. + [Ruxos] is licensed under Mulan PSL v2. 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 diff --git a/Makefile b/Makefile index cbfc0d25a..f23fa3594 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,11 @@ # - `MODE`: Build mode: release, debug # - `LOG:` Logging level: warn, error, info, debug, trace # - `V`: Verbose level: (empty), 1, 2 -# - `ARGS`: Command-line arguments separated by comma. Only available when feature `alloc` is enabled. -# - `ENVS`: Environment variables, separated by comma between key value pairs. Only available when feature `alloc` is enabled. +# - `ARGS`: Command-line arguments separated by comma. Only available when feature `alloc` is enabled. +# - `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 of ArceOS modules to be enabled. +# - `FEATURES`: Features of Ruxos modules to be enabled. # - `APP_FEATURES`: Features of (rust) apps to be enabled. # * QEMU options: # - `BLK`: Enable storage devices (virtio-blk) @@ -29,7 +29,7 @@ # - `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) +# - `IP`: Ruxos 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 @@ -43,7 +43,7 @@ LOG ?= warn V ?= # App options -A ?= apps/helloworld +A ?= apps/c/helloworld APP ?= $(A) FEATURES ?= APP_FEATURES ?= @@ -55,7 +55,6 @@ GRAPHIC ?= n V9P ?= n BUS ?= mmio - DISK_IMG ?= disk.img QEMU_LOG ?= n NET_DUMP ?= n @@ -130,18 +129,18 @@ else $(error "ARCH" must be one of "x86_64", "riscv64", or "aarch64") endif -export AX_ARCH=$(ARCH) -export AX_PLATFORM=$(PLATFORM_NAME) -export AX_SMP=$(SMP) -export AX_MODE=$(MODE) -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) +export RUX_ARCH=$(ARCH) +export RUX_PLATFORM=$(PLATFORM_NAME) +export RUX_SMP=$(SMP) +export RUX_MODE=$(MODE) +export RUX_LOG=$(LOG) +export RUX_TARGET=$(TARGET) +export RUX_IP=$(IP) +export RUX_GW=$(GW) +export RUX_9P_ADDR = $(NET_9P_ADDR) +export RUX_ANAME_9P = $(ANAME_9P) +export RUX_PROTOCOL_9P = $(PROTOCOL_9P) +export RUX_MUSL=$(MUSL) # Binutils CROSS_COMPILE ?= $(ARCH)-linux-musl- @@ -158,7 +157,7 @@ GDB ?= gdb-multiarch OUT_DIR ?= $(APP) APP_NAME := $(shell basename $(APP)) -LD_SCRIPT := $(CURDIR)/modules/axhal/linker_$(PLATFORM_NAME).lds +LD_SCRIPT := $(CURDIR)/modules/ruxhal/linker_$(PLATFORM_NAME).lds OUT_ELF := $(OUT_DIR)/$(APP_NAME)_$(PLATFORM_NAME).elf OUT_BIN := $(OUT_DIR)/$(APP_NAME)_$(PLATFORM_NAME).bin @@ -210,7 +209,7 @@ fmt: cargo fmt --all fmt_c: - @clang-format --style=file -i $(shell find ulib/axlibc -iname '*.c' -o -iname '*.h') + @clang-format --style=file -i $(shell find ulib/ruxlibc -iname '*.c' -o -iname '*.h') test: $(call app_test) @@ -233,11 +232,11 @@ clean: clean_c clean_musl cargo clean clean_c:: - rm -rf ulib/axlibc/build_* + rm -rf ulib/ruxlibc/build_* rm -rf $(app-objs) clean_musl: - rm -rf ulib/axmusl/build_* - rm -rf ulib/axmusl/install + rm -rf ulib/ruxmusl/build_* + rm -rf ulib/ruxmusl/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 diff --git a/README.md b/README.md index 21c8b8d40..f89170e0b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# RukOS +# RuxOS -[![CI](https://github.com/syswonder/rukos/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/syswonder/rukos/actions/workflows/build.yml) -[![CI](https://github.com/syswonder/rukos/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/syswonder/rukos/actions/workflows/test.yml) +[![CI](https://github.com/syswonder/ruxos/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/syswonder/ruxos/actions/workflows/build.yml) +[![CI](https://github.com/syswonder/ruxos/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/syswonder/ruxos/actions/workflows/test.yml) An experimental modular operating system (or unikernel) written in Rust. -RukOS was inspired by [Unikraft](https://github.com/unikraft/unikraft) and [ArceOS](https://github.com/rcore-os/arceos) +RuxOS was inspired by [Unikraft](https://github.com/unikraft/unikraft) and [ArceOS](https://github.com/rcore-os/arceos) 🚧 Working In Progress. @@ -20,7 +20,7 @@ RukOS was inspired by [Unikraft](https://github.com/unikraft/unikraft) and [Arce * [x] Synchronization/Mutex * [x] SMP scheduling with single run queue * [x] File system -* [ ] Compatible with Linux apps +* [x] Compatible with Linux apps * [ ] Interrupt driven device I/O * [ ] Async I/O @@ -28,26 +28,50 @@ RukOS was inspired by [Unikraft](https://github.com/unikraft/unikraft) and [Arce Example applications can be found in the [apps/](apps/) directory. All applications must at least depend on the following modules, while other modules are optional: -* [axruntime](modules/axruntime/): Bootstrapping from the bare-metal environment, and initialization. -* [axhal](modules/axhal/): Hardware abstraction layer, provides unified APIs for cross-platform. -* [axconfig](modules/axconfig/): Platform constants and kernel parameters, such as physical memory base, kernel load addresses, stack size, etc. +* [ruxruntime](modules/ruxruntime/): Bootstrapping from the bare-metal environment, and initialization. +* [ruxhal](modules/ruxhal/): Hardware abstraction layer, provides unified APIs for cross-platform. +* [ruxconfig](modules/ruxconfig/): Platform constants and kernel parameters, such as physical memory base, kernel load addresses, stack size, etc. * [axlog](modules/axlog/): Multi-level formatted logging. The currently supported applications (Rust), as well as their dependent modules and features, are shown in the following table: +### Rust + | App | Extra modules | Enabled features | Description | |-|-|-|-| | [helloworld](apps/helloworld/) | | | A minimal app that just prints a string | | [exception](apps/exception/) | | paging | Exception handling test | | [memtest](apps/memtest/) | axalloc | alloc, paging | Dynamic memory allocation test | -| [display](apps/display/) | axalloc, axdisplay | alloc, paging, display | Graphic/GUI test | -| [yield](apps/task/yield/) | axalloc, axtask | alloc, paging, multitask, sched_fifo | Multi-threaded yielding test | -| [parallel](apps/task/parallel/) | axalloc, axtask | alloc, paging, multitask, sched_fifo | Parallel computing test (to test synchronization & mutex) | -| [sleep](apps/task/sleep/) | axalloc, axtask | alloc, paging, multitask, sched_fifo | Thread sleeping test | -| [shell](apps/fs/shell/) | axalloc, axdriver, axfs | alloc, paging, fs | A simple shell that responds to filesystem operations | -| [httpclient](apps/net/httpclient/) | axalloc, axdriver, axnet | alloc, paging, net | A simple client that sends an HTTP request and then prints the response | -| [echoserver](apps/net/echoserver/) | axalloc, axdriver, axnet, axtask | alloc, paging, net, multitask | A multi-threaded TCP server that reverses messages sent by the client | -| [httpserver](apps/net/httpserver/) | axalloc, axdriver, axnet, axtask | alloc, paging, net, multitask | A multi-threaded HTTP server that serves a static web page | +| [display](apps/display/) | axalloc, ruxdisplay | alloc, paging, display | Graphic/GUI test | +| [yield](apps/task/yield/) | axalloc, ruxtask | alloc, paging, multitask, sched_fifo | Multi-threaded yielding test | +| [parallel](apps/task/parallel/) | axalloc, ruxtask | alloc, paging, multitask, sched_fifo | Parallel computing test (to test synchronization & mutex) | +| [sleep](apps/task/sleep/) | axalloc, ruxtask | alloc, paging, multitask, sched_fifo | Thread sleeping test | +| [shell](apps/fs/shell/) | axalloc, ruxdriver, ruxfs | alloc, paging, fs | A simple shell that responds to filesystem operations | +| [httpclient](apps/net/httpclient/) | axalloc, ruxdriver, axnet | alloc, paging, net | A simple client that sends an HTTP request and then prints the response | +| [echoserver](apps/net/echoserver/) | axalloc, ruxdriver, axnet, ruxtask | alloc, paging, net, multitask | A multi-threaded TCP server that reverses messages sent by the client | +| [httpserver](apps/net/httpserver/) | axalloc, ruxdriver, axnet, ruxtask | alloc, paging, net, multitask | A multi-threaded HTTP server that serves a static web page | + +### C + +| App | Enabled features | Description | +|-|-|-| +| [helloworld](apps/c/helloworld/) | | A minimal app that just prints a string by C | +| [envtest](apps/c/envtest/) | alloc, paging | An environment variable test | +| [memtest](apps/c/memtest/) | alloc, paging | Dynamic memory allocation test by C | +| [filetest](apps/c/filetest/) | alloc, paging, fs, blkfs | File system operation test | +| [httpclient](apps/c/httpclient/) | alloc, paging, net | A simple client that sends an HTTP request and then prints the response by C | +| [httpserver](apps/c/httpserver/) | alloc, paging, net | A multi-threaded HTTP server that serves a static web page by C | +| [udpserver](apps/c/udpserver/) | alloc, paging, net | A simple UDP server that send back original message | +| [systime](apps/c/systime/) | rtc | A simple test for real time clock module | +| [basic](apps/c/pthread/basic/) | alloc, paging, multitask, irq | A simple test for basic pthread-related API in C standard library | +| [parallel](apps/c/pthread/parallel/) | alloc, paging, multitask | Parallel computing test to test synchronization by C | +| [pipe](apps/c/pthread/pipe/) | alloc, paging, multitask, pipe | A test for pipe API | +| [sleep](apps/c/pthread/sleep/) | alloc, paging, multitask, irq | Thread sleeping test | +| [tsd](apps/c/pthread/tsd/) | alloc, paging, multitask, irq | A test for pthread-key related API | +| [libc-bench](apps/c/libc-bench/) | alloc, multitask, fs, musl | A standard libc test for musl libc integration | +| [iperf](apps/c/iperf/) | alloc, paging, net, fs, blkfs, select, fp_simd | A network performance test tool | +| [redis](apps/c/redis/) | alloc, paging, fp_simd, irq, multitask, fs, blkfs, net, pipe, epoll, poll, virtio-9p, rtc | A Redis server on Ruxos | +| [sqlite3](apps/c/sqlite3/) | alloc, paging, fs, fp_simd, blkfs | A simple test for Sqlite3 API | ## Build & Run @@ -83,7 +107,7 @@ export PATH=`pwd`/x86_64-linux-musl-cross/bin:`pwd`/aarch64-linux-musl-cross/bin ### Example apps ```bash -# in rukos directory +# in ruxos directory make A=path/to/app ARCH= LOG= ``` @@ -112,15 +136,15 @@ Note that the `NET=y` argument is required to enable the network device in QEMU. ```toml [dependencies] - axstd = { path = "/path/to/rukos/ulib/axstd", features = ["..."] } + axstd = { path = "/path/to/ruxos/ulib/axstd", features = ["..."] } ``` 3. Call library functions from `axstd` in your code, just like the Rust [std](https://doc.rust-lang.org/std/) library. -4. Build your application with RukOS, by running the `make` command in the application directory: +4. Build your application with RuxOS, by running the `make` command in the application directory: ```bash # in app directory - make -C /path/to/rukos A=$(pwd) ARCH= run + make -C /path/to/ruxos A=$(pwd) ARCH= run # more args: LOG= SMP= NET=[y|n] ... ``` @@ -152,15 +176,15 @@ Note that the `NET=y` argument is required to enable the network device in QEMU. net ``` -3. Build your application with RukOS, by running the `make` command in the application directory: +3. Build your application with RuxOS, by running the `make` command in the application directory: ```bash # in app directory - make -C /path/to/rukos A=$(pwd) ARCH= run + make -C /path/to/ruxos A=$(pwd) ARCH= run # more args: LOG= SMP= NET=[y|n] ... ``` -### How to build RukOS for specific platforms and devices +### How to build RuxOS for specific platforms and devices Set the `PLATFORM` variable when run `make`: @@ -180,4 +204,4 @@ make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdis ## Design -![](doc/figures/rukos.svg) +![](doc/figures/ruxos.svg) diff --git a/api/arceos_api/Cargo.toml b/api/arceos_api/Cargo.toml index 4b759c654..4e405c1df 100644 --- a/api/arceos_api/Cargo.toml +++ b/api/arceos_api/Cargo.toml @@ -12,29 +12,29 @@ documentation = "https://rcore-os.github.io/arceos/arceos_api/index.html" [features] default = [] -irq = ["axfeat/irq"] -rtc = ["axfeat/rtc"] -alloc = ["dep:axalloc", "axfeat/alloc"] -multitask = ["axtask/multitask", "axfeat/multitask"] -fs = ["dep:axfs", "axfeat/fs"] -net = ["dep:axnet", "axfeat/net"] -display = ["dep:axdisplay", "axfeat/display"] +irq = ["ruxfeat/irq"] +rtc = ["ruxfeat/rtc"] +alloc = ["dep:axalloc", "ruxfeat/alloc"] +multitask = ["ruxtask/multitask", "ruxfeat/multitask"] +fs = ["dep:ruxfs", "ruxfeat/fs"] +net = ["dep:axnet", "ruxfeat/net"] +display = ["dep:ruxdisplay", "ruxfeat/display"] -myfs = ["axfeat/myfs"] +myfs = ["ruxfeat/myfs"] # Use dummy functions if the feature is not enabled dummy-if-not-enabled = [] [dependencies] -axfeat = { path = "../axfeat" } -axruntime = { path = "../../modules/axruntime" } -axconfig = { path = "../../modules/axconfig" } +ruxfeat = { path = "../ruxfeat" } +ruxruntime = { path = "../../modules/ruxruntime" } +ruxconfig = { path = "../../modules/ruxconfig" } axlog = { path = "../../modules/axlog" } axio = { path = "../../crates/axio" } axerrno = { path = "../../crates/axerrno" } -axhal = { path = "../../modules/axhal" } +ruxhal = { path = "../../modules/ruxhal" } axalloc = { path = "../../modules/axalloc", optional = true } -axtask = { path = "../../modules/axtask", optional = true } -axfs = { path = "../../modules/axfs", optional = true } +ruxtask = { path = "../../modules/ruxtask", optional = true } +ruxfs = { path = "../../modules/ruxfs", optional = true } axnet = { path = "../../modules/axnet", optional = true } -axdisplay = { path = "../../modules/axdisplay", optional = true } +ruxdisplay = { path = "../../modules/ruxdisplay", optional = true } diff --git a/api/arceos_api/src/imp/display.rs b/api/arceos_api/src/imp/display.rs index ee031ecde..3bddde5a0 100644 --- a/api/arceos_api/src/imp/display.rs +++ b/api/arceos_api/src/imp/display.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,14 +7,14 @@ * See the Mulan PSL v2 for more details. */ -pub use axdisplay::DisplayInfo as AxDisplayInfo; +pub use ruxdisplay::DisplayInfo as AxDisplayInfo; /// Gets the framebuffer information. pub fn ax_framebuffer_info() -> AxDisplayInfo { - axdisplay::framebuffer_info() + ruxdisplay::framebuffer_info() } /// Flushes the framebuffer, i.e. show on the screen. pub fn ax_framebuffer_flush() { - axdisplay::framebuffer_flush() + ruxdisplay::framebuffer_flush() } diff --git a/api/arceos_api/src/imp/fs.rs b/api/arceos_api/src/imp/fs.rs index 2aac0bf4b..c0c7a4bc9 100644 --- a/api/arceos_api/src/imp/fs.rs +++ b/api/arceos_api/src/imp/fs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,17 +9,17 @@ use alloc::string::String; use axerrno::AxResult; -use axfs::fops::{Directory, File}; +use ruxfs::fops::{Directory, File}; -pub use axfs::fops::DirEntry as AxDirEntry; -pub use axfs::fops::FileAttr as AxFileAttr; -pub use axfs::fops::FilePerm as AxFilePerm; -pub use axfs::fops::FileType as AxFileType; -pub use axfs::fops::OpenOptions as AxOpenOptions; +pub use ruxfs::fops::DirEntry as AxDirEntry; +pub use ruxfs::fops::FileAttr as AxFileAttr; +pub use ruxfs::fops::FilePerm as AxFilePerm; +pub use ruxfs::fops::FileType as AxFileType; +pub use ruxfs::fops::OpenOptions as AxOpenOptions; pub use axio::SeekFrom as AxSeekFrom; #[cfg(feature = "myfs")] -pub use axfs::fops::{Disk as AxDisk, MyFileSystemIf}; +pub use ruxfs::fops::{Disk as AxDisk, MyFileSystemIf}; /// A handle to an opened file. pub struct AxFileHandle(File); @@ -72,25 +72,25 @@ pub fn ax_read_dir(dir: &mut AxDirHandle, dirents: &mut [AxDirEntry]) -> AxResul } pub fn ax_create_dir(path: &str) -> AxResult { - axfs::api::create_dir(path) + ruxfs::api::create_dir(path) } pub fn ax_remove_dir(path: &str) -> AxResult { - axfs::api::remove_dir(path) + ruxfs::api::remove_dir(path) } pub fn ax_remove_file(path: &str) -> AxResult { - axfs::api::remove_file(path) + ruxfs::api::remove_file(path) } pub fn ax_rename(old: &str, new: &str) -> AxResult { - axfs::api::rename(old, new) + ruxfs::api::rename(old, new) } pub fn ax_current_dir() -> AxResult { - axfs::api::current_dir() + ruxfs::api::current_dir() } pub fn ax_set_current_dir(path: &str) -> AxResult { - axfs::api::set_current_dir(path) + ruxfs::api::set_current_dir(path) } diff --git a/api/arceos_api/src/imp/mem.rs b/api/arceos_api/src/imp/mem.rs index 46cefef47..46793539a 100644 --- a/api/arceos_api/src/imp/mem.rs +++ b/api/arceos_api/src/imp/mem.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_api/src/imp/mod.rs b/api/arceos_api/src/imp/mod.rs index 6f2acdeb1..c4d2e01ec 100644 --- a/api/arceos_api/src/imp/mod.rs +++ b/api/arceos_api/src/imp/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -29,11 +29,11 @@ mod stdio { use core::fmt; pub fn ax_console_read_byte() -> Option { - axhal::console::getchar().map(|c| if c == b'\r' { b'\n' } else { c }) + ruxhal::console::getchar().map(|c| if c == b'\r' { b'\n' } else { c }) } pub fn ax_console_write_bytes(buf: &[u8]) -> crate::AxResult { - axhal::console::write_bytes(buf); + ruxhal::console::write_bytes(buf); Ok(buf.len()) } @@ -46,6 +46,6 @@ pub use self::mem::*; pub use self::stdio::*; pub use self::task::*; -pub use axhal::misc::terminate as ax_terminate; -pub use axhal::time::{current_time as ax_current_time, TimeValue as AxTimeValue}; pub use axio::PollState as AxPollState; +pub use ruxhal::misc::terminate as ax_terminate; +pub use ruxhal::time::{current_time as ax_current_time, TimeValue as AxTimeValue}; diff --git a/api/arceos_api/src/imp/net.rs b/api/arceos_api/src/imp/net.rs index d7bf9a5ad..1ccf1e59a 100644 --- a/api/arceos_api/src/imp/net.rs +++ b/api/arceos_api/src/imp/net.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_api/src/imp/task.rs b/api/arceos_api/src/imp/task.rs index 03942553f..805d3a76b 100644 --- a/api/arceos_api/src/imp/task.rs +++ b/api/arceos_api/src/imp/task.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,17 +9,17 @@ pub fn ax_sleep_until(deadline: crate::time::AxTimeValue) { #[cfg(feature = "multitask")] - axtask::sleep_until(deadline); + ruxtask::sleep_until(deadline); #[cfg(not(feature = "multitask"))] - axhal::time::busy_wait_until(deadline); + ruxhal::time::busy_wait_until(deadline); } pub fn ax_yield_now() { #[cfg(feature = "multitask")] - axtask::yield_now(); + ruxtask::yield_now(); #[cfg(not(feature = "multitask"))] if cfg!(feature = "irq") { - axhal::arch::wait_for_irqs(); + ruxhal::arch::wait_for_irqs(); } else { core::hint::spin_loop(); } @@ -27,9 +27,9 @@ pub fn ax_yield_now() { pub fn ax_exit(_exit_code: i32) -> ! { #[cfg(feature = "multitask")] - axtask::exit(_exit_code); + ruxtask::exit(_exit_code); #[cfg(not(feature = "multitask"))] - axhal::misc::terminate(); + ruxhal::misc::terminate(); } cfg_task! { @@ -37,7 +37,7 @@ cfg_task! { /// A handle to a task. pub struct AxTaskHandle { - inner: axtask::AxTaskRef, + inner: ruxtask::AxTaskRef, id: u64, } @@ -52,24 +52,24 @@ cfg_task! { /// /// A wait queue is used to store sleeping tasks waiting for a certain event /// to happen. - pub struct AxWaitQueueHandle(axtask::WaitQueue); + pub struct AxWaitQueueHandle(ruxtask::WaitQueue); impl AxWaitQueueHandle { /// Creates a new empty wait queue. pub const fn new() -> Self { - Self(axtask::WaitQueue::new()) + Self(ruxtask::WaitQueue::new()) } } pub fn ax_current_task_id() -> u64 { - axtask::current().id().as_u64() + ruxtask::current().id().as_u64() } pub fn ax_spawn(f: F, name: alloc::string::String, stack_size: usize) -> AxTaskHandle where F: FnOnce() + Send + 'static, { - let inner = axtask::spawn_raw(f, name, stack_size); + let inner = ruxtask::spawn_raw(f, name, stack_size); AxTaskHandle { id: inner.id().as_u64(), inner, @@ -81,7 +81,7 @@ cfg_task! { } pub fn ax_set_current_priority(prio: isize) -> crate::AxResult { - if axtask::set_priority(prio) { + if ruxtask::set_priority(prio) { Ok(()) } else { axerrno::ax_err!( diff --git a/api/arceos_api/src/lib.rs b/api/arceos_api/src/lib.rs index e728fc6e7..39d5573e4 100644 --- a/api/arceos_api/src/lib.rs +++ b/api/arceos_api/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -25,7 +25,7 @@ feature = "dummy-if-not-enabled" ))] extern crate alloc; -extern crate axruntime; +extern crate ruxruntime; #[macro_use] mod macros; @@ -35,7 +35,7 @@ pub use axerrno::{AxError, AxResult}; /// Platform-specific constants and parameters. pub mod config { - pub use axconfig::*; + pub use ruxconfig::*; } /// System operations. diff --git a/api/arceos_api/src/macros.rs b/api/arceos_api/src/macros.rs index 00843d6c5..2d148171f 100644 --- a/api/arceos_api/src/macros.rs +++ b/api/arceos_api/src/macros.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/signal.rs b/api/arceos_posix_api/src/imp/signal.rs deleted file mode 100644 index a9bb3cb9d..000000000 --- a/api/arceos_posix_api/src/imp/signal.rs +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::ctypes::k_sigaction; -use axruntime::{rx_sigaction, Signal}; - -/// Set signal handler -pub fn sys_sigaction( - signum: u8, - sigaction: Option<&k_sigaction>, - oldact: Option<&mut k_sigaction>, -) { - Signal::sigaction( - signum, - sigaction.map(|act| act as *const k_sigaction as *const rx_sigaction), - oldact.map(|old| old as *mut k_sigaction as *mut rx_sigaction), - ); -} diff --git a/api/axfeat/Cargo.toml b/api/axfeat/Cargo.toml deleted file mode 100644 index 6db00d650..000000000 --- a/api/axfeat/Cargo.toml +++ /dev/null @@ -1,90 +0,0 @@ -[package] -name = "axfeat" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] -description = "Top-level feature selection for ArceOS" -license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/api/axfeat" -documentation = "https://rcore-os.github.io/arceos/axfeat/index.html" - -[features] -default = [] - -# Multicore -smp = ["axhal/smp", "axruntime/smp", "spinlock/smp"] - -# Floating point/SIMD -fp_simd = ["axhal/fp_simd"] - -# Interrupts -irq = ["axhal/irq", "axruntime/irq", "axtask?/irq"] - -# Real time clock -rtc = ["axhal/rtc", "axruntime/rtc"] - -# Memory -alloc = ["axalloc", "axruntime/alloc"] -alloc-tlsf = ["axalloc/tlsf"] -alloc-slab = ["axalloc/slab"] -alloc-buddy = ["axalloc/buddy"] -paging = ["alloc", "axhal/paging", "axruntime/paging"] -tls = ["alloc", "axhal/tls", "axruntime/tls", "axtask?/tls"] - -# Multi-threading and scheduler -multitask = ["alloc", "axtask/multitask", "axsync/multitask", "axruntime/multitask"] -sched_fifo = ["axtask/sched_fifo"] -sched_rr = ["axtask/sched_rr", "irq"] -sched_cfs = ["axtask/sched_cfs", "irq"] - -# File system -fs = ["alloc", "paging", "dep:axfs", "axruntime/fs"] # TODO: try to remove "paging" -blkfs = ["axdriver/virtio-blk", "axruntime/blkfs"] -myfs = ["axfs?/myfs"] -9pfs = [] - -# Networking -net = ["alloc", "paging", "axdriver/virtio-net", "dep:axnet", "axruntime/net"] - -# Display -display = ["alloc", "paging", "axdriver/virtio-gpu", "dep:axdisplay", "axruntime/display"] - -# Signal -signal = ["axruntime/signal"] - -# 9P -virtio-9p = ["9pfs", "axdriver/virtio-9p", "ax9p/virtio-9p", "axruntime/virtio-9p"] -net-9p = ["9pfs", "net", "ax9p/net-9p", "axruntime/net-9p"] - -# Device drivers -bus-mmio = ["axdriver?/bus-mmio"] -bus-pci = ["axdriver?/bus-pci"] -driver-ramdisk = ["axdriver?/ramdisk", "axfs?/use-ramdisk"] -driver-ixgbe = ["axdriver?/ixgbe"] -driver-bcm2835-sdhci = ["axdriver?/bcm2835-sdhci"] - -# Logging -log-level-off = ["axlog/log-level-off"] -log-level-error = ["axlog/log-level-error"] -log-level-warn = ["axlog/log-level-warn"] -log-level-info = ["axlog/log-level-info"] -log-level-debug = ["axlog/log-level-debug"] -log-level-trace = ["axlog/log-level-trace"] - -# musl -musl = ["axhal/musl", "axruntime/musl", "axalloc/slab", "axtask/musl"] - -[dependencies] -axruntime = { path = "../../modules/axruntime" } -axhal = { path = "../../modules/axhal" } -axlog = { path = "../../modules/axlog" } -axalloc = { path = "../../modules/axalloc", optional = true } -axdriver = { path = "../../modules/axdriver", optional = true } -axfs = { path = "../../modules/axfs", optional = true } -ax9p = { path = "../../modules/ax9p", optional = true } -axnet = { path = "../../modules/axnet", optional = true } -axdisplay = { path = "../../modules/axdisplay", optional = true } -axsync = { path = "../../modules/axsync", optional = true } -axtask = { path = "../../modules/axtask", optional = true } -spinlock = { path = "../../crates/spinlock", optional = true } diff --git a/api/ruxfeat/Cargo.toml b/api/ruxfeat/Cargo.toml new file mode 100644 index 000000000..f9f4b90c8 --- /dev/null +++ b/api/ruxfeat/Cargo.toml @@ -0,0 +1,86 @@ +[package] +name = "ruxfeat" +version = "0.1.0" +edition = "2021" +authors = [ + "Yuekai Jia ", + "yanjuguang ", +] +description = "Top-level feature selection for RuxOS" +license = "GPL-3.0-or-later OR Apache-2.0" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/api/ruxfeat" + +[features] +default = [] + +# Multicore +smp = ["ruxhal/smp", "ruxruntime/smp", "spinlock/smp"] + +# Floating point/SIMD +fp_simd = ["ruxhal/fp_simd", "ruxfs/fp_simd"] + +# Interrupts +irq = ["ruxhal/irq", "ruxruntime/irq", "ruxtask?/irq"] + +# Real time clock +rtc = ["ruxhal/rtc", "ruxruntime/rtc"] + +# Memory +alloc = ["axalloc", "ruxruntime/alloc", "ruxfs/alloc"] +alloc-tlsf = ["axalloc/tlsf"] +alloc-slab = ["axalloc/slab"] +alloc-buddy = ["axalloc/buddy"] +paging = ["alloc", "ruxhal/paging", "ruxruntime/paging"] +tls = ["alloc", "ruxhal/tls", "ruxruntime/tls", "ruxtask?/tls"] + +# Multi-threading and scheduler +multitask = ["alloc", "ruxtask/multitask", "axsync/multitask", "ruxruntime/multitask"] +sched_fifo = ["ruxtask/sched_fifo"] +sched_rr = ["ruxtask/sched_rr", "irq"] +sched_cfs = ["ruxtask/sched_cfs", "irq"] + +# File system +fs = ["alloc", "paging", "dep:ruxfs", "ruxruntime/fs"] # TODO: try to remove "paging" +blkfs = ["ruxdriver/virtio-blk", "ruxruntime/blkfs"] +myfs = ["ruxfs?/myfs"] +9pfs = [] + +# Networking +net = ["alloc", "paging", "ruxdriver/virtio-net", "dep:axnet", "ruxruntime/net"] + +# Display +display = ["alloc", "paging", "ruxdriver/virtio-gpu", "dep:ruxdisplay", "ruxruntime/display"] + +# 9P +virtio-9p = ["9pfs", "ruxdriver/virtio-9p", "rux9p/virtio-9p", "ruxruntime/virtio-9p"] +net-9p = ["9pfs", "net", "rux9p/net-9p", "ruxruntime/net-9p"] + +# Device drivers +bus-mmio = ["ruxdriver?/bus-mmio"] +bus-pci = ["ruxdriver?/bus-pci"] +driver-ramdisk = ["ruxdriver?/ramdisk", "ruxfs?/use-ramdisk"] +driver-ixgbe = ["ruxdriver?/ixgbe"] +driver-bcm2835-sdhci = ["ruxdriver?/bcm2835-sdhci"] + +# Logging +log-level-off = ["axlog/log-level-off"] +log-level-error = ["axlog/log-level-error"] +log-level-warn = ["axlog/log-level-warn"] +log-level-info = ["axlog/log-level-info"] +log-level-debug = ["axlog/log-level-debug"] +log-level-trace = ["axlog/log-level-trace"] + +[dependencies] +ruxruntime = { path = "../../modules/ruxruntime" } +ruxhal = { path = "../../modules/ruxhal" } +axlog = { path = "../../modules/axlog" } +axalloc = { path = "../../modules/axalloc", optional = true } +ruxdriver = { path = "../../modules/ruxdriver", optional = true } +ruxfs = { path = "../../modules/ruxfs", optional = true } +rux9p = { path = "../../modules/rux9p", optional = true } +axnet = { path = "../../modules/axnet", optional = true } +ruxdisplay = { path = "../../modules/ruxdisplay", optional = true } +axsync = { path = "../../modules/axsync", optional = true } +ruxtask = { path = "../../modules/ruxtask", optional = true } +spinlock = { path = "../../crates/spinlock", optional = true } diff --git a/api/axfeat/src/lib.rs b/api/ruxfeat/src/lib.rs similarity index 82% rename from api/axfeat/src/lib.rs rename to api/ruxfeat/src/lib.rs index b805070df..ddaf6a5a9 100644 --- a/api/axfeat/src/lib.rs +++ b/api/ruxfeat/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! Top-level feature selection for [ArceOS]. +//! Top-level feature selection for [Ruxos]. //! //! # Cargo Features //! @@ -28,12 +28,17 @@ //! - `sched_fifo`: Use the FIFO cooperative scheduler. //! - `sched_rr`: Use the Round-robin preemptive scheduler. //! - `sched_cfs`: Use the Completely Fair Scheduler (CFS) preemptive scheduler. -//! - Upperlayer stacks (fs, net, display) +//! - Upperlayer stacks (fs, net, display, rtc) //! - `fs`: Enable file system support. //! - `myfs`: Allow users to define their custom filesystems to override the default. +//! - `blkfs`: Mount block device in root directory. +//! - `9pfs`: Allow user apps to access files in host end by 9p protocol. +//! - `virtio-9p`: Use virtio-9p in hypervisor for 9pfs. +//! - `net-9p`: Use net protocol for 9pfs. //! - `net`: Enable networking support. //! - `display`: Enable graphics support. //! - `signal`: Enable signal support. +//! - `rtc`: Allow user apps to get real time. //! - Device drivers //! - `bus-mmio`: Use device tree to probe all MMIO devices. //! - `bus-pci`: Use PCI bus to probe all PCI devices. @@ -45,6 +50,6 @@ //! - `log-level-error`, `log-level-warn`, `log-level-info`, `log-level-debug`, //! `log-level-trace`: Keep logging only at the specified level or higher. //! -//! [ArceOS]: https://github.com/rcore-os/arceos +//! [Ruxos]: https://github.com/syswonder/ruxos #![no_std] diff --git a/api/arceos_posix_api/.gitignore b/api/ruxos_posix_api/.gitignore similarity index 100% rename from api/arceos_posix_api/.gitignore rename to api/ruxos_posix_api/.gitignore diff --git a/api/arceos_posix_api/Cargo.toml b/api/ruxos_posix_api/Cargo.toml similarity index 56% rename from api/arceos_posix_api/Cargo.toml rename to api/ruxos_posix_api/Cargo.toml index ff37025c5..ed00a274a 100644 --- a/api/arceos_posix_api/Cargo.toml +++ b/api/ruxos_posix_api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "arceos_posix_api" +name = "ruxos_posix_api" version = "0.1.0" edition = "2021" authors = [ @@ -10,40 +10,40 @@ authors = [ "scPointer ", "Shiping Yuan ", ] -description = "POSIX-compatible APIs for ArceOS modules" +description = "POSIX-compatible APIs for Ruxos modules" license = "GPL-3.0-or-later OR Apache-2.0" -repository = "https://github.com/rcore-os/arceos/tree/main/api/arceos_posix_api" +repository = "https://github.com/syswonder/ruxos/tree/main/api/ruxos_posix_api" [features] default = [] -smp = ["axfeat/smp"] -alloc = ["dep:axalloc", "axfeat/alloc"] -multitask = ["axtask/multitask", "axfeat/multitask", "axsync/multitask"] +smp = ["ruxfeat/smp"] +alloc = ["dep:axalloc", "ruxfeat/alloc"] +multitask = ["ruxfeat/multitask", "ruxtask/multitask"] fd = ["alloc"] -fs = ["dep:axfs", "axfeat/fs", "fd"] -net = ["dep:axnet", "axfeat/net", "fd"] -signal = ["axfeat/signal"] +fs = ["dep:ruxfs", "ruxfeat/fs", "fd"] +net = ["dep:axnet", "ruxfeat/net", "fd"] +signal = ["ruxruntime/signal"] pipe = ["fd"] select = ["fd"] epoll = ["fd"] poll = ["fd"] -tls = ["axfeat/tls"] -irq = ["axfeat/irq"] +tls = ["ruxfeat/tls"] +irq = ["ruxfeat/irq"] -musl = ["axfeat/musl"] +musl = ["ruxhal/musl", "ruxruntime/musl", "axalloc/slab", "ruxtask/musl"] [dependencies] -# ArceOS modules -axfeat = { path = "../axfeat" } -axruntime = { path = "../../modules/axruntime" } -axconfig = { path = "../../modules/axconfig" } +# Ruxos modules +ruxfeat = { path = "../ruxfeat" } +ruxruntime = { path = "../../modules/ruxruntime" } +ruxconfig = { path = "../../modules/ruxconfig" } axlog = { path = "../../modules/axlog" } -axhal = { path = "../../modules/axhal" } +ruxhal = { path = "../../modules/ruxhal" } axsync = { path = "../../modules/axsync" } axalloc = { path = "../../modules/axalloc", optional = true } -axtask = { path = "../../modules/axtask", optional = true } -axfs = { path = "../../modules/axfs", optional = true } +ruxtask = { path = "../../modules/ruxtask", optional = true } +ruxfs = { path = "../../modules/ruxfs", optional = true } axnet = { path = "../../modules/axnet", optional = true } # Other crates diff --git a/api/arceos_posix_api/build.rs b/api/ruxos_posix_api/build.rs similarity index 91% rename from api/arceos_posix_api/build.rs rename to api/ruxos_posix_api/build.rs index 6a8d6f7d2..80daa27d8 100644 --- a/api/arceos_posix_api/build.rs +++ b/api/ruxos_posix_api/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -23,7 +23,7 @@ fn main() { let mut output = Vec::new(); writeln!( output, - "// Generated by arceos_posix_api/build.rs, DO NOT edit!" + "// Generated by ruxos_posix_api/build.rs, DO NOT edit!" )?; writeln!( output, @@ -52,7 +52,7 @@ typedef struct {{ let mut output = Vec::new(); writeln!( output, - "// Generated by arceos_posix_api/build.rs, DO NOT edit!" + "// Generated by ruxos_posix_api/build.rs, DO NOT edit!" )?; writeln!( output, @@ -137,7 +137,7 @@ typedef struct {{ let mut builder = bindgen::Builder::default() .header(in_file) - .clang_arg("-I./../../ulib/axlibc/include") + .clang_arg("-I./../../ulib/ruxlibc/include") .parse_callbacks(Box::new(MyCallbacks)) .derive_default(true) .size_t_is_usize(false) @@ -156,7 +156,7 @@ typedef struct {{ .expect("Couldn't write bindings!"); } - gen_pthread_mutex("../../ulib/axlibc/include/ax_pthread_mutex.h").unwrap(); - gen_pthread_cond("../../ulib/axlibc/include/ax_pthread_cond.h").unwrap(); + gen_pthread_mutex("../../ulib/ruxlibc/include/ax_pthread_mutex.h").unwrap(); + gen_pthread_cond("../../ulib/ruxlibc/include/ax_pthread_cond.h").unwrap(); gen_c_to_rust_bindings("ctypes.h", "src/ctypes_gen.rs"); } diff --git a/api/arceos_posix_api/ctypes.h b/api/ruxos_posix_api/ctypes.h similarity index 93% rename from api/arceos_posix_api/ctypes.h rename to api/ruxos_posix_api/ctypes.h index 24907306a..f1ad47277 100644 --- a/api/arceos_posix_api/ctypes.h +++ b/api/ruxos_posix_api/ctypes.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/api/arceos_posix_api/src/imp/fd_ops.rs b/api/ruxos_posix_api/src/imp/fd_ops.rs similarity index 96% rename from api/arceos_posix_api/src/imp/fd_ops.rs rename to api/ruxos_posix_api/src/imp/fd_ops.rs index e46283fa4..c0c6be9f1 100644 --- a/api/arceos_posix_api/src/imp/fd_ops.rs +++ b/api/ruxos_posix_api/src/imp/fd_ops.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -19,7 +19,7 @@ use super::stdio::{stdin, stdout}; use crate::ctypes; /// Maximum number of files per process -pub const AX_FILE_LIMIT: usize = 1024; +pub const RUX_FILE_LIMIT: usize = 1024; pub trait FileLike: Send + Sync { fn read(&self, buf: &mut [u8]) -> LinuxResult; @@ -31,7 +31,7 @@ pub trait FileLike: Send + Sync { } lazy_static::lazy_static! { - static ref FD_TABLE: RwLock, AX_FILE_LIMIT>> = { + static ref FD_TABLE: RwLock, RUX_FILE_LIMIT>> = { let mut fd_table = FlattenObjects::new(); fd_table.add_at(0, Arc::new(stdin()) as _).unwrap(); // stdin fd_table.add_at(1, Arc::new(stdout()) as _).unwrap(); // stdout @@ -96,9 +96,10 @@ pub fn sys_dup2(old_fd: c_int, new_fd: c_int) -> c_int { return Ok(r); } } - if new_fd as usize >= AX_FILE_LIMIT { + if new_fd as usize >= RUX_FILE_LIMIT { return Err(LinuxError::EBADF); } + close_file_like(new_fd)?; let f = get_file_like(old_fd)?; FD_TABLE diff --git a/api/arceos_posix_api/src/imp/fs.rs b/api/ruxos_posix_api/src/imp/fs.rs similarity index 83% rename from api/arceos_posix_api/src/imp/fs.rs rename to api/ruxos_posix_api/src/imp/fs.rs index cc6ea2938..44ce939f2 100644 --- a/api/arceos_posix_api/src/imp/fs.rs +++ b/api/ruxos_posix_api/src/imp/fs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,19 +11,19 @@ use alloc::sync::Arc; use core::ffi::{c_char, c_int}; use axerrno::{LinuxError, LinuxResult}; -use axfs::fops::OpenOptions; use axio::{PollState, SeekFrom}; use axsync::Mutex; +use ruxfs::fops::OpenOptions; use super::fd_ops::{get_file_like, FileLike}; use crate::{ctypes, utils::char_ptr_to_str}; pub struct File { - inner: Mutex, + inner: Mutex, } impl File { - fn new(inner: axfs::fops::File) -> Self { + fn new(inner: ruxfs::fops::File) -> Self { Self { inner: Mutex::new(inner), } @@ -120,7 +120,7 @@ pub fn sys_open(filename: *const c_char, flags: c_int, mode: ctypes::mode_t) -> debug!("sys_open <= {:?} {:#o} {:#o}", filename, flags, mode); syscall_body!(sys_open, { let options = flags_to_options(flags, mode); - let file = axfs::fops::File::open(filename?, &options)?; + let file = ruxfs::fops::File::open(filename?, &options)?; File::new(file).add_to_fd_table() }) } @@ -133,7 +133,7 @@ pub fn sys_openat(_fd: usize, path: *const c_char, flags: c_int, mode: ctypes::m debug!("sys_openat <= {:?}, {:#o} {:#o}", path, flags, mode); syscall_body!(sys_openat, { let options = flags_to_options(flags, mode); - let file = axfs::fops::File::open(path?, &options)?; + let file = ruxfs::fops::File::open(path?, &options)?; File::new(file).add_to_fd_table() }) } @@ -155,12 +155,22 @@ pub fn sys_lseek(fd: c_int, offset: ctypes::off_t, whence: c_int) -> ctypes::off }) } -/// `fsync` +/// Synchronize a file's in-core state with storage device +/// +/// TODO pub unsafe fn sys_fsync(fd: c_int) -> c_int { debug!("sys_fsync <= fd: {}", fd); syscall_body!(sys_fsync, Ok(0)) } +/// Synchronize a file's in-core state with storage device +/// +/// TODO +pub unsafe fn sys_fdatasync(fd: c_int) -> c_int { + debug!("sys_fdatasync <= fd: {}", fd); + syscall_body!(sys_fdatasync, Ok(0)) +} + /// Get the file metadata by `path` and write into `buf`. /// /// Return 0 if success. @@ -173,7 +183,7 @@ pub unsafe fn sys_stat(path: *const c_char, buf: *mut ctypes::stat) -> c_int { } let mut options = OpenOptions::new(); options.read(true); - let file = axfs::fops::File::open(path?, &options)?; + let file = ruxfs::fops::File::open(path?, &options)?; let st = File::new(file).stat()?; unsafe { *buf = st }; Ok(0) @@ -247,7 +257,7 @@ pub unsafe fn sys_newfstatat( } let mut options = OpenOptions::new(); options.read(true); - let file = axfs::fops::File::open(path?, &options)?; + let file = ruxfs::fops::File::open(path?, &options)?; let st = File::new(file).stat()?; unsafe { (*kst).st_dev = st.st_dev; @@ -272,7 +282,7 @@ pub fn sys_getcwd(buf: *mut c_char, size: usize) -> c_int { return Err(LinuxError::EINVAL); } let dst = unsafe { core::slice::from_raw_parts_mut(buf as *mut u8, size as _) }; - let cwd = axfs::api::current_dir()?; + let cwd = ruxfs::api::current_dir()?; let cwd = cwd.as_bytes(); if cwd.len() < size { dst[..cwd.len()].copy_from_slice(cwd); @@ -293,7 +303,25 @@ pub fn sys_rename(old: *const c_char, new: *const c_char) -> c_int { let old_path = char_ptr_to_str(old)?; let new_path = char_ptr_to_str(new)?; debug!("sys_rename <= old: {:?}, new: {:?}", old_path, new_path); - axfs::api::rename(old_path, new_path)?; + ruxfs::api::rename(old_path, new_path)?; + Ok(0) + }) +} + +/// Rename at certain directory pointed by `oldfd` +/// +/// TODO: only support `oldfd`, `newfd` equals to AT_FDCWD +pub fn sys_renameat(oldfd: c_int, old: *const c_char, newfd: c_int, new: *const c_char) -> c_int { + let old_path = char_ptr_to_str(old); + let new_path = char_ptr_to_str(new); + debug!( + "sys_renameat <= oldfd: {}, old: {:?}, newfd: {}, new: {:?}", + oldfd, old_path, newfd, new_path + ); + assert_eq!(oldfd, ctypes::AT_FDCWD as c_int); + assert_eq!(newfd, ctypes::AT_FDCWD as c_int); + syscall_body!(sys_renameat, { + ruxfs::api::rename(old_path?, new_path?)?; Ok(0) }) } @@ -303,7 +331,7 @@ pub fn sys_rmdir(pathname: *const c_char) -> c_int { syscall_body!(sys_rmdir, { let path = char_ptr_to_str(pathname)?; debug!("sys_rmdir <= path: {:?}", path); - axfs::api::remove_dir(path)?; + ruxfs::api::remove_dir(path)?; Ok(0) }) } @@ -312,8 +340,8 @@ pub fn sys_rmdir(pathname: *const c_char) -> c_int { pub fn sys_unlink(pathname: *const c_char) -> c_int { syscall_body!(sys_unlink, { let path = char_ptr_to_str(pathname)?; - debug!("ax_unlink <= path: {:?}", path); - axfs::api::remove_file(path)?; + debug!("sys_unlink <= path: {:?}", path); + ruxfs::api::remove_file(path)?; Ok(0) }) } @@ -337,8 +365,8 @@ pub fn sys_mkdir(pathname: *const c_char, mode: ctypes::mode_t) -> c_int { // TODO: implement mode syscall_body!(sys_mkdir, { let path = char_ptr_to_str(pathname)?; - debug!("ax_mkdir <= path: {:?}, mode: {:?}", path, mode); - axfs::api::create_dir(path)?; + debug!("sys_mkdir <= path: {:?}, mode: {:?}", path, mode); + ruxfs::api::create_dir(path)?; Ok(0) }) } @@ -355,3 +383,22 @@ pub fn sys_mkdirat(fd: c_int, pathname: *const c_char, mode: ctypes::mode_t) -> ); sys_mkdir(pathname, mode) } + +/// Changes the ownership of the file referred to by the open file descriptor fd +pub fn sys_fchownat( + fd: c_int, + path: *const c_char, + uid: ctypes::uid_t, + gid: ctypes::gid_t, + flag: c_int, +) -> c_int { + debug!( + "sys_fchownat <= fd: {}, path: {:?}, uid: {}, gid: {}, flag: {}", + fd, + char_ptr_to_str(path), + uid, + gid, + flag + ); + syscall_body!(sys_fchownat, Ok(0)) +} diff --git a/api/arceos_posix_api/src/imp/io.rs b/api/ruxos_posix_api/src/imp/io.rs similarity index 76% rename from api/arceos_posix_api/src/imp/io.rs rename to api/ruxos_posix_api/src/imp/io.rs index aa5ed4003..c509c567c 100644 --- a/api/arceos_posix_api/src/imp/io.rs +++ b/api/ruxos_posix_api/src/imp/io.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -62,7 +62,8 @@ pub fn sys_write(fd: c_int, buf: *const c_void, count: usize) -> ctypes::ssize_t }) } -/// Write a vector. +/// Writes `iocnt` buffers of data described by `iov` to the file associated with the file +/// descriptor `fd` pub unsafe fn sys_writev(fd: c_int, iov: *const ctypes::iovec, iocnt: c_int) -> ctypes::ssize_t { debug!("sys_writev <= fd: {}, iocnt: {}", fd, iocnt); syscall_body!(sys_writev, { @@ -82,3 +83,23 @@ pub unsafe fn sys_writev(fd: c_int, iov: *const ctypes::iovec, iocnt: c_int) -> Ok(ret) }) } +/// Reads `iocnt` buffers from the file associated with the file descriptor `fd` into the +/// buffers described by `iov` +pub unsafe fn sys_readv(fd: c_int, iov: *const ctypes::iovec, iocnt: c_int) -> ctypes::ssize_t { + debug!("sys_readv <= fd: {}, iocnt: {}", fd, iocnt); + syscall_body!(sys_readv, { + if !(0..=1024).contains(&iocnt) { + return Err(LinuxError::EINVAL); + } + + let iovs = unsafe { core::slice::from_raw_parts(iov, iocnt as usize) }; + let mut ret = 0; + for iov in iovs.iter() { + if iov.iov_base.is_null() { + continue; + } + ret += sys_read(fd, iov.iov_base, iov.iov_len); + } + Ok(ret) + }) +} diff --git a/api/arceos_posix_api/src/imp/io_mpx/epoll.rs b/api/ruxos_posix_api/src/imp/io_mpx/epoll.rs similarity index 87% rename from api/arceos_posix_api/src/imp/io_mpx/epoll.rs rename to api/ruxos_posix_api/src/imp/io_mpx/epoll.rs index 5323dc6ea..68c7b8a50 100644 --- a/api/arceos_posix_api/src/imp/io_mpx/epoll.rs +++ b/api/ruxos_posix_api/src/imp/io_mpx/epoll.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -17,8 +17,8 @@ use alloc::sync::Arc; use core::{ffi::c_int, time::Duration}; use axerrno::{LinuxError, LinuxResult}; -use axhal::time::current_time; use axsync::Mutex; +use ruxhal::time::current_time; use crate::ctypes; use crate::imp::fd_ops::{add_file_like, get_file_like, FileLike}; @@ -215,7 +215,29 @@ pub unsafe fn sys_epoll_wait( loop { #[cfg(feature = "net")] axnet::poll_interfaces(); - let events_num = epoll_instance.poll_all(events)?; + + let poll_all_res = epoll_instance.poll_all(events); + let mut events_num = 0; + match poll_all_res { + Ok(num) => events_num = num, + Err(LinuxError::EBADF) => { + error!("sys_epoll_wait a non-exist fd"); + let mut events = epoll_instance.events.lock(); + let del_fds = events + .iter() + .filter(|(&fd, _)| get_file_like(fd as _).is_err()) + .map(|(&fd, _)| fd) + .collect::>(); + del_fds.iter().for_each(|&fd| { + if let Entry::Occupied(ocp) = events.entry(fd) { + ocp.remove_entry(); + } + }); + return Ok(0); + } + Err(_) => {} + } + if events_num > 0 { return Ok(events_num as c_int); } diff --git a/api/arceos_posix_api/src/imp/io_mpx/mod.rs b/api/ruxos_posix_api/src/imp/io_mpx/mod.rs similarity index 96% rename from api/arceos_posix_api/src/imp/io_mpx/mod.rs rename to api/ruxos_posix_api/src/imp/io_mpx/mod.rs index 046483e7b..77a62e3e8 100644 --- a/api/arceos_posix_api/src/imp/io_mpx/mod.rs +++ b/api/ruxos_posix_api/src/imp/io_mpx/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/io_mpx/poll.rs b/api/ruxos_posix_api/src/imp/io_mpx/poll.rs similarity index 86% rename from api/arceos_posix_api/src/imp/io_mpx/poll.rs rename to api/ruxos_posix_api/src/imp/io_mpx/poll.rs index 170efbfcb..cdc9c34f5 100644 --- a/api/arceos_posix_api/src/imp/io_mpx/poll.rs +++ b/api/ruxos_posix_api/src/imp/io_mpx/poll.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,13 +7,9 @@ * See the Mulan PSL v2 for more details. */ -/// Add `poll` feature to use poll() interface. -/// poll() is a system call function used to monitor I/O events across multiple file descriptors. -/// poll() is a blocking type of interface, make sure that this does not cost too much. -/// To monitor I/O events, you can also use `select` or `epoll` instead. use crate::{ctypes, imp::fd_ops::get_file_like}; use axerrno::{LinuxError, LinuxResult}; -use axhal::time::current_time; +use ruxhal::time::current_time; use core::{ffi::c_int, time::Duration}; @@ -60,7 +56,7 @@ pub unsafe fn sys_ppoll( /// Used to monitor multiple file descriptors for events pub unsafe fn sys_poll(fds: *mut ctypes::pollfd, nfds: ctypes::nfds_t, timeout: c_int) -> c_int { - debug!("ax_poll <= nfds: {} timeout: {} ms", nfds, timeout); + debug!("sys_poll <= nfds: {} timeout: {} ms", nfds, timeout); syscall_body!(ax_poll, { if nfds == 0 { diff --git a/api/arceos_posix_api/src/imp/io_mpx/select.rs b/api/ruxos_posix_api/src/imp/io_mpx/select.rs similarity index 98% rename from api/arceos_posix_api/src/imp/io_mpx/select.rs rename to api/ruxos_posix_api/src/imp/io_mpx/select.rs index fdec72cc9..2631e7f1f 100644 --- a/api/arceos_posix_api/src/imp/io_mpx/select.rs +++ b/api/ruxos_posix_api/src/imp/io_mpx/select.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,7 +10,7 @@ use core::ffi::{c_int, c_void}; use axerrno::{LinuxError, LinuxResult}; -use axhal::time::current_time; +use ruxhal::time::current_time; use crate::{ctypes, imp::fd_ops::get_file_like}; diff --git a/api/arceos_posix_api/src/imp/ioctl.rs b/api/ruxos_posix_api/src/imp/ioctl.rs similarity index 85% rename from api/arceos_posix_api/src/imp/ioctl.rs rename to api/ruxos_posix_api/src/imp/ioctl.rs index f0f027f39..3339ed880 100644 --- a/api/arceos_posix_api/src/imp/ioctl.rs +++ b/api/ruxos_posix_api/src/imp/ioctl.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,6 +7,7 @@ * See the Mulan PSL v2 for more details. */ +use crate::imp::fd_ops::get_file_like; use axerrno::LinuxError; use core::ffi::c_int; @@ -15,6 +16,7 @@ pub const TCGETS: usize = 0x5401; pub const TIOCGPGRP: usize = 0x540F; pub const TIOCSPGRP: usize = 0x5410; pub const TIOCGWINSZ: usize = 0x5413; +pub const FIONBIO: usize = 0x5421; #[derive(Clone, Copy, Default)] pub struct ConsoleWinSize { @@ -28,12 +30,14 @@ pub struct ConsoleWinSize { /// currently only support fd = 1 pub fn sys_ioctl(fd: c_int, request: usize, data: usize) -> c_int { debug!("sys_ioctl <= fd: {}, request: {}", fd, request); - if fd != 1 { - debug!("Only support fd = 1"); - return -1; - } syscall_body!(sys_ioctl, { match request { + FIONBIO => { + unsafe { + get_file_like(fd)?.set_nonblocking(*(data as *const i32) > 0)?; + } + Ok(0) + } TIOCGWINSZ => { let winsize = data as *mut ConsoleWinSize; unsafe { diff --git a/api/arceos_posix_api/src/imp/mmap.rs b/api/ruxos_posix_api/src/imp/mmap.rs similarity index 98% rename from api/arceos_posix_api/src/imp/mmap.rs rename to api/ruxos_posix_api/src/imp/mmap.rs index d1de148dd..81934328b 100644 --- a/api/arceos_posix_api/src/imp/mmap.rs +++ b/api/ruxos_posix_api/src/imp/mmap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/mod.rs b/api/ruxos_posix_api/src/imp/mod.rs similarity index 96% rename from api/arceos_posix_api/src/imp/mod.rs rename to api/ruxos_posix_api/src/imp/mod.rs index 5e6c59fab..8ff9f39ef 100644 --- a/api/arceos_posix_api/src/imp/mod.rs +++ b/api/ruxos_posix_api/src/imp/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/net.rs b/api/ruxos_posix_api/src/imp/net.rs similarity index 99% rename from api/arceos_posix_api/src/imp/net.rs rename to api/ruxos_posix_api/src/imp/net.rs index be4b94b46..264afa279 100644 --- a/api/arceos_posix_api/src/imp/net.rs +++ b/api/ruxos_posix_api/src/imp/net.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/pipe.rs b/api/ruxos_posix_api/src/imp/pipe.rs similarity index 99% rename from api/arceos_posix_api/src/imp/pipe.rs rename to api/ruxos_posix_api/src/imp/pipe.rs index 98b84ef36..b65876dd6 100644 --- a/api/arceos_posix_api/src/imp/pipe.rs +++ b/api/ruxos_posix_api/src/imp/pipe.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/pthread/condvar.rs b/api/ruxos_posix_api/src/imp/pthread/condvar.rs similarity index 98% rename from api/arceos_posix_api/src/imp/pthread/condvar.rs rename to api/ruxos_posix_api/src/imp/pthread/condvar.rs index 9ff9bc706..8edccc1df 100644 --- a/api/arceos_posix_api/src/imp/pthread/condvar.rs +++ b/api/ruxos_posix_api/src/imp/pthread/condvar.rs @@ -1,17 +1,18 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ + use core::ffi::c_int; +use core::mem::size_of; use crate::{ctypes, sys_pthread_mutex_lock, sys_pthread_mutex_unlock}; use axerrno::LinuxResult; -use axtask::WaitQueue; -use core::mem::size_of; +use ruxtask::WaitQueue; static_assertions::const_assert_eq!(size_of::(), size_of::()); diff --git a/api/arceos_posix_api/src/imp/pthread/dummy.rs b/api/ruxos_posix_api/src/imp/pthread/dummy.rs similarity index 97% rename from api/arceos_posix_api/src/imp/pthread/dummy.rs rename to api/ruxos_posix_api/src/imp/pthread/dummy.rs index 3df326452..f87c2dd9a 100644 --- a/api/arceos_posix_api/src/imp/pthread/dummy.rs +++ b/api/ruxos_posix_api/src/imp/pthread/dummy.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/pthread/futex.rs b/api/ruxos_posix_api/src/imp/pthread/futex.rs similarity index 96% rename from api/arceos_posix_api/src/imp/pthread/futex.rs rename to api/ruxos_posix_api/src/imp/pthread/futex.rs index 527d11ca1..4fdbf7f45 100644 --- a/api/arceos_posix_api/src/imp/pthread/futex.rs +++ b/api/ruxos_posix_api/src/imp/pthread/futex.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,13 +7,13 @@ * See the Mulan PSL v2 for more details. */ +use alloc::collections::{BTreeMap, VecDeque}; use core::{ffi::c_int, time::Duration}; -use alloc::collections::{BTreeMap, VecDeque}; use axerrno::LinuxError; use axsync::Mutex; -use axtask::{current, AxTaskRef, TaskState, WaitQueue}; use memory_addr::VirtAddr; +use ruxtask::{current, AxTaskRef, TaskState, WaitQueue}; use crate::ctypes; @@ -89,7 +89,7 @@ pub fn sys_futex( // TODO: check signals if timeout == 0 { - axtask::yield_now(); + ruxtask::yield_now(); } else { #[cfg(feature = "irq")] { @@ -128,7 +128,7 @@ pub fn sys_futex( } else { drop(futex_wait_task); } - axtask::yield_now(); + ruxtask::yield_now(); Ok(val) } FutexFlags::Requeue => { diff --git a/api/arceos_posix_api/src/imp/pthread/mod.rs b/api/ruxos_posix_api/src/imp/pthread/mod.rs similarity index 93% rename from api/arceos_posix_api/src/imp/pthread/mod.rs rename to api/ruxos_posix_api/src/imp/pthread/mod.rs index 64bf4706c..1125c7b96 100644 --- a/api/arceos_posix_api/src/imp/pthread/mod.rs +++ b/api/ruxos_posix_api/src/imp/pthread/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,7 +12,7 @@ use core::cell::UnsafeCell; use core::ffi::{c_int, c_void}; use axerrno::{LinuxError, LinuxResult}; -use axtask::AxTaskRef; +use ruxtask::AxTaskRef; use spin::RwLock; use crate::ctypes; @@ -39,7 +39,7 @@ pub use tsd::{ lazy_static::lazy_static! { static ref TID_TO_PTHREAD: RwLock>> = { let mut map = BTreeMap::new(); - let main_task = axtask::current(); + let main_task = ruxtask::current(); let main_tid = main_task.id().as_u64(); let main_thread = Pthread { inner: main_task.as_task_ref().clone(), @@ -85,7 +85,7 @@ impl Pthread { drop(their_packet); }; - let task_inner = axtask::spawn(main); + let task_inner = ruxtask::spawn(main); let tid = task_inner.id().as_u64(); let thread = Pthread { inner: task_inner, @@ -117,7 +117,7 @@ impl Pthread { start_routine(arg.0); }; - let task_inner = axtask::pspawn(main, tls as usize, set_tid, tl); + let task_inner = ruxtask::pspawn(main, tls as usize, set_tid, tl); let tid = task_inner.id().as_u64(); let thread = Pthread { @@ -130,7 +130,7 @@ impl Pthread { } fn current_ptr() -> *mut Pthread { - let tid = axtask::current().id().as_u64(); + let tid = ruxtask::current().id().as_u64(); match TID_TO_PTHREAD.read().get(&tid) { None => core::ptr::null_mut(), Some(ptr) => ptr.0 as *mut Pthread, @@ -153,14 +153,14 @@ impl Pthread { TID_TO_PTHREAD.write().remove(&tid); debug!("Exit_musl, tid: {}", tid); drop(thread); - axtask::exit(0) + ruxtask::exit(0) } #[cfg(not(feature = "musl"))] fn exit_current(retval: *mut c_void) -> ! { let thread = Self::current().expect("fail to get current thread"); unsafe { *thread.retval.result.get() = retval }; - axtask::exit(0); + ruxtask::exit(0); } fn join(ptr: ctypes::pthread_t) -> LinuxResult<*mut c_void> { @@ -209,9 +209,9 @@ pub fn sys_pthread_exit(retval: *mut c_void) -> ! { debug!("sys_pthread_exit <= {:#x}", retval as usize); #[cfg(feature = "musl")] { - let id = axtask::current().as_task_ref().id().as_u64(); + let id = ruxtask::current().as_task_ref().id().as_u64(); if id != 2u64 { - axtask::current().as_task_ref().free_thread_list_lock(); + ruxtask::current().as_task_ref().free_thread_list_lock(); } // retval is exit code for musl Pthread::exit_musl(retval as usize); @@ -285,7 +285,7 @@ pub unsafe fn sys_clone( unsafe { *ptid = tid as c_int }; } - axtask::put_task(task_inner); + ruxtask::put_task(task_inner); Ok(tid) }) @@ -296,8 +296,8 @@ pub unsafe fn sys_clone( pub fn sys_set_tid_address(tid: usize) -> c_int { syscall_body!(sys_set_tid_address, { debug!("set_tid_address <= addr: {:#x}", tid); - let id = axtask::current().id().as_u64() as c_int; - axtask::current().as_task_ref().set_child_tid(tid); + let id = ruxtask::current().id().as_u64() as c_int; + ruxtask::current().as_task_ref().set_child_tid(tid); Ok(id) }) } diff --git a/api/arceos_posix_api/src/imp/pthread/mutex.rs b/api/ruxos_posix_api/src/imp/pthread/mutex.rs similarity index 98% rename from api/arceos_posix_api/src/imp/pthread/mutex.rs rename to api/ruxos_posix_api/src/imp/pthread/mutex.rs index 8e872676a..64e1dedc8 100644 --- a/api/arceos_posix_api/src/imp/pthread/mutex.rs +++ b/api/ruxos_posix_api/src/imp/pthread/mutex.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/api/arceos_posix_api/src/imp/pthread/tsd.rs b/api/ruxos_posix_api/src/imp/pthread/tsd.rs similarity index 84% rename from api/arceos_posix_api/src/imp/pthread/tsd.rs rename to api/ruxos_posix_api/src/imp/pthread/tsd.rs index 3d0a724c1..c05ea127f 100644 --- a/api/arceos_posix_api/src/imp/pthread/tsd.rs +++ b/api/ruxos_posix_api/src/imp/pthread/tsd.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,8 +9,8 @@ use crate::ctypes; use axerrno::LinuxError; -use axtask::tsd::DestrFunction; use core::ffi::{c_int, c_void}; +use ruxtask::tsd::DestrFunction; /// Allocate a specific key for a process shared by all threads. pub unsafe fn sys_pthread_key_create( @@ -19,7 +19,7 @@ pub unsafe fn sys_pthread_key_create( ) -> c_int { debug!("sys_pthread_key_create <= {:#x}", key as usize); syscall_body!(sys_pthread_key_create, { - if let Some(k) = axtask::current().alloc_key(destr_function) { + if let Some(k) = ruxtask::current().alloc_key(destr_function) { unsafe { *key = k as ctypes::pthread_key_t; } @@ -34,7 +34,7 @@ pub unsafe fn sys_pthread_key_create( pub fn sys_pthread_key_delete(key: ctypes::pthread_key_t) -> c_int { debug!("sys_pthread_key_delete <= {}", key); syscall_body!(sys_pthread_key_delete, { - if let Some(_) = axtask::current().free_key(key as usize) { + if let Some(_) = ruxtask::current().free_key(key as usize) { Ok(0) } else { Err(LinuxError::EINVAL) @@ -46,7 +46,7 @@ pub fn sys_pthread_key_delete(key: ctypes::pthread_key_t) -> c_int { pub fn sys_pthread_setspecific(key: ctypes::pthread_key_t, value: *const c_void) -> c_int { debug!("sys_pthread_setspecific <= {}, {:#x}", key, value as usize); syscall_body!(sys_pthread_setspecific, { - if let Some(_) = axtask::current().set_tsd(key as usize, value as *mut c_void) { + if let Some(_) = ruxtask::current().set_tsd(key as usize, value as *mut c_void) { Ok(0) } else { Err(LinuxError::EINVAL) @@ -58,7 +58,7 @@ pub fn sys_pthread_setspecific(key: ctypes::pthread_key_t, value: *const c_void) pub fn sys_pthread_getspecific(key: ctypes::pthread_key_t) -> *mut c_void { debug!("sys_pthread_getspecific <= {}", key); syscall_body!(sys_pthread_getspecific, { - if let Some(tsd) = axtask::current().get_tsd(key as usize) { + if let Some(tsd) = ruxtask::current().get_tsd(key as usize) { Ok(tsd) } else { // return null diff --git a/api/arceos_posix_api/src/imp/resources.rs b/api/ruxos_posix_api/src/imp/resources.rs similarity index 91% rename from api/arceos_posix_api/src/imp/resources.rs rename to api/ruxos_posix_api/src/imp/resources.rs index 6614b6d56..eec2f6751 100644 --- a/api/arceos_posix_api/src/imp/resources.rs +++ b/api/ruxos_posix_api/src/imp/resources.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -45,8 +45,8 @@ pub unsafe fn sys_getrlimit(resource: c_int, rlimits: *mut ctypes::rlimit) -> c_ ctypes::RLIMIT_FSIZE => {} ctypes::RLIMIT_DATA => {} ctypes::RLIMIT_STACK => unsafe { - (*rlimits).rlim_cur = axconfig::TASK_STACK_SIZE as _; - (*rlimits).rlim_max = axconfig::TASK_STACK_SIZE as _; + (*rlimits).rlim_cur = ruxconfig::TASK_STACK_SIZE as _; + (*rlimits).rlim_max = ruxconfig::TASK_STACK_SIZE as _; }, ctypes::RLIMIT_CORE => {} ctypes::RLIMIT_RSS => {} @@ -56,8 +56,8 @@ pub unsafe fn sys_getrlimit(resource: c_int, rlimits: *mut ctypes::rlimit) -> c_ }, #[cfg(feature = "fd")] ctypes::RLIMIT_NOFILE => unsafe { - (*rlimits).rlim_cur = super::fd_ops::AX_FILE_LIMIT as _; - (*rlimits).rlim_max = super::fd_ops::AX_FILE_LIMIT as _; + (*rlimits).rlim_cur = super::fd_ops::RUX_FILE_LIMIT as _; + (*rlimits).rlim_max = super::fd_ops::RUX_FILE_LIMIT as _; }, ctypes::RLIMIT_MEMLOCK => {} ctypes::RLIMIT_AS => {} diff --git a/api/arceos_posix_api/src/imp/rt_sig.rs b/api/ruxos_posix_api/src/imp/rt_sig.rs similarity index 55% rename from api/arceos_posix_api/src/imp/rt_sig.rs rename to api/ruxos_posix_api/src/imp/rt_sig.rs index 636e7fdd9..e26066679 100644 --- a/api/arceos_posix_api/src/imp/rt_sig.rs +++ b/api/ruxos_posix_api/src/imp/rt_sig.rs @@ -1,3 +1,12 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + //! Signal implementation, used by musl use core::ffi::c_int; diff --git a/api/ruxos_posix_api/src/imp/signal.rs b/api/ruxos_posix_api/src/imp/signal.rs new file mode 100644 index 000000000..4da9474b1 --- /dev/null +++ b/api/ruxos_posix_api/src/imp/signal.rs @@ -0,0 +1,67 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +use core::ffi::c_int; +use core::time::Duration; + +use crate::ctypes; +use crate::ctypes::k_sigaction; + +use axerrno::LinuxError; +use ruxruntime::{rx_sigaction, Signal}; + +/// Set signal handler +pub fn sys_sigaction( + signum: u8, + sigaction: Option<&k_sigaction>, + oldact: Option<&mut k_sigaction>, +) { + Signal::sigaction( + signum, + sigaction.map(|act| act as *const k_sigaction as *const rx_sigaction), + oldact.map(|old| old as *mut k_sigaction as *mut rx_sigaction), + ); +} + +/// Set a timer to send a signal to the current process after a specified time +pub unsafe fn sys_setitimer(which: c_int, new: *const ctypes::itimerval) -> c_int { + syscall_body!(sys_setitimer, { + let which = which as usize; + let new_interval = Duration::from((*new).it_interval).as_nanos() as u64; + Signal::timer_interval(which, Some(new_interval)); + + let new_ddl = + ruxhal::time::current_time_nanos() + Duration::from((*new).it_value).as_nanos() as u64; + Signal::timer_deadline(which, Some(new_ddl)); + Ok(0) + }) +} + +/// Get timer to send signal after some time +pub unsafe fn sys_getitimer(which: c_int, curr_value: *mut ctypes::itimerval) -> c_int { + syscall_body!(sys_getitimer, { + let ddl = Duration::from_nanos(Signal::timer_deadline(which as usize, None).unwrap()); + if ddl.as_nanos() == 0 { + return Err(LinuxError::EINVAL); + } + let mut now: ctypes::timespec = ctypes::timespec::default(); + unsafe { + crate::sys_clock_gettime(0, &mut now); + } + let now = Duration::from(now); + if ddl > now { + (*curr_value).it_value = ctypes::timeval::from(ddl - now); + } else { + (*curr_value).it_value = ctypes::timeval::from(Duration::new(0, 0)); + } + (*curr_value).it_interval = + Duration::from_nanos(Signal::timer_interval(which as usize, None).unwrap()).into(); + Ok(0) + }) +} diff --git a/api/arceos_posix_api/src/imp/stat.rs b/api/ruxos_posix_api/src/imp/stat.rs similarity index 73% rename from api/arceos_posix_api/src/imp/stat.rs rename to api/ruxos_posix_api/src/imp/stat.rs index 941d5e4e9..1c2e16868 100644 --- a/api/arceos_posix_api/src/imp/stat.rs +++ b/api/ruxos_posix_api/src/imp/stat.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,8 +9,15 @@ use crate::ctypes; -/// `umask` +/// Set file mode creation mask +/// +/// TODO: pub fn sys_umask(mode: ctypes::mode_t) -> ctypes::mode_t { debug!("sys_umask <= mode: {:x}", mode); syscall_body!(sys_umask, Ok(0)) } + +/// Returns the effective user ID of the calling process +pub fn sys_geteuid() -> core::ffi::c_uint { + syscall_body!(sys_geteuid, Ok(0)) +} diff --git a/api/arceos_posix_api/src/imp/stdio.rs b/api/ruxos_posix_api/src/imp/stdio.rs similarity index 96% rename from api/arceos_posix_api/src/imp/stdio.rs rename to api/ruxos_posix_api/src/imp/stdio.rs index 9f541bd70..39a02b09e 100644 --- a/api/arceos_posix_api/src/imp/stdio.rs +++ b/api/ruxos_posix_api/src/imp/stdio.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -15,11 +15,11 @@ use axsync::Mutex; use {alloc::sync::Arc, axerrno::LinuxError, axerrno::LinuxResult, axio::PollState}; fn console_read_bytes() -> Option { - axhal::console::getchar().map(|c| if c == b'\r' { b'\n' } else { c }) + ruxhal::console::getchar().map(|c| if c == b'\r' { b'\n' } else { c }) } fn console_write_bytes(buf: &[u8]) -> AxResult { - axhal::console::write_bytes(buf); + ruxhal::console::write_bytes(buf); Ok(buf.len()) } diff --git a/api/arceos_posix_api/src/imp/sys.rs b/api/ruxos_posix_api/src/imp/sys.rs similarity index 81% rename from api/arceos_posix_api/src/imp/sys.rs rename to api/ruxos_posix_api/src/imp/sys.rs index 220bcd149..850ef775e 100644 --- a/api/arceos_posix_api/src/imp/sys.rs +++ b/api/ruxos_posix_api/src/imp/sys.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -19,12 +19,12 @@ pub unsafe extern "C" fn sys_sysinfo(info: *mut ctypes::sysinfo) -> c_int { let info_mut = info.as_mut().unwrap(); // If the kernel booted less than 1 second, it will be 0. - info_mut.uptime = axhal::time::current_time().as_secs() as c_long; + info_mut.uptime = ruxhal::time::current_time().as_secs() as c_long; info_mut.loads = [0; 3]; - #[cfg(feature = "axtask")] + #[cfg(feature = "multitask")] { - axtask::get_avenrun(&mut info_mut.loads); + ruxtask::get_avenrun(&mut info_mut.loads); } info_mut.sharedram = 0; @@ -58,3 +58,9 @@ pub unsafe extern "C" fn sys_sysinfo(info: *mut ctypes::sysinfo) -> c_int { Ok(0) }) } + +/// Print system information +pub fn sys_uname(_uts: *mut core::ffi::c_void) -> c_int { + debug!("sys_uname not implemented"); + syscall_body!(sys_uname, Ok(0)) +} diff --git a/api/arceos_posix_api/src/imp/task.rs b/api/ruxos_posix_api/src/imp/task.rs similarity index 85% rename from api/arceos_posix_api/src/imp/task.rs rename to api/ruxos_posix_api/src/imp/task.rs index 5b503231a..4c295f86a 100644 --- a/api/arceos_posix_api/src/imp/task.rs +++ b/api/ruxos_posix_api/src/imp/task.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -15,10 +15,10 @@ use core::ffi::c_int; /// relax the CPU and wait for incoming interrupts. pub fn sys_sched_yield() -> c_int { #[cfg(feature = "multitask")] - axtask::yield_now(); + ruxtask::yield_now(); #[cfg(not(feature = "multitask"))] if cfg!(feature = "irq") { - axhal::arch::wait_for_irqs(); + ruxhal::arch::wait_for_irqs(); } else { core::hint::spin_loop(); } @@ -30,7 +30,7 @@ pub fn sys_getpid() -> c_int { syscall_body!(sys_getpid, #[cfg(feature = "multitask")] { - Ok(axtask::current().id().as_u64() as c_int) + Ok(ruxtask::current().id().as_u64() as c_int) } #[cfg(not(feature = "multitask"))] { @@ -43,7 +43,7 @@ pub fn sys_getpid() -> c_int { pub fn sys_exit(exit_code: c_int) -> ! { debug!("sys_exit <= {}", exit_code); #[cfg(feature = "multitask")] - axtask::exit(exit_code); + ruxtask::exit(exit_code); #[cfg(not(feature = "multitask"))] - axhal::misc::terminate(); + ruxhal::misc::terminate(); } diff --git a/api/arceos_posix_api/src/imp/time.rs b/api/ruxos_posix_api/src/imp/time.rs similarity index 61% rename from api/arceos_posix_api/src/imp/time.rs rename to api/ruxos_posix_api/src/imp/time.rs index d3b24b754..cde12cfaa 100644 --- a/api/arceos_posix_api/src/imp/time.rs +++ b/api/ruxos_posix_api/src/imp/time.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,14 +7,13 @@ * See the Mulan PSL v2 for more details. */ -use axerrno::LinuxError; -#[cfg(feature = "signal")] -use axruntime::Signal; use core::ffi::{c_int, c_long}; use core::time::Duration; use crate::ctypes; +use axerrno::LinuxError; + impl From for Duration { fn from(ts: ctypes::timespec) -> Self { Duration::new(ts.tv_sec as u64, ts.tv_nsec as u32) @@ -51,7 +50,7 @@ pub unsafe fn sys_clock_gettime(_clk: ctypes::clockid_t, ts: *mut ctypes::timesp if ts.is_null() { return Err(LinuxError::EFAULT); } - let now = axhal::time::current_time().into(); + let now = ruxhal::time::current_time().into(); unsafe { *ts = now }; debug!("sys_clock_gettime: {}.{:09}s", now.tv_sec, now.tv_nsec); Ok(0) @@ -70,7 +69,7 @@ pub unsafe fn sys_clock_settime(_clk: ctypes::clockid_t, ts: *mut ctypes::timesp new_tv.as_secs(), new_tv.as_nanos() ); - axhal::time::set_current_time(new_tv); + ruxhal::time::set_current_time(new_tv); Ok(0) }) } @@ -91,14 +90,14 @@ pub unsafe fn sys_nanosleep(req: *const ctypes::timespec, rem: *mut ctypes::time Duration::from(*req) }; - let now = axhal::time::current_time(); + let now = ruxhal::time::current_time(); #[cfg(feature = "multitask")] - axtask::sleep(dur); + ruxtask::sleep(dur); #[cfg(not(feature = "multitask"))] - axhal::time::busy_wait(dur); + ruxhal::time::busy_wait(dur); - let after = axhal::time::current_time(); + let after = ruxhal::time::current_time(); let actual = after - now; if let Some(diff) = dur.checked_sub(actual) { @@ -110,42 +109,3 @@ pub unsafe fn sys_nanosleep(req: *const ctypes::timespec, rem: *mut ctypes::time Ok(0) }) } - -#[cfg(feature = "signal")] -/// Set a timer to send a signal to the current process after a specified time -pub unsafe fn sys_setitimer(which: c_int, new: *const ctypes::itimerval) -> c_int { - syscall_body!(sys_setitimer, { - let which = which as usize; - let new_interval = Duration::from((*new).it_interval).as_nanos() as u64; - Signal::timer_interval(which, Some(new_interval)); - - let new_ddl = - axhal::time::current_time_nanos() + Duration::from((*new).it_value).as_nanos() as u64; - Signal::timer_deadline(which, Some(new_ddl)); - Ok(0) - }) -} - -#[cfg(feature = "signal")] -/// Get timer to send signal after some time -pub unsafe fn sys_getitimer(which: c_int, curr_value: *mut ctypes::itimerval) -> c_int { - syscall_body!(sys_getitimer, { - let ddl = Duration::from_nanos(Signal::timer_deadline(which as usize, None).unwrap()); - if ddl.as_nanos() == 0 { - return Err(LinuxError::EINVAL); - } - let mut now: ctypes::timespec = ctypes::timespec::default(); - unsafe { - sys_clock_gettime(0, &mut now); - } - let now = Duration::from(now); - if ddl > now { - (*curr_value).it_value = ctypes::timeval::from(ddl - now); - } else { - (*curr_value).it_value = ctypes::timeval::from(Duration::new(0, 0)); - } - (*curr_value).it_interval = - Duration::from_nanos(Signal::timer_interval(which as usize, None).unwrap()).into(); - Ok(0) - }) -} diff --git a/api/arceos_posix_api/src/lib.rs b/api/ruxos_posix_api/src/lib.rs similarity index 82% rename from api/arceos_posix_api/src/lib.rs rename to api/ruxos_posix_api/src/lib.rs index ca5e7501e..5fe2e0c0f 100644 --- a/api/arceos_posix_api/src/lib.rs +++ b/api/ruxos_posix_api/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,9 +7,9 @@ * See the Mulan PSL v2 for more details. */ -//! POSIX-compatible APIs for [ArceOS] modules +//! POSIX-compatible APIs for [Ruxos] modules //! -//! [ArceOS]: https://github.com/rcore-os/arceos +//! [Ruxos]: https://github.com/syswonder/ruxos #![cfg_attr(all(not(test), not(doc)), no_std)] #![feature(ip_in_core)] @@ -20,13 +20,13 @@ #[macro_use] extern crate axlog; -extern crate axruntime; +extern crate ruxruntime; #[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "alloc")] -pub use axruntime::{environ, environ_iter, RX_ENVIRON}; +pub use ruxruntime::{environ, environ_iter, RUX_ENVIRON}; #[macro_use] mod utils; @@ -35,8 +35,8 @@ mod imp; /// Platform-specific constants and parameters. pub mod config { - pub use axconfig::*; pub use memory_addr::PAGE_SIZE_4K; + pub use ruxconfig::*; } /// POSIX C types. @@ -45,11 +45,11 @@ pub mod config { #[allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals, clippy::upper_case_acronyms, missing_docs)] pub mod ctypes; -pub use imp::io::{sys_read, sys_write, sys_writev}; +pub use imp::io::{sys_read, sys_readv, sys_write, sys_writev}; pub use imp::resources::{sys_getrlimit, sys_prlimit64, sys_setrlimit}; pub use imp::rt_sig::{sys_rt_sigaction, sys_rt_sigprocmask}; -pub use imp::stat::sys_umask; -pub use imp::sys::sys_sysinfo; +pub use imp::stat::{sys_geteuid, sys_umask}; +pub use imp::sys::{sys_sysinfo, sys_uname}; pub use imp::sys_invalid; pub use imp::task::{sys_exit, sys_getpid, sys_sched_yield}; pub use imp::time::{sys_clock_gettime, sys_clock_settime, sys_nanosleep}; @@ -60,8 +60,9 @@ pub use imp::fd_ops::sys_dup3; pub use imp::fd_ops::{sys_close, sys_dup, sys_dup2, sys_fcntl}; #[cfg(feature = "fs")] pub use imp::fs::{ - sys_fstat, sys_fsync, sys_getcwd, sys_lseek, sys_lstat, sys_mkdir, sys_mkdirat, sys_newfstatat, - sys_open, sys_openat, sys_rename, sys_rmdir, sys_stat, sys_unlink, sys_unlinkat, + sys_fchownat, sys_fdatasync, sys_fstat, sys_fsync, sys_getcwd, sys_lseek, sys_lstat, sys_mkdir, + sys_mkdirat, sys_newfstatat, sys_open, sys_openat, sys_rename, sys_renameat, sys_rmdir, + sys_stat, sys_unlink, sys_unlinkat, }; #[cfg(feature = "epoll")] pub use imp::io_mpx::{sys_epoll_create, sys_epoll_ctl, sys_epoll_pwait, sys_epoll_wait}; @@ -97,9 +98,7 @@ pub use imp::pthread::{ sys_pthread_setspecific, }; #[cfg(feature = "signal")] -pub use imp::signal::sys_sigaction; -#[cfg(feature = "signal")] -pub use imp::time::{sys_getitimer, sys_setitimer}; +pub use imp::signal::{sys_getitimer, sys_setitimer, sys_sigaction}; #[cfg(feature = "multitask")] pub use imp::pthread::futex::sys_futex; diff --git a/api/arceos_posix_api/src/utils.rs b/api/ruxos_posix_api/src/utils.rs similarity index 97% rename from api/arceos_posix_api/src/utils.rs rename to api/ruxos_posix_api/src/utils.rs index 16384d531..9188afd6f 100644 --- a/api/arceos_posix_api/src/utils.rs +++ b/api/ruxos_posix_api/src/utils.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [RuxOS] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/envtest/main.c b/apps/c/envtest/main.c index 61cb8848e..2a48ac60e 100644 --- a/apps/c/envtest/main.c +++ b/apps/c/envtest/main.c @@ -1,6 +1,7 @@ #include #include #include + int main(int argc, char** argv) { puts("Running argv tests..."); if (argc != 3) { diff --git a/apps/c/helloworld/main.c b/apps/c/helloworld/main.c index 962a4324b..b64a16128 100644 --- a/apps/c/helloworld/main.c +++ b/apps/c/helloworld/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/httpclient/expect_info.out b/apps/c/httpclient/expect_info.out index 815bff980..2e78dfb73 100644 --- a/apps/c/httpclient/expect_info.out +++ b/apps/c/httpclient/expect_info.out @@ -23,7 +23,7 @@ created net interface "eth0": ip: 10.0.2.15/24 gateway: 10.0.2.2 Primary CPU 0 init OK. -Hello, ArceOS C HTTP client! +Hello, Ruxos C HTTP client! IP: [0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+ HTTP/1.1 200 OK Server: nginx diff --git a/apps/c/httpclient/httpclient.c b/apps/c/httpclient/httpclient.c index 9769d7d02..c6de5b9fb 100644 --- a/apps/c/httpclient/httpclient.c +++ b/apps/c/httpclient/httpclient.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -30,7 +30,7 @@ Accept: */*\r\n\ int main() { - puts("Hello, ArceOS C HTTP client!"); + puts("Hello, Ruxos C HTTP client!"); int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sock == -1) { perror("socket() error"); diff --git a/apps/c/httpserver/httpserver.c b/apps/c/httpserver/httpserver.c index 0ed8a6653..1e7de2b68 100644 --- a/apps/c/httpserver/httpserver.c +++ b/apps/c/httpserver/httpserver.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -25,15 +25,15 @@ Connection: close\r\n\ const char content[] = "\n\ \n\ - Hello, ArceOS\n\ + Hello, Ruxos\n\ \n\ \n\
\n\ -

Hello, ArceOS

\n\ +

Hello, Ruxos

\n\
\n\
\n\
\n\ - Powered by ArceOS example HTTP server v0.1.0\n\ + Powered by Ruxos example HTTP server v0.1.0\n\
\n\ \n\ \n\ @@ -41,7 +41,7 @@ const char content[] = "\n\ int main() { - puts("Hello, ArceOS C HTTP server!"); + puts("Hello, Ruxos C HTTP server!"); struct sockaddr_in local, remote; int addr_len = sizeof(remote); local.sin_family = AF_INET; diff --git a/apps/c/iperf/README.md b/apps/c/iperf/README.md index ca6f1469e..592a7942e 100644 --- a/apps/c/iperf/README.md +++ b/apps/c/iperf/README.md @@ -1,11 +1,11 @@ -# How to run iperf on ArceOS and benchmark network performance +# How to run iperf on Ruxos and benchmark network performance ## Build & run -Build and start the [`iperf3`](https://github.com/esnet/iperf) server on ArceOS: +Build and start the [`iperf3`](https://github.com/esnet/iperf) server on Ruxos: ```bash -# in arceos root directory +# in ruxos root directory make A=apps/c/iperf BLK=y NET=y ARCH= run ``` @@ -13,7 +13,7 @@ make A=apps/c/iperf BLK=y NET=y ARCH= run In another shell, run the `iperf3` client: -* iperf on ArceOS as the receiver: +* iperf on Ruxos as the receiver: ```bash # TCP @@ -24,7 +24,7 @@ In another shell, run the `iperf3` client: You need to set the `` (in bits/sec) to avoid sending packets too fast from the client when use UDP. -* iperf on ArceOS as the sender: +* iperf on Ruxos as the sender: ```bash # TCP @@ -38,7 +38,7 @@ By default, the `` is 128 KB for TCP and 8 KB for UDP. Larger buffer Note that if the `` is greater than `1472` (total packet length is exceeded the MTU of the NIC) when use UDP, packets fragmentation will occur. You should enable fragmentation features in [smoltcp](https://github.com/smoltcp-rs/smoltcp): ```toml -# in arceos/modules/axnet/Cargo.toml +# in ruxos/modules/axnet/Cargo.toml [dependencies.smoltcp] git = "https://github.com/smoltcp-rs/smoltcp.git" rev = "1f9b9f0" diff --git a/apps/c/iperf/iperf.patch b/apps/c/iperf/iperf.patch index 07994d1a7..252e231b9 100644 --- a/apps/c/iperf/iperf.patch +++ b/apps/c/iperf/iperf.patch @@ -341,7 +341,7 @@ index 73dc362..4bfe6f9 100644 { static int randomized = 0; - char hostname[500]; -+ char hostname[500] = "arceos-iperf"; ++ char hostname[500] = "ruxos-iperf"; struct timeval tv; char temp[1000]; @@ -411,7 +411,7 @@ index 73dc362..4bfe6f9 100644 - snprintf(buf, sizeof(buf), "%s %s %s %s %s", uts.sysname, uts.nodename, - uts.release, uts.version, uts.machine); -+ snprintf(buf, sizeof(buf), "%s %s %s %s %s", "arceos", "iperf", "0", "0","null"); ++ snprintf(buf, sizeof(buf), "%s %s %s %s %s", "ruxos", "iperf", "0", "0","null"); return buf; } diff --git a/apps/c/libc-bench/Readme.md b/apps/c/libc-bench/Readme.md index 76121f896..36120c62a 100644 --- a/apps/c/libc-bench/Readme.md +++ b/apps/c/libc-bench/Readme.md @@ -113,11 +113,11 @@ b_utf8_onebyone (0) time: 0.127939568 b_stdio_putcgetc (0) -[ 2.098431 0:2 arceos_posix_api::imp::ioctl:32] Only support fd = 1 +[ 2.098431 0:2 ruxos_posix_api::imp::ioctl:32] Only support fd = 1 time: 0.395968752 b_stdio_putcgetc_unlocked (0) -[ 2.493650 0:2 arceos_posix_api::imp::ioctl:32] Only support fd = 1 +[ 2.493650 0:2 ruxos_posix_api::imp::ioctl:32] Only support fd = 1 time: 0.245682432 b_regex_compile ("(a|b|c)*d*b") @@ -150,6 +150,6 @@ b_regex_search ("a{25}b") - Memory is expanded to 4G (two files are changed, `platforms/aarch64-qemu-virt.toml`, `scripts/make/qemu.mk`), so CI fails (mostly because RISC-V cannot support such a large memory space). -- It is recommended to know how musl-libc is integrated in `ulib/axmusl`. +- It is recommended to know how musl-libc is integrated in `ulib/ruxmusl`. -- Since `/etc/hosts` is not complemented, `getaddrinfo` uses previous implementation. See `ulib/axmusl/src/net.rs`. +- Since `/etc/hosts` is not complemented, `getaddrinfo` uses previous implementation. See `ulib/ruxmusl/src/net.rs`. diff --git a/apps/c/memtest/memtest.c b/apps/c/memtest/memtest.c index 1e8e38708..888163a24 100644 --- a/apps/c/memtest/memtest.c +++ b/apps/c/memtest/memtest.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/nginx/.gitignore b/apps/c/nginx/.gitignore new file mode 100755 index 000000000..a55620f53 --- /dev/null +++ b/apps/c/nginx/.gitignore @@ -0,0 +1,5 @@ +nginx-* +html +*.img +mnt +objs diff --git a/apps/c/nginx/README.md b/apps/c/nginx/README.md new file mode 100644 index 000000000..cd532236b --- /dev/null +++ b/apps/c/nginx/README.md @@ -0,0 +1,49 @@ +# How to run nginx on ruxos + +## commands + +### download web page + +You should make sure there is a html folder in apps/c/nginx which contains the web page of nginx server. + +If you not use your own web page , you can run commands below: + +```shell +git clone https://github.com/syswonder/syswonder-web.git +mkdir -p apps/c/nginx/html +cp -r syswonder-web/docs/* apps/c/nginx/html +rm -f -r syswonder-web +``` + +### run nginx + +The commands below is to run nginx with different features. These examples run in aarch64 with musl, if you want to run in x86_64, just replace `ARCH=aarch64` with `ARCH=x86_64`, and if you do not want to run with musl , just delete `MUSL=y`. + +use v9p and musl in aarch64: + +```shell +make A=apps/c/nginx/ LOG=info NET=y BLK=y V9P=y V9P_PATH=apps/c/nginx/html/ ARCH=aarch64 SMP=4 ARGS="./nginx_app" MUSL=y run +``` + +not use v9p,but use musl in aarch64: + +```shell +make A=apps/c/nginx/ LOG=info NET=y BLK=y ARCH=aarch64 SMP=4 ARGS="./nginx_app" MUSL=y run +``` + +If you change running option or source code , remember to clean the compile files and before running. + +```shell +make clean_c A=apps/c/nginx +``` + +# nginx conf + +You can change next files to change nginx conf: + +`/nginx/conf/nginx.conf` + +`/nginx/conf/mime.types` + +After change you should copy them to disk.img (you can run `apps/c/nginx/create_nginx_img.sh` to do that) + diff --git a/apps/c/nginx/axbuild.mk b/apps/c/nginx/axbuild.mk new file mode 100755 index 000000000..d52d70d1a --- /dev/null +++ b/apps/c/nginx/axbuild.mk @@ -0,0 +1,48 @@ +nginx-version = 1.24.0 +nginx-src := $(APP)/nginx-$(nginx-version) +nginx-objdir := $(APP)/objs +nginx-objs := objs/nginx_app.o + +app-objs := $(nginx-objs) + +CFLAGS += -Wno-format + +nginx-build-args := \ + CC=$(CC) \ + CFLAGS="$(CFLAGS)" \ + USE_JEMALLOC=no \ + -j + +ifneq ($(V),) + nginx-build-args += V=$(V) +endif + +ifeq ($(V9P),y) + DISK_ARG = 9p +else + DISK_ARG = no_9p +endif + + +disk.img: + echo "nginx makefile create_nginx_img" + ./$(APP)/create_nginx_img.sh $(DISK_ARG) + +$(nginx-objdir): + git clone https://github.com/lhw2002426/nginx-app.git -b nginx-objs $(APP)/objs + +$(nginx-src): + @echo "Download nginx source code" + wget https://nginx.org/download/nginx-$(nginx-version).tar.gz -P $(APP) + tar -zxvf $(APP)/nginx-$(nginx-version).tar.gz -C $(APP) && rm -f $(APP)/nginx-$(nginx-version).tar.gz + +$(APP)/$(nginx-objs): build_nginx + +clean_c:: + find . -type f \( -name "*.o" -o -name "*.elf" -o -name "*.bin" \) -exec rm -f {} + + +build_nginx: $(nginx-src) disk.img $(nginx-objdir) + cd $(nginx-objdir) && $(MAKE) $(nginx-build-args) + + +.PHONY: build_nginx diff --git a/apps/c/nginx/create_nginx_img.sh b/apps/c/nginx/create_nginx_img.sh new file mode 100755 index 000000000..84f725261 --- /dev/null +++ b/apps/c/nginx/create_nginx_img.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# From https://github.com/rafalh/rust-fatfs/blob/master/scripts/create-test-img.sh +CUR_DIR=$(dirname $0) + +echo $OUT_DIR + +if [ $# -lt 1 ]; then + CONF="$CUR_DIR/nginx.conf" + echo "not us 9p" +elif [ "$1" == "9p" ]; then + CONF="$CUR_DIR/nginx_9p.conf" + echo "use 9p" +else + CONF="$CUR_DIR/nginx.conf" + echo "not use 9p" +fi + +create_test_img() { + local name=$1 + local blkcount=$2 + local fatSize=$3 + dd if=/dev/zero of="$name" bs=1024 count=$blkcount + mkfs.vfat -s 1 -F $fatSize -n "Test!" -i 12345678 "$name" + mkdir -p mnt + sudo mount -o loop "$name" mnt -o rw,uid=$USER,gid=$USER + mkdir -p "mnt/nginx/logs" + mkdir -p "mnt/etc" + echo "" >> "mnt/etc/localtime" + echo "root:x:0:0:root:/root:/bin/bash" >> "mnt/etc/passwd" + echo "root:x:0:" >> "mnt/etc/group" + mkdir -p "mnt/nginx/conf" + cp "$CONF" "mnt/nginx/conf/nginx.conf" + cp "$CUR_DIR/mime.types" "mnt/nginx/conf/mime.types" + mkdir -p "mnt/html" + cp -r "$CUR_DIR/html" "mnt/" + sudo umount mnt +} + +create_test_img "$CUR_DIR/fat32.img" 40000 32 +echo $CUR_DIR +echo "nginx create disk" +rm -f disk.img +cp $CUR_DIR/fat32.img disk.img diff --git a/apps/c/nginx/features.txt b/apps/c/nginx/features.txt new file mode 100755 index 000000000..7ac64ecbf --- /dev/null +++ b/apps/c/nginx/features.txt @@ -0,0 +1,14 @@ +alloc +paging +fp_simd +irq +multitask +fs +blkfs +net +pipe +epoll +poll +select +virtio-9p +rtc diff --git a/apps/c/nginx/mime.types b/apps/c/nginx/mime.types new file mode 100755 index 000000000..dd757ddb4 --- /dev/null +++ b/apps/c/nginx/mime.types @@ -0,0 +1,98 @@ + +types { + text/markdown md; + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/svg+xml svg svgz; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/webp webp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + + font/woff woff; + font/woff2 woff2; + + application/java-archive jar war ear; + application/json json; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.apple.mpegurl m3u8; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/vnd.ms-excel xls; + application/vnd.ms-fontobject eot; + application/vnd.ms-powerpoint ppt; + application/vnd.oasis.opendocument.graphics odg; + application/vnd.oasis.opendocument.presentation odp; + application/vnd.oasis.opendocument.spreadsheet ods; + application/vnd.oasis.opendocument.text odt; + application/vnd.openxmlformats-officedocument.presentationml.presentation + pptx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet + xlsx; + application/vnd.openxmlformats-officedocument.wordprocessingml.document + docx; + application/vnd.wap.wmlc wmlc; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xspf+xml xspf; + application/zip zip; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream iso img; + application/octet-stream msi msp msm; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp2t ts; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/apps/c/nginx/nginx.conf b/apps/c/nginx/nginx.conf new file mode 100755 index 000000000..95dbabebb --- /dev/null +++ b/apps/c/nginx/nginx.conf @@ -0,0 +1,40 @@ +worker_processes 1; +daemon off; +master_process off; + +error_log logs/error.log debug; + +events { + worker_connections 32; +} + +http { + include mime.types; + default_type application/octet-stream; + + keepalive_timeout 65; + + server { + listen 5555; + server_name localhost; + + index index.html; + + root /html; + + location / { + try_files $uri $uri/ /404.html; + } + + error_page 404 /404.html; + location = /404.html { + root /html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /html; + } + + } +} diff --git a/apps/c/nginx/nginx_9p.conf b/apps/c/nginx/nginx_9p.conf new file mode 100755 index 000000000..41217be52 --- /dev/null +++ b/apps/c/nginx/nginx_9p.conf @@ -0,0 +1,40 @@ +worker_processes 1; +daemon off; +master_process off; + +error_log logs/error.log debug; + +events { + worker_connections 32; +} + +http { + include mime.types; + default_type application/octet-stream; + + keepalive_timeout 65; + + server { + listen 5555; + server_name localhost; + + index index.html; + + root /v9fs; + + location / { + try_files $uri $uri/ /404.html; + } + + error_page 404 /404.html; + location = /404.html { + root /v9fs; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /v9fs; + } + + } +} diff --git a/apps/c/pthread/basic/main.c b/apps/c/pthread/basic/main.c index 137ebe7b3..7ee1e6f69 100644 --- a/apps/c/pthread/basic/main.c +++ b/apps/c/pthread/basic/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/pthread/parallel/main.c b/apps/c/pthread/parallel/main.c index 4a1a320c7..83b6f5825 100644 --- a/apps/c/pthread/parallel/main.c +++ b/apps/c/pthread/parallel/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/pthread/pipe/main.c b/apps/c/pthread/pipe/main.c index 0bed653a1..7c2509923 100644 --- a/apps/c/pthread/pipe/main.c +++ b/apps/c/pthread/pipe/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/pthread/sleep/main.c b/apps/c/pthread/sleep/main.c index 4466fe049..b1ddf8e5a 100644 --- a/apps/c/pthread/sleep/main.c +++ b/apps/c/pthread/sleep/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/pthread/tsd/main.c b/apps/c/pthread/tsd/main.c index c19039ced..88c1e1744 100644 --- a/apps/c/pthread/tsd/main.c +++ b/apps/c/pthread/tsd/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/redis/README.md b/apps/c/redis/README.md index f3f8c713c..683a12ebf 100644 --- a/apps/c/redis/README.md +++ b/apps/c/redis/README.md @@ -26,7 +26,7 @@ # How to test? -- Use `redis-cli -p 5555` to connect to redis-server, and enjoy ArceOS-Redis world! +- Use `redis-cli -p 5555` to connect to redis-server, and enjoy Ruxos-Redis world! - Use `redis-benchmark -p 5555` and other optional parameters to run the benchmark. - Like: `redis-benchmark -p 5555 -n 5 -q -c 10`, this command issues 5 requests for each commands (like `set`, `get`, etc.), with 10 concurrency. - `LRANGE_xxx` test may fail because of running out of memory(Follow notes 4, 5). @@ -281,7 +281,7 @@ MSET (10 keys): 183150.19 requests per second ``` ### X86_64 -# Run ArceOS-Redis On PC +# Run Ruxos-Redis On PC ## Notification @@ -292,8 +292,8 @@ MSET (10 keys): 183150.19 requests per second - `make A=apps/c/redis LOG=error PLATFORM=x86_64-pc-oslab SMP=4 FEATURES=driver-ixgbe,driver-ramdisk IP=10.2.2.2 GW=10.2.2.1` - Copy `redis_x86_64-pc-oslab.elf` to `/boot`, then reboot. -- Enter `grub` then boot the PC by ArceOS Redis. -- Connect to ArceOS-Redis server by: +- Enter `grub` then boot the PC by Ruxos Redis. +- Connect to Ruxos-Redis server by: - `redis-cli -p 5555 -h 10.2.2.2` - `redis-benchmark -p 5555 -h 10.2.2.2` diff --git a/apps/c/sqlite3/Makefile b/apps/c/sqlite3/Makefile index 1404e3de8..19fcd6eff 100644 --- a/apps/c/sqlite3/Makefile +++ b/apps/c/sqlite3/Makefile @@ -1,13 +1,14 @@ -AX_ROOT := /home/oslab/OS/arceos +# This path is out of date +RUX_ROOT := /home/oslab/OS/ruxos all: - $(MAKE) -C $(AX_ROOT) A=$(PWD) + $(MAKE) -C $(RUX_ROOT) A=$(PWD) run: - $(MAKE) -C $(AX_ROOT) A=$(PWD) run + $(MAKE) -C $(RUX_ROOT) A=$(PWD) run clean: rm -rf *.o - $(MAKE) -C $(AX_ROOT) A=$(PWD) clean + $(MAKE) -C $(RUX_ROOT) A=$(PWD) clean .PHONY: all run clean diff --git a/apps/c/sqlite3/main.c b/apps/c/sqlite3/main.c index 7bce887c4..ffb33c8cd 100644 --- a/apps/c/sqlite3/main.c +++ b/apps/c/sqlite3/main.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/c/udpserver/udpserver.c b/apps/c/udpserver/udpserver.c index 40bc6a8aa..959a9cbc0 100644 --- a/apps/c/udpserver/udpserver.c +++ b/apps/c/udpserver/udpserver.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -17,7 +17,7 @@ const char res_suffix[11] = "_response\n"; int main() { - puts("Hello, ArceOS C UDP server!"); + puts("Hello, Ruxos C UDP server!"); struct sockaddr_in local, remote; int addr_len = sizeof(remote); local.sin_family = AF_INET; diff --git a/apps/display/basic_painting/Cargo.toml b/apps/display/basic_painting/Cargo.toml index b5a355dac..cabd7c188 100644 --- a/apps/display/basic_painting/Cargo.toml +++ b/apps/display/basic_painting/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "arceos-display-basic-painting" +name = "ruxos-display-basic-painting" version = "0.1.0" edition = "2021" authors = ["Shiping Yuan "] diff --git a/apps/display/basic_painting/src/display.rs b/apps/display/basic_painting/src/display.rs index d49f38dd6..135ad9a6b 100644 --- a/apps/display/basic_painting/src/display.rs +++ b/apps/display/basic_painting/src/display.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/display/basic_painting/src/main.rs b/apps/display/basic_painting/src/main.rs index 8c6563ae3..84c6199b7 100644 --- a/apps/display/basic_painting/src/main.rs +++ b/apps/display/basic_painting/src/main.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -64,7 +64,7 @@ impl DrawingBoard { .into_styled(PrimitiveStyle::with_stroke(Rgb888::GREEN, 10)) .draw(&mut self.disp) .ok(); - let text = "ArceOS"; + let text = "Ruxos"; Text::with_alignment( text, self.latest_pos + Point::new(0, 300), diff --git a/apps/display/draw_map/Cargo.toml b/apps/display/draw_map/Cargo.toml index abc0b4331..b4b5bc822 100644 --- a/apps/display/draw_map/Cargo.toml +++ b/apps/display/draw_map/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "arceos-display-draw-map" +name = "ruxos-display-draw-map" version = "0.1.0" edition = "2021" authors = ["Shiping Yuan "] diff --git a/apps/exception/Cargo.toml b/apps/exception/Cargo.toml deleted file mode 100644 index 1be50f0d1..000000000 --- a/apps/exception/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "arceos-exception" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../ulib/axstd", optional = true } diff --git a/apps/exception/expect_debug_aarch64.out b/apps/exception/expect_debug_aarch64.out deleted file mode 100644 index 4652c0c04..000000000 --- a/apps/exception/expect_debug_aarch64.out +++ /dev/null @@ -1,19 +0,0 @@ -smp = 1 -build_mode = release -log_level = debug - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize platform devices... -Primary CPU 0 init OK. -Running exception tests... -BRK #0x0 @ 0x[0-9a-f]\{16\} -Exception tests run OK! -Shutting down... diff --git a/apps/exception/expect_debug_riscv64.out b/apps/exception/expect_debug_riscv64.out deleted file mode 100644 index ea1508c5d..000000000 --- a/apps/exception/expect_debug_riscv64.out +++ /dev/null @@ -1,19 +0,0 @@ -smp = 1 -build_mode = release -log_level = debug - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize platform devices... -Primary CPU 0 init OK. -Running exception tests... -Exception(Breakpoint) @ 0x[0-9a-f]\{16\} -Exception tests run OK! -Shutting down... diff --git a/apps/exception/expect_debug_x86_64.out b/apps/exception/expect_debug_x86_64.out deleted file mode 100644 index 0cdbde466..000000000 --- a/apps/exception/expect_debug_x86_64.out +++ /dev/null @@ -1,19 +0,0 @@ -smp = 1 -build_mode = release -log_level = debug - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize platform devices... -Primary CPU 0 init OK. -Running exception tests... -#BP @ 0x[0-9a-f]\{16\} -Exception tests run OK! -Shutting down... diff --git a/apps/exception/src/main.rs b/apps/exception/src/main.rs deleted file mode 100644 index e643044d1..000000000 --- a/apps/exception/src/main.rs +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::arch::asm; -use std::println; - -fn raise_break_exception() { - unsafe { - #[cfg(target_arch = "x86_64")] - asm!("int3"); - #[cfg(target_arch = "aarch64")] - asm!("brk #0"); - #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] - asm!("ebreak"); - } -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Running exception tests..."); - raise_break_exception(); - println!("Exception tests run OK!"); -} diff --git a/apps/exception/test_cmd b/apps/exception/test_cmd deleted file mode 100644 index 746e8ac8a..000000000 --- a/apps/exception/test_cmd +++ /dev/null @@ -1 +0,0 @@ -test_one "LOG=debug" "expect_debug_${ARCH}.out" diff --git a/apps/fs/shell/src/cmd.rs b/apps/fs/shell/src/cmd.rs index afef993e6..c240231dd 100644 --- a/apps/fs/shell/src/cmd.rs +++ b/apps/fs/shell/src/cmd.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -253,15 +253,15 @@ fn do_pwd(_args: &str) { } fn do_uname(_args: &str) { - let arch = option_env!("AX_ARCH").unwrap_or(""); - let platform = option_env!("AX_PLATFORM").unwrap_or(""); - let smp = match option_env!("AX_SMP") { + let arch = option_env!("RUX_ARCH").unwrap_or(""); + let platform = option_env!("RUX_PLATFORM").unwrap_or(""); + let smp = match option_env!("RUX_SMP") { None | Some("1") => "", _ => " SMP", }; let version = option_env!("CARGO_PKG_VERSION").unwrap_or("0.1.0"); println!( - "ArceOS {ver}{smp} {arch} {plat}", + "Ruxos {ver}{smp} {arch} {plat}", ver = version, smp = smp, arch = arch, diff --git a/apps/fs/shell/src/main.rs b/apps/fs/shell/src/main.rs index a03a0aa01..f28e85b5a 100644 --- a/apps/fs/shell/src/main.rs +++ b/apps/fs/shell/src/main.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -43,10 +43,7 @@ const SPACE: u8 = b' '; const MAX_CMD_LEN: usize = 256; fn print_prompt() { - print!( - "arceos:{}$ ", - path_to_str!(std::env::current_dir().unwrap()) - ); + print!("ruxos:{}$ ", path_to_str!(std::env::current_dir().unwrap())); std::io::stdout().flush().unwrap(); } diff --git a/apps/fs/shell/src/ramfs.rs b/apps/fs/shell/src/ramfs.rs index 3f0f83bb0..1a44eb872 100644 --- a/apps/fs/shell/src/ramfs.rs +++ b/apps/fs/shell/src/ramfs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/apps/helloworld/Cargo.toml b/apps/helloworld/Cargo.toml deleted file mode 100644 index 9b759ec55..000000000 --- a/apps/helloworld/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "arceos-helloworld" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../ulib/axstd", optional = true } diff --git a/apps/helloworld/expect_info.out b/apps/helloworld/expect_info.out deleted file mode 100644 index 870e9049c..000000000 --- a/apps/helloworld/expect_info.out +++ /dev/null @@ -1,17 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize platform devices... -Primary CPU 0 init OK. -Hello, world! -Shutting down... diff --git a/apps/helloworld/expect_info_smp4.out b/apps/helloworld/expect_info_smp4.out deleted file mode 100644 index 2fc566f33..000000000 --- a/apps/helloworld/expect_info_smp4.out +++ /dev/null @@ -1,23 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize platform devices... -CPU 0 init OK -CPU 1 started -CPU 2 started -CPU 3 started -CPU 1 init OK -CPU 2 init OK -CPU 3 init OK -Hello, world! -Shutting down... diff --git a/apps/helloworld/src/main.rs b/apps/helloworld/src/main.rs deleted file mode 100644 index 063695e16..000000000 --- a/apps/helloworld/src/main.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[cfg(feature = "axstd")] -use axstd::println; - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Hello, world!"); -} diff --git a/apps/helloworld/test_cmd b/apps/helloworld/test_cmd deleted file mode 100644 index 0fdc836a0..000000000 --- a/apps/helloworld/test_cmd +++ /dev/null @@ -1,2 +0,0 @@ -test_one "LOG=info" "expect_info.out" -test_one "SMP=4 LOG=info" "expect_info_smp4.out" diff --git a/apps/memtest/Cargo.toml b/apps/memtest/Cargo.toml deleted file mode 100644 index 592b6c4f1..000000000 --- a/apps/memtest/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "arceos-memtest" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -rand = { version = "0.8", default-features = false, features = ["small_rng"] } -axstd = { path = "../../ulib/axstd", features = ["alloc"], optional = true } diff --git a/apps/memtest/expect_trace.out b/apps/memtest/expect_trace.out deleted file mode 100644 index f77894b7b..000000000 --- a/apps/memtest/expect_trace.out +++ /dev/null @@ -1,34 +0,0 @@ -smp = 1 -build_mode = release -log_level = trace - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... - use TLSF allocator. -initialize global allocator at: \[0x[0-9a-f]\+, 0x[0-9a-f]\+) -Initialize kernel page table... -Initialize platform devices... -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | EXECUTE) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | WRITE) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | WRITE) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | WRITE) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | WRITE) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | WRITE | DEVICE) -map_region(PA:0x[0-9a-f]\+): \[VA:0x[0-9a-f]\+, VA:0x[0-9a-f]\+) -> \[PA:0x[0-9a-f]\+, PA:0x[0-9a-f]\+) MappingFlags(READ | WRITE) -set page table root: PA:0x[0-9a-f]\+ => PA:0x[0-9a-f]\+ -Primary CPU 0 init OK. -Running memory tests... -expand heap memory: -test_vec() OK! -test_btree_map() OK! -Memory tests run OK! -Shutting down... diff --git a/apps/memtest/src/main.rs b/apps/memtest/src/main.rs deleted file mode 100644 index 09bb65a1f..000000000 --- a/apps/memtest/src/main.rs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use rand::{rngs::SmallRng, RngCore, SeedableRng}; -use std::collections::BTreeMap; -use std::vec::Vec; - -fn test_vec(rng: &mut impl RngCore) { - const N: usize = 3_000_000; - let mut v = Vec::with_capacity(N); - for _ in 0..N { - v.push(rng.next_u32()); - } - v.sort(); - for i in 0..N - 1 { - assert!(v[i] <= v[i + 1]); - } - println!("test_vec() OK!"); -} - -fn test_btree_map(rng: &mut impl RngCore) { - const N: usize = 50_000; - let mut m = BTreeMap::new(); - for _ in 0..N { - let value = rng.next_u32(); - let key = format!("key_{value}"); - m.insert(key, value); - } - for (k, v) in m.iter() { - if let Some(k) = k.strip_prefix("key_") { - assert_eq!(k.parse::().unwrap(), *v); - } - } - println!("test_btree_map() OK!"); -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Running memory tests..."); - - let mut rng = SmallRng::seed_from_u64(0xdead_beef); - test_vec(&mut rng); - test_btree_map(&mut rng); - - println!("Memory tests run OK!"); -} diff --git a/apps/memtest/test_cmd b/apps/memtest/test_cmd deleted file mode 100644 index c4a60e5ff..000000000 --- a/apps/memtest/test_cmd +++ /dev/null @@ -1 +0,0 @@ -test_one "LOG=trace FEATURES=paging" "expect_trace.out" diff --git a/apps/net/bwbench/Cargo.toml b/apps/net/bwbench/Cargo.toml deleted file mode 100644 index 4cc245487..000000000 --- a/apps/net/bwbench/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "arceos-bwbench" -version = "0.1.0" -edition = "2021" -authors = ["ChengXiang Qi "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["net"] } -axnet = { path = "../../../modules/axnet" } diff --git a/apps/net/bwbench/src/main.rs b/apps/net/bwbench/src/main.rs deleted file mode 100644 index 6da76cbd8..000000000 --- a/apps/net/bwbench/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![no_std] -#![no_main] - -extern crate axstd; - -#[no_mangle] -fn main() { - axstd::println!("Benchmarking bandwidth..."); - axnet::bench_transmit(); - // axnet::bench_receive(); -} diff --git a/apps/net/echoserver/Cargo.toml b/apps/net/echoserver/Cargo.toml deleted file mode 100644 index 7698bf0c1..000000000 --- a/apps/net/echoserver/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "arceos-echoserver" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["alloc", "multitask", "net"], optional = true } diff --git a/apps/net/echoserver/src/main.rs b/apps/net/echoserver/src/main.rs deleted file mode 100644 index 3162e5d00..000000000 --- a/apps/net/echoserver/src/main.rs +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::io::{self, prelude::*}; -use std::net::{TcpListener, TcpStream}; -use std::thread; -use std::vec::Vec; - -const LOCAL_IP: &str = "0.0.0.0"; -const LOCAL_PORT: u16 = 5555; - -fn reverse(buf: &[u8]) -> Vec { - let mut lines = buf - .split(|&b| b == b'\n') - .map(Vec::from) - .collect::>(); - for line in lines.iter_mut() { - line.reverse(); - } - lines.join(&b'\n') -} - -fn echo_server(mut stream: TcpStream) -> io::Result<()> { - let mut buf = [0u8; 1024]; - loop { - let n = stream.read(&mut buf)?; - if n == 0 { - return Ok(()); - } - stream.write_all(reverse(&buf[..n]).as_slice())?; - } -} - -fn accept_loop() -> io::Result<()> { - let listener = TcpListener::bind((LOCAL_IP, LOCAL_PORT))?; - println!("listen on: {}", listener.local_addr().unwrap()); - - let mut i = 0; - loop { - match listener.accept() { - Ok((stream, addr)) => { - println!("new client {}: {}", i, addr); - thread::spawn(move || match echo_server(stream) { - Err(e) => println!("client connection error: {:?}", e), - Ok(()) => println!("client {} closed successfully", i), - }); - } - Err(e) => return Err(e), - } - i += 1; - } -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Hello, echo server!"); - accept_loop().expect("test echo server failed"); -} diff --git a/apps/net/httpclient/Cargo.toml b/apps/net/httpclient/Cargo.toml deleted file mode 100644 index 8efffa032..000000000 --- a/apps/net/httpclient/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "arceos-httpclient" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia ", "Dashuai Wu "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["net"], optional = true } - -[features] -default = [] -dns = ["axstd?/dns"] diff --git a/apps/net/httpclient/expect_info.out b/apps/net/httpclient/expect_info.out deleted file mode 100644 index 01e05eedf..000000000 --- a/apps/net/httpclient/expect_info.out +++ /dev/null @@ -1,38 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize kernel page table... -Initialize platform devices... -Initialize device drivers... -registered a new Net device at .\+: "virtio-net" -Initialize network subsystem... - use NIC 0: "virtio-net" -created net interface "eth0": - ether: 52-54-00-12-34-56 - ip: 10.0.2.15/24 - gateway: 10.0.2.2 -Primary CPU 0 init OK. -Hello, simple http client! -dest: [0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+:80 ([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+:80) -HTTP/1.1 200 OK -Server: nginx -Date: -Content-Type: text/plain -Content-Length: -Connection: keep-alive -Access-Control-Allow-Origin: * -Cache-Control: no-cache, no-store, must-revalidate - -^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+ -Shutting down... diff --git a/apps/net/httpclient/expect_info_dns.out b/apps/net/httpclient/expect_info_dns.out deleted file mode 100644 index e848229c7..000000000 --- a/apps/net/httpclient/expect_info_dns.out +++ /dev/null @@ -1,38 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize kernel page table... -Initialize platform devices... -Initialize device drivers... -registered a new Net device at .\+: "virtio-net" -Initialize network subsystem... - use NIC 0: "virtio-net" -created net interface "eth0": - ether: 52-54-00-12-34-56 - ip: 10.0.2.15/24 - gateway: 10.0.2.2 -Primary CPU 0 init OK. -Hello, simple http client! -dest: ident.me:80 ([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+:80) -HTTP/1.1 200 OK -Server: nginx -Date: -Content-Type: text/plain -Content-Length: -Connection: keep-alive -Access-Control-Allow-Origin: * -Cache-Control: no-cache, no-store, must-revalidate - -^[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+ -Shutting down... diff --git a/apps/net/httpclient/src/main.rs b/apps/net/httpclient/src/main.rs deleted file mode 100644 index c7877beef..000000000 --- a/apps/net/httpclient/src/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::io::{self, prelude::*}; -use std::net::{TcpStream, ToSocketAddrs}; - -#[cfg(feature = "dns")] -const DEST: &str = "ident.me:80"; -#[cfg(not(feature = "dns"))] -const DEST: &str = "49.12.234.183:80"; - -const REQUEST: &str = "\ -GET / HTTP/1.1\r\n\ -Host: ident.me\r\n\ -Accept: */*\r\n\ -\r\n"; - -fn client() -> io::Result<()> { - for addr in DEST.to_socket_addrs()? { - println!("dest: {} ({})", DEST, addr); - } - - let mut stream = TcpStream::connect(DEST)?; - stream.write_all(REQUEST.as_bytes())?; - let mut buf = [0; 2048]; - let n = stream.read(&mut buf)?; - let response = core::str::from_utf8(&buf[..n]).unwrap(); - println!("{}", response); // longer response need to handle tcp package problems. - Ok(()) -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Hello, simple http client!"); - client().expect("test http client failed"); -} diff --git a/apps/net/httpclient/test_cmd b/apps/net/httpclient/test_cmd deleted file mode 100644 index f56d6d43d..000000000 --- a/apps/net/httpclient/test_cmd +++ /dev/null @@ -1,2 +0,0 @@ -test_one "LOG=info NET=y" "expect_info.out" -test_one "LOG=info NET=y APP_FEATURES=dns" "expect_info_dns.out" diff --git a/apps/net/httpserver/Cargo.toml b/apps/net/httpserver/Cargo.toml deleted file mode 100644 index ba59e9820..000000000 --- a/apps/net/httpserver/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "arceos-httpserver" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["alloc", "multitask", "net"], optional = true } diff --git a/apps/net/httpserver/src/main.rs b/apps/net/httpserver/src/main.rs deleted file mode 100644 index 4b1739abe..000000000 --- a/apps/net/httpserver/src/main.rs +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -//! Simple HTTP server. -//! -//! Benchmark with [Apache HTTP server benchmarking tool](https://httpd.apache.org/docs/2.4/programs/ab.html): -//! -//! ``` -//! ab -n 5000 -c 20 http://X.X.X.X:5555/ -//! ``` - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::io::{self, prelude::*}; -use std::net::{TcpListener, TcpStream}; -use std::thread; - -const LOCAL_IP: &str = "0.0.0.0"; -const LOCAL_PORT: u16 = 5555; - -macro_rules! header { - () => { - "\ -HTTP/1.1 200 OK\r\n\ -Content-Type: text/html\r\n\ -Content-Length: {}\r\n\ -Connection: close\r\n\ -\r\n\ -{}" - }; -} - -const CONTENT: &str = r#" - - Hello, ArceOS - - -
-

Hello, ArceOS

-
-
-
- Powered by ArceOS example HTTP server v0.1.0 -
- - -"#; - -macro_rules! info { - ($($arg:tt)*) => { - match option_env!("LOG") { - Some("info") | Some("debug") | Some("trace") => { - print!("[INFO] {}\n", format_args!($($arg)*)); - } - _ => {} - } - }; -} - -fn http_server(mut stream: TcpStream) -> io::Result<()> { - let mut buf = [0u8; 4096]; - let _len = stream.read(&mut buf)?; - - let response = format!(header!(), CONTENT.len(), CONTENT); - stream.write_all(response.as_bytes())?; - - Ok(()) -} - -fn accept_loop() -> io::Result<()> { - let listener = TcpListener::bind((LOCAL_IP, LOCAL_PORT))?; - println!("listen on: http://{}/", listener.local_addr().unwrap()); - - let mut i = 0; - loop { - match listener.accept() { - Ok((stream, addr)) => { - info!("new client {}: {}", i, addr); - thread::spawn(move || match http_server(stream) { - Err(e) => info!("client connection error: {:?}", e), - Ok(()) => info!("client {} closed successfully", i), - }); - } - Err(e) => return Err(e), - } - i += 1; - } -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Hello, ArceOS HTTP server!"); - accept_loop().expect("test HTTP server failed"); -} diff --git a/apps/net/udpserver/Cargo.toml b/apps/net/udpserver/Cargo.toml deleted file mode 100644 index 0c6b86a4a..000000000 --- a/apps/net/udpserver/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "arceos-udpserver" -version = "0.1.0" -edition = "2021" -authors = ["Dashuai Wu "] - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["net"], optional = true } diff --git a/apps/net/udpserver/src/main.rs b/apps/net/udpserver/src/main.rs deleted file mode 100644 index 6b1751680..000000000 --- a/apps/net/udpserver/src/main.rs +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::io; -use std::net::{ToSocketAddrs, UdpSocket}; - -const LOCAL_IP: &str = "0.0.0.0"; -const LOCAL_PORT: u16 = 5555; - -fn receive_loop() -> io::Result<()> { - let addr = (LOCAL_IP, LOCAL_PORT).to_socket_addrs()?.next().unwrap(); - let socket = UdpSocket::bind(addr)?; - println!("listen on: {}", socket.local_addr().unwrap()); - let mut buf = [0u8; 1024]; - loop { - match socket.recv_from(&mut buf) { - Ok((size, addr)) => { - println!("recv: {}Bytes from {}", size, addr); - let mid = core::str::from_utf8(&buf).unwrap(); - println!("{}", mid); - let mid = ["response_", mid].join(""); - socket.send_to(mid.as_bytes(), addr)?; - buf = [0u8; 1024]; - } - Err(e) => return Err(e), - }; - } -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Hello, simple udp client!"); - receive_loop().expect("test udp client failed"); -} diff --git a/apps/task/parallel/Cargo.toml b/apps/task/parallel/Cargo.toml deleted file mode 100644 index ea9340992..000000000 --- a/apps/task/parallel/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "arceos-parallel" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -rand = { version = "0.8", default-features = false, features = ["small_rng"] } -axstd = { path = "../../../ulib/axstd", features = ["alloc", "multitask", "irq"], optional = true } diff --git a/apps/task/parallel/expect_info_smp1_fifo.out b/apps/task/parallel/expect_info_smp1_fifo.out deleted file mode 100644 index 7c38a8829..000000000 --- a/apps/task/parallel/expect_info_smp1_fifo.out +++ /dev/null @@ -1,38 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use FIFO scheduler. -Initialize interrupt handlers... -Primary CPU 0 init OK. -part 0: ThreadId(4) \[0, 125000) -part 1: ThreadId(5) \[125000, 250000) -part 2: ThreadId(6) \[250000, 375000) -part 3: ThreadId(7) \[375000, 500000) -part 4: ThreadId(8) \[500000, 625000) -part 5: ThreadId(9) \[625000, 750000) -part 6: ThreadId(10) \[750000, 875000) -part 7: ThreadId(11) \[875000, 1000000) -part 8: ThreadId(12) \[1000000, 1125000) -part 9: ThreadId(13) \[1125000, 1250000) -part 10: ThreadId(14) \[1250000, 1375000) -part 11: ThreadId(15) \[1375000, 1500000) -part 12: ThreadId(16) \[1500000, 1625000) -part 13: ThreadId(17) \[1625000, 1750000) -part 14: ThreadId(18) \[1750000, 1875000) -part 15: ThreadId(19) \[1875000, 2000000) -part 15: ThreadId(19) finished -Parallel summation tests run OK! -Shutting down... diff --git a/apps/task/parallel/expect_info_smp4_cfs.out b/apps/task/parallel/expect_info_smp4_cfs.out deleted file mode 100644 index f062d0790..000000000 --- a/apps/task/parallel/expect_info_smp4_cfs.out +++ /dev/null @@ -1,59 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: -.text (READ | EXECUTE | RESERVED) -.rodata (READ | RESERVED) -.data .tdata .tbss .percpu (READ | WRITE | RESERVED) -.percpu (READ | WRITE | RESERVED) -boot stack (READ | WRITE | RESERVED) -.bss (READ | WRITE | RESERVED) -free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use Completely Fair scheduler. -Initialize interrupt handlers... -CPU 0 init OK -CPU 1 started -CPU 2 started -CPU 3 started -CPU 1 init OK -CPU 2 init OK -CPU 3 init OK -part 0: ThreadId([0-9]\+) \[0, 125000) -part 1: ThreadId([0-9]\+) \[125000, 250000) -part 2: ThreadId([0-9]\+) \[250000, 375000) -part 3: ThreadId([0-9]\+) \[375000, 500000) -part 4: ThreadId([0-9]\+) \[500000, 625000) -part 5: ThreadId([0-9]\+) \[625000, 750000) -part 6: ThreadId([0-9]\+) \[750000, 875000) -part 7: ThreadId([0-9]\+) \[875000, 1000000) -part 8: ThreadId([0-9]\+) \[1000000, 1125000) -part 9: ThreadId([0-9]\+) \[1125000, 1250000) -part 10: ThreadId([0-9]\+) \[1250000, 1375000) -part 11: ThreadId([0-9]\+) \[1375000, 1500000) -part 12: ThreadId([0-9]\+) \[1500000, 1625000) -part 13: ThreadId([0-9]\+) \[1625000, 1750000) -part 14: ThreadId([0-9]\+) \[1750000, 1875000) -part 15: ThreadId([0-9]\+) \[1875000, 2000000) -part 15: ThreadId([0-9]\+) finished -part 0: ThreadId([0-9]\+) finished -part 1: ThreadId([0-9]\+) finished -part 2: ThreadId([0-9]\+) finished -part 3: ThreadId([0-9]\+) finished -part 4: ThreadId([0-9]\+) finished -part 5: ThreadId([0-9]\+) finished -part 6: ThreadId([0-9]\+) finished -part 7: ThreadId([0-9]\+) finished -part 8: ThreadId([0-9]\+) finished -part 9: ThreadId([0-9]\+) finished -part 10: ThreadId([0-9]\+) finished -part 11: ThreadId([0-9]\+) finished -part 12: ThreadId([0-9]\+) finished -part 13: ThreadId([0-9]\+) finished -part 14: ThreadId([0-9]\+) finished -Parallel summation tests run OK! -Shutting down... diff --git a/apps/task/parallel/expect_info_smp4_rr.out b/apps/task/parallel/expect_info_smp4_rr.out deleted file mode 100644 index bc8350554..000000000 --- a/apps/task/parallel/expect_info_smp4_rr.out +++ /dev/null @@ -1,59 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use Round-robin scheduler. -Initialize interrupt handlers... -CPU 0 init OK -CPU 1 started -CPU 2 started -CPU 3 started -CPU 1 init OK -CPU 2 init OK -CPU 3 init OK -part 0: ThreadId([0-9]\+) \[0, 125000) -part 1: ThreadId([0-9]\+) \[125000, 250000) -part 2: ThreadId([0-9]\+) \[250000, 375000) -part 3: ThreadId([0-9]\+) \[375000, 500000) -part 4: ThreadId([0-9]\+) \[500000, 625000) -part 5: ThreadId([0-9]\+) \[625000, 750000) -part 6: ThreadId([0-9]\+) \[750000, 875000) -part 7: ThreadId([0-9]\+) \[875000, 1000000) -part 8: ThreadId([0-9]\+) \[1000000, 1125000) -part 9: ThreadId([0-9]\+) \[1125000, 1250000) -part 10: ThreadId([0-9]\+) \[1250000, 1375000) -part 11: ThreadId([0-9]\+) \[1375000, 1500000) -part 12: ThreadId([0-9]\+) \[1500000, 1625000) -part 13: ThreadId([0-9]\+) \[1625000, 1750000) -part 14: ThreadId([0-9]\+) \[1750000, 1875000) -part 15: ThreadId([0-9]\+) \[1875000, 2000000) -part 15: ThreadId([0-9]\+) finished -part 0: ThreadId([0-9]\+) finished -part 1: ThreadId([0-9]\+) finished -part 2: ThreadId([0-9]\+) finished -part 3: ThreadId([0-9]\+) finished -part 4: ThreadId([0-9]\+) finished -part 5: ThreadId([0-9]\+) finished -part 6: ThreadId([0-9]\+) finished -part 7: ThreadId([0-9]\+) finished -part 8: ThreadId([0-9]\+) finished -part 9: ThreadId([0-9]\+) finished -part 10: ThreadId([0-9]\+) finished -part 11: ThreadId([0-9]\+) finished -part 12: ThreadId([0-9]\+) finished -part 13: ThreadId([0-9]\+) finished -part 14: ThreadId([0-9]\+) finished -Parallel summation tests run OK! -Shutting down... diff --git a/apps/task/parallel/src/main.rs b/apps/task/parallel/src/main.rs deleted file mode 100644 index aa3372501..000000000 --- a/apps/task/parallel/src/main.rs +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use rand::{rngs::SmallRng, RngCore, SeedableRng}; -use std::thread; -use std::{sync::Arc, vec::Vec}; - -#[cfg(feature = "axstd")] -use std::os::arceos::api::task::{self as api, AxWaitQueueHandle}; - -const NUM_DATA: usize = 2_000_000; -const NUM_TASKS: usize = 16; - -#[cfg(feature = "axstd")] -fn barrier() { - use std::sync::atomic::{AtomicUsize, Ordering}; - static BARRIER_WQ: AxWaitQueueHandle = AxWaitQueueHandle::new(); - static BARRIER_COUNT: AtomicUsize = AtomicUsize::new(0); - - BARRIER_COUNT.fetch_add(1, Ordering::Relaxed); - api::ax_wait_queue_wait( - &BARRIER_WQ, - || BARRIER_COUNT.load(Ordering::Relaxed) == NUM_TASKS, - None, - ); - api::ax_wait_queue_wake(&BARRIER_WQ, u32::MAX); // wakeup all -} - -#[cfg(not(feature = "axstd"))] -fn barrier() { - use std::sync::{Barrier, OnceLock}; - static BARRIER: OnceLock = OnceLock::new(); - BARRIER.get_or_init(|| Barrier::new(NUM_TASKS)).wait(); -} - -fn sqrt(n: &u64) -> u64 { - let mut x = *n; - loop { - if x * x <= *n && (x + 1) * (x + 1) > *n { - return x; - } - x = (x + *n / x) / 2; - } -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - let mut rng = SmallRng::seed_from_u64(0xdead_beef); - let vec = Arc::new( - (0..NUM_DATA) - .map(|_| rng.next_u32() as u64) - .collect::>(), - ); - let expect: u64 = vec.iter().map(sqrt).sum(); - - #[cfg(feature = "axstd")] - { - // equals to sleep(500ms) - let timeout = api::ax_wait_queue_wait( - &AxWaitQueueHandle::new(), - || false, - Some(std::time::Duration::from_millis(500)), - ); - assert!(timeout); - } - - let mut tasks = Vec::with_capacity(NUM_TASKS); - for i in 0..NUM_TASKS { - let vec = vec.clone(); - tasks.push(thread::spawn(move || { - let left = i * (NUM_DATA / NUM_TASKS); - let right = (left + (NUM_DATA / NUM_TASKS)).min(NUM_DATA); - println!( - "part {}: {:?} [{}, {})", - i, - thread::current().id(), - left, - right - ); - - let partial_sum: u64 = vec[left..right].iter().map(sqrt).sum(); - barrier(); - - println!("part {}: {:?} finished", i, thread::current().id()); - partial_sum - })); - } - - let actual = tasks.into_iter().map(|t| t.join().unwrap()).sum(); - println!("sum = {}", actual); - assert_eq!(expect, actual); - - println!("Parallel summation tests run OK!"); -} diff --git a/apps/task/parallel/test_cmd b/apps/task/parallel/test_cmd deleted file mode 100644 index 046ef5771..000000000 --- a/apps/task/parallel/test_cmd +++ /dev/null @@ -1,3 +0,0 @@ -test_one "LOG=info" "expect_info_smp1_fifo.out" -test_one "SMP=4 LOG=info FEATURES=sched_rr" "expect_info_smp4_rr.out" -test_one "SMP=4 LOG=info FEATURES=sched_cfs" "expect_info_smp4_cfs.out" diff --git a/apps/task/priority/Cargo.toml b/apps/task/priority/Cargo.toml deleted file mode 100644 index 5c4061a09..000000000 --- a/apps/task/priority/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "arceos-priority" -version = "0.1.0" -edition = "2021" -authors = ["Haoxing Ye "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[features] -sched_rr = ["axstd?/sched_rr"] -sched_cfs = ["axstd?/sched_cfs"] - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["alloc", "multitask"], optional = true } diff --git a/apps/task/priority/expect_info_smp1_cfs.out b/apps/task/priority/expect_info_smp1_cfs.out deleted file mode 100644 index 90ab65485..000000000 --- a/apps/task/priority/expect_info_smp1_cfs.out +++ /dev/null @@ -1,37 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize scheduling... - use Completely Fair scheduler. -Initialize interrupt handlers... -Primary CPU 0 init OK. -part 0: ThreadId(4) \[0, 40) -part 1: ThreadId(5) \[0, 40) -part 2: ThreadId(6) \[0, 40) -part 3: ThreadId(7) \[0, 40) -part 4: ThreadId(8) \[0, 4) -part 0: ThreadId(4) finished -part 1: ThreadId(5) finished -part 2: ThreadId(6) finished -part 3: ThreadId(7) finished -part 4: ThreadId(8) finished -sum = 3318102132 -leave time: -task 0 = -task 1 = -task 2 = -task 3 = -task 4 = -Priority tests run OK! -Shutting down... diff --git a/apps/task/priority/expect_info_smp1_fifo.out b/apps/task/priority/expect_info_smp1_fifo.out deleted file mode 100644 index 54a3546b3..000000000 --- a/apps/task/priority/expect_info_smp1_fifo.out +++ /dev/null @@ -1,36 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize scheduling... - use FIFO scheduler. -Primary CPU 0 init OK. -part 0: ThreadId(4) \[0, 40) -part 0: ThreadId(4) finished -part 1: ThreadId(5) \[0, 40) -part 1: ThreadId(5) finished -part 2: ThreadId(6) \[0, 40) -part 2: ThreadId(6) finished -part 3: ThreadId(7) \[0, 40) -part 3: ThreadId(7) finished -part 4: ThreadId(8) \[0, 4) -part 4: ThreadId(8) finished -sum = 3318102132 -leave time: -task 0 = -task 1 = -task 2 = -task 3 = -task 4 = -Priority tests run OK! -Shutting down... diff --git a/apps/task/priority/expect_info_smp1_rr.out b/apps/task/priority/expect_info_smp1_rr.out deleted file mode 100644 index da4d57a7f..000000000 --- a/apps/task/priority/expect_info_smp1_rr.out +++ /dev/null @@ -1,37 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize scheduling... - use Round-robin scheduler. -Initialize interrupt handlers... -Primary CPU 0 init OK. -part 0: ThreadId(4) \[0, 40) -part 1: ThreadId(5) \[0, 40) -part 2: ThreadId(6) \[0, 40) -part 3: ThreadId(7) \[0, 40) -part 4: ThreadId(8) \[0, 4) -part 0: ThreadId(4) finished -part 1: ThreadId(5) finished -part 2: ThreadId(6) finished -part 3: ThreadId(7) finished -part 4: ThreadId(8) finished -sum = 3318102132 -leave time: -task 0 = -task 1 = -task 2 = -task 3 = -task 4 = -Priority tests run OK! -Shutting down... diff --git a/apps/task/priority/expect_info_smp4_cfs.out b/apps/task/priority/expect_info_smp4_cfs.out deleted file mode 100644 index b73ed81dd..000000000 --- a/apps/task/priority/expect_info_smp4_cfs.out +++ /dev/null @@ -1,43 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -Primary CPU [0-9]\+ started, -Secondary CPU [0-9]\+ started. -Secondary CPU [0-9]\+ started. -Secondary CPU [0-9]\+ started. -Secondary CPU [0-9]\+ init OK. -Secondary CPU [0-9]\+ init OK. -Secondary CPU [0-9]\+ init OK. -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize scheduling... - use Completely Fair scheduler. -Initialize interrupt handlers... -Primary CPU [0-9]\+ init OK. -part 0: ThreadId(7) \[0, 40) -part 1: ThreadId(8) \[0, 40) -part 2: ThreadId(9) \[0, 40) -part 3: ThreadId(10) \[0, 40) -part 4: ThreadId(11) \[0, 4) -part 0: ThreadId(7) finished -part 1: ThreadId(8) finished -part 2: ThreadId(9) finished -part 3: ThreadId(10) finished -part 4: ThreadId(11) finished -sum = 3318102132 -leave time: -task 0 = -task 1 = -task 2 = -task 3 = -task 4 = -Priority tests run OK! -Shutting down... diff --git a/apps/task/priority/src/main.rs b/apps/task/priority/src/main.rs deleted file mode 100644 index 800e39bcf..000000000 --- a/apps/task/priority/src/main.rs +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::sync::Arc; -use std::{thread, time}; -use std::{vec, vec::Vec}; - -#[cfg(any(feature = "axstd", target_os = "arceos"))] -use std::os::arceos::api::task::ax_set_current_priority; - -struct TaskParam { - data_len: usize, - value: u64, - nice: isize, -} - -const TASK_PARAMS: &[TaskParam] = &[ - // four short tasks - TaskParam { - data_len: 40, - value: 1000000, - nice: 19, - }, - TaskParam { - data_len: 40, - value: 1000000, - nice: 10, - }, - TaskParam { - data_len: 40, - value: 1000000, - nice: 0, - }, - TaskParam { - data_len: 40, - value: 1000000, - nice: -10, - }, - // one long task - TaskParam { - data_len: 4, - value: 10000000, - nice: 0, - }, -]; - -const PAYLOAD_KIND: usize = 5; - -fn load(n: &u64) -> u64 { - // time consuming is linear with *n - let mut sum: u64 = *n; - for i in 0..*n { - sum += ((i ^ (i * 3)) ^ (i + *n)) / (i + 1); - } - sum -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - #[cfg(feature = "axstd")] - ax_set_current_priority(-20).ok(); - - let data = (0..PAYLOAD_KIND) - .map(|i| Arc::new(vec![TASK_PARAMS[i].value; TASK_PARAMS[i].data_len])) - .collect::>(); - let mut expect: u64 = 0; - for data_inner in &data { - expect += data_inner.iter().map(load).sum::(); - } - - let mut tasks = Vec::with_capacity(PAYLOAD_KIND); - let start_time = time::Instant::now(); - for i in 0..PAYLOAD_KIND { - let vec = data[i].clone(); - let data_len = TASK_PARAMS[i].data_len; - let nice = TASK_PARAMS[i].nice; - tasks.push(thread::spawn(move || { - #[cfg(feature = "axstd")] - ax_set_current_priority(nice).ok(); - - let left = 0; - let right = data_len; - println!( - "part {}: {:?} [{}, {})", - i, - thread::current().id(), - left, - right - ); - - let partial_sum: u64 = vec[left..right].iter().map(load).sum(); - let leave_time = start_time.elapsed().as_millis() as u64; - - println!("part {}: {:?} finished", i, thread::current().id()); - (partial_sum, leave_time) - })); - } - - let (results, leave_times): (Vec<_>, Vec<_>) = - tasks.into_iter().map(|t| t.join().unwrap()).unzip(); - let actual = results.iter().sum(); - - println!("sum = {}", actual); - println!("leave time:"); - for (i, time) in leave_times.iter().enumerate() { - println!("task {} = {}ms", i, time); - } - - #[cfg(feature = "axstd")] - if cfg!(feature = "sched_cfs") && option_env!("AX_SMP") == Some("1") { - assert!( - leave_times[0] > leave_times[1] - && leave_times[1] > leave_times[2] - && leave_times[2] > leave_times[3] - ); - } - - assert_eq!(expect, actual); - - println!("Priority tests run OK!"); -} diff --git a/apps/task/priority/test_cmd b/apps/task/priority/test_cmd deleted file mode 100644 index 6c0bd6b3a..000000000 --- a/apps/task/priority/test_cmd +++ /dev/null @@ -1,4 +0,0 @@ -test_one "SMP=1 LOG=info" "expect_info_smp1_fifo.out" -test_one "SMP=1 LOG=info APP_FEATURES=sched_cfs" "expect_info_smp1_cfs.out" -test_one "SMP=1 LOG=info APP_FEATURES=sched_rr" "expect_info_smp1_rr.out" -test_one "SMP=4 LOG=info APP_FEATURES=sched_cfs" "expect_info_smp4_cfs.out" diff --git a/apps/task/sleep/Cargo.toml b/apps/task/sleep/Cargo.toml deleted file mode 100644 index 2608c3db8..000000000 --- a/apps/task/sleep/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "arceos-sleep" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["multitask", "irq"], optional = true } diff --git a/apps/task/sleep/expect_info_smp4_fifo.out b/apps/task/sleep/expect_info_smp4_fifo.out deleted file mode 100644 index ebcdf252b..000000000 --- a/apps/task/sleep/expect_info_smp4_fifo.out +++ /dev/null @@ -1,82 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use FIFO scheduler. -Initialize interrupt handlers... -Hello, main task! -main task sleep for 1\.[0-9]\+s - tick 0 -task 0 sleep 1 seconds (0) ... -task 1 sleep 2 seconds (0) ... -task 2 sleep 3 seconds (0) ... -task 3 sleep 4 seconds (0) ... -task 4 sleep 5 seconds (0) ... - tick 1 -task 0 actual sleep 1\.[0-9]\+s seconds (0). -task 0 sleep 1 seconds (1) ... - tick 2 - tick 3 -task 1 actual sleep 2\.[0-9]\+s seconds (0). -task 1 sleep 2 seconds (1) ... -task 0 actual sleep 1\.[0-9]\+s seconds (1). -task 0 sleep 1 seconds (2) ... - tick 4 - tick 5 -task 2 actual sleep 3\.[0-9]\+s seconds (0). -task 2 sleep 3 seconds (1) ... -task 0 actual sleep 1\.[0-9]\+s seconds (2). - tick 6 - tick 7 -task 3 actual sleep 4\.[0-9]\+s seconds (0). -task 3 sleep 4 seconds (1) ... -task 1 actual sleep 2\.[0-9]\+s seconds (1). -task 1 sleep 2 seconds (2) ... - tick 8 - tick 9 -task 4 actual sleep 5\.[0-9]\+s seconds (0). -task 4 sleep 5 seconds (1) ... - tick 10 - tick 11 -task 2 actual sleep 3\.[0-9]\+s seconds (1). -task 2 sleep 3 seconds (2) ... -task 1 actual sleep 2\.[0-9]\+s seconds (2). - tick 12 - tick 13 - tick 14 - tick 15 -task 3 actual sleep 4\.[0-9]\+s seconds (1). -task 3 sleep 4 seconds (2) ... - tick 16 - tick 17 -task 2 actual sleep 3\.[0-9]\+s seconds (2). - tick 18 - tick 19 -task 4 actual sleep 5\.[0-9]\+s seconds (1). -task 4 sleep 5 seconds (2) ... - tick 20 - tick 21 - tick 22 - tick 23 -task 3 actual sleep 4\.[0-9]\+s seconds (2). - tick 24 - tick 25 - tick 26 - tick 27 - tick 28 - tick 29 -task 4 actual sleep 5\.[0-9]\+s seconds (2). -Sleep tests run OK! -Shutting down... diff --git a/apps/task/sleep/expect_info_smp4_rr.out b/apps/task/sleep/expect_info_smp4_rr.out deleted file mode 100644 index 7d09432a8..000000000 --- a/apps/task/sleep/expect_info_smp4_rr.out +++ /dev/null @@ -1,82 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use Round-robin scheduler. -Initialize interrupt handlers... -Hello, main task! -main task sleep for 1\.[0-9]\+s - tick 0 -task 0 sleep 1 seconds (0) ... -task 1 sleep 2 seconds (0) ... -task 2 sleep 3 seconds (0) ... -task 3 sleep 4 seconds (0) ... -task 4 sleep 5 seconds (0) ... - tick 1 -task 0 actual sleep 1\.[0-9]\+s seconds (0). -task 0 sleep 1 seconds (1) ... - tick 2 - tick 3 -task 1 actual sleep 2\.[0-9]\+s seconds (0). -task 1 sleep 2 seconds (1) ... -task 0 actual sleep 1\.[0-9]\+s seconds (1). -task 0 sleep 1 seconds (2) ... - tick 4 - tick 5 -task 2 actual sleep 3\.[0-9]\+s seconds (0). -task 2 sleep 3 seconds (1) ... -task 0 actual sleep 1\.[0-9]\+s seconds (2). - tick 6 - tick 7 -task 3 actual sleep 4\.[0-9]\+s seconds (0). -task 3 sleep 4 seconds (1) ... -task 1 actual sleep 2\.[0-9]\+s seconds (1). -task 1 sleep 2 seconds (2) ... - tick 8 - tick 9 -task 4 actual sleep 5\.[0-9]\+s seconds (0). -task 4 sleep 5 seconds (1) ... - tick 10 - tick 11 -task 2 actual sleep 3\.[0-9]\+s seconds (1). -task 2 sleep 3 seconds (2) ... -task 1 actual sleep 2\.[0-9]\+s seconds (2). - tick 12 - tick 13 - tick 14 - tick 15 -task 3 actual sleep 4\.[0-9]\+s seconds (1). -task 3 sleep 4 seconds (2) ... - tick 16 - tick 17 -task 2 actual sleep 3\.[0-9]\+s seconds (2). - tick 18 - tick 19 -task 4 actual sleep 5\.[0-9]\+s seconds (1). -task 4 sleep 5 seconds (2) ... - tick 20 - tick 21 - tick 22 - tick 23 -task 3 actual sleep 4\.[0-9]\+s seconds (2). - tick 24 - tick 25 - tick 26 - tick 27 - tick 28 - tick 29 -task 4 actual sleep 5\.[0-9]\+s seconds (2). -Sleep tests run OK! -Shutting down... diff --git a/apps/task/sleep/src/main.rs b/apps/task/sleep/src/main.rs deleted file mode 100644 index 5d52e8695..000000000 --- a/apps/task/sleep/src/main.rs +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::thread; -use std::time::{Duration, Instant}; - -const NUM_TASKS: usize = 5; - -static FINISHED_TASKS: AtomicUsize = AtomicUsize::new(0); - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Hello, main task!"); - let now = Instant::now(); - thread::sleep(Duration::from_secs(1)); - let elapsed = now.elapsed(); - println!("main task sleep for {:?}", elapsed); - - // backgroud ticks, 0.5s x 30 = 15s - thread::spawn(|| { - for i in 0..30 { - println!(" tick {}", i); - thread::sleep(Duration::from_millis(500)); - } - }); - - // task n: sleep 3 x n (sec) - for i in 0..NUM_TASKS { - thread::spawn(move || { - let sec = i + 1; - for j in 0..3 { - println!("task {} sleep {} seconds ({}) ...", i, sec, j); - let now = Instant::now(); - thread::sleep(Duration::from_secs(sec as _)); - let elapsed = now.elapsed(); - println!("task {} actual sleep {:?} seconds ({}).", i, elapsed, j); - } - FINISHED_TASKS.fetch_add(1, Ordering::Relaxed); - }); - } - - while FINISHED_TASKS.load(Ordering::Relaxed) < NUM_TASKS { - thread::sleep(Duration::from_millis(10)); - } - println!("Sleep tests run OK!"); -} diff --git a/apps/task/sleep/test_cmd b/apps/task/sleep/test_cmd deleted file mode 100644 index beeb3c408..000000000 --- a/apps/task/sleep/test_cmd +++ /dev/null @@ -1,2 +0,0 @@ -test_one "SMP=4 LOG=info" "expect_info_smp4_fifo.out" -test_one "SMP=4 LOG=info FEATURES=sched_rr" "expect_info_smp4_rr.out" diff --git a/apps/task/tls/Cargo.toml b/apps/task/tls/Cargo.toml deleted file mode 100644 index 86cbe1bd4..000000000 --- a/apps/task/tls/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "arceos-tls" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["tls", "alloc", "multitask"], optional = true } diff --git a/apps/task/tls/expect_info_smp1_fifo.out b/apps/task/tls/expect_info_smp1_fifo.out deleted file mode 100644 index 9628fda4e..000000000 --- a/apps/task/tls/expect_info_smp1_fifo.out +++ /dev/null @@ -1,31 +0,0 @@ -smp = 1 -build_mode = release -log_level = info - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use FIFO scheduler. -Primary CPU 0 init OK. -Running TLS tests... -main: true 0xaa 0xcafe 0xdeadbeed 0xa2ce05a2ce05 Hello, world! -1: false 0xab 0xcaff 0xdeadbeee 0xa2ce05a2ce06 Hello1 world! -2: true 0xac 0xcb00 0xdeadbeef 0xa2ce05a2ce07 Hello2 world! -3: false 0xad 0xcb01 0xdeadbef0 0xa2ce05a2ce08 Hello3 world! -4: true 0xae 0xcb02 0xdeadbef1 0xa2ce05a2ce09 Hello4 world! -5: false 0xaf 0xcb03 0xdeadbef2 0xa2ce05a2ce0a Hello5 world! -6: true 0xb0 0xcb04 0xdeadbef3 0xa2ce05a2ce0b Hello6 world! -7: false 0xb1 0xcb05 0xdeadbef4 0xa2ce05a2ce0c Hello7 world! -8: true 0xb2 0xcb06 0xdeadbef5 0xa2ce05a2ce0d Hello8 world! -9: false 0xb3 0xcb07 0xdeadbef6 0xa2ce05a2ce0e Hello9 world! -10: true 0xb4 0xcb08 0xdeadbef7 0xa2ce05a2ce0f Hello: world! -TLS tests run OK! -Shutting down... diff --git a/apps/task/tls/expect_info_smp4_rr.out b/apps/task/tls/expect_info_smp4_rr.out deleted file mode 100644 index a65f69af2..000000000 --- a/apps/task/tls/expect_info_smp4_rr.out +++ /dev/null @@ -1,38 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use Round-robin scheduler. -Initialize interrupt handlers... -CPU 0 init OK -CPU 1 started -CPU 2 started -CPU 3 started -CPU 1 init OK -CPU 2 init OK -CPU 3 init OK -Running TLS tests... -main: true 0xaa 0xcafe 0xdeadbeed 0xa2ce05a2ce05 Hello, world! -1: false 0xab 0xcaff 0xdeadbeee 0xa2ce05a2ce06 Hello1 world! -2: true 0xac 0xcb00 0xdeadbeef 0xa2ce05a2ce07 Hello2 world! -3: false 0xad 0xcb01 0xdeadbef0 0xa2ce05a2ce08 Hello3 world! -4: true 0xae 0xcb02 0xdeadbef1 0xa2ce05a2ce09 Hello4 world! -5: false 0xaf 0xcb03 0xdeadbef2 0xa2ce05a2ce0a Hello5 world! -6: true 0xb0 0xcb04 0xdeadbef3 0xa2ce05a2ce0b Hello6 world! -7: false 0xb1 0xcb05 0xdeadbef4 0xa2ce05a2ce0c Hello7 world! -8: true 0xb2 0xcb06 0xdeadbef5 0xa2ce05a2ce0d Hello8 world! -9: false 0xb3 0xcb07 0xdeadbef6 0xa2ce05a2ce0e Hello9 world! -10: true 0xb4 0xcb08 0xdeadbef7 0xa2ce05a2ce0f Hello: world! -TLS tests run OK! -Shutting down... diff --git a/apps/task/tls/src/main.rs b/apps/task/tls/src/main.rs deleted file mode 100644 index e9633e32e..000000000 --- a/apps/task/tls/src/main.rs +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] -#![feature(thread_local)] -#![allow(unused_unsafe)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::{thread, vec::Vec}; - -#[thread_local] -static mut BOOL: bool = true; - -#[thread_local] -static mut U8: u8 = 0xAA; - -#[thread_local] -static mut U16: u16 = 0xcafe; - -#[thread_local] -static mut U32: u32 = 0xdeadbeed; - -#[thread_local] -static mut U64: u64 = 0xa2ce05_a2ce05; - -#[thread_local] -static mut STR: [u8; 13] = *b"Hello, world!"; - -macro_rules! get { - ($var:expr) => { - unsafe { $var } - }; -} - -macro_rules! set { - ($var:expr, $value:expr) => { - unsafe { $var = $value } - }; -} - -macro_rules! add { - ($var:expr, $value:expr) => { - unsafe { $var += $value } - }; -} - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - println!("Running TLS tests..."); - - println!( - "main: {} {:#x} {:#x} {:#x} {:#x} {}", - get!(BOOL), - get!(U8), - get!(U16), - get!(U32), - get!(U64), - get!(std::str::from_utf8_unchecked(&STR)) - ); - assert!(get!(BOOL)); - assert_eq!(get!(U8), 0xAA); - assert_eq!(get!(U16), 0xcafe); - assert_eq!(get!(U32), 0xdeadbeed); - assert_eq!(get!(U64), 0xa2ce05_a2ce05); - assert_eq!(get!(&STR), b"Hello, world!"); - - let mut tasks = Vec::new(); - for i in 1..=10 { - tasks.push(thread::spawn(move || { - set!(BOOL, i % 2 == 0); - add!(U8, i as u8); - add!(U16, i as u16); - add!(U32, i as u32); - add!(U64, i as u64); - set!(STR[5], 48 + i as u8); - - thread::yield_now(); - - println!( - "{}: {} {:#x} {:#x} {:#x} {:#x} {}", - i, - get!(BOOL), - get!(U8), - get!(U16), - get!(U32), - get!(U64), - get!(std::str::from_utf8_unchecked(&STR)) - ); - assert_eq!(get!(BOOL), i % 2 == 0); - assert_eq!(get!(U8), 0xAA + i as u8); - assert_eq!(get!(U16), 0xcafe + i as u16); - assert_eq!(get!(U32), 0xdeadbeed + i as u32); - assert_eq!(get!(U64), 0xa2ce05_a2ce05 + i as u64); - assert_eq!(get!(STR[5]), 48 + i as u8); - assert_eq!(get!(STR.len()), 13); - })); - } - - tasks.into_iter().for_each(|t| t.join().unwrap()); - - // TLS of main thread must not have been changed by the other thread. - assert!(get!(BOOL)); - assert_eq!(get!(U8), 0xAA); - assert_eq!(get!(U16), 0xcafe); - assert_eq!(get!(U32), 0xdeadbeed); - assert_eq!(get!(U64), 0xa2ce05_a2ce05); - assert_eq!(get!(&STR), b"Hello, world!"); - - println!("TLS tests run OK!"); -} diff --git a/apps/task/tls/test_cmd b/apps/task/tls/test_cmd deleted file mode 100644 index e28757954..000000000 --- a/apps/task/tls/test_cmd +++ /dev/null @@ -1,2 +0,0 @@ -test_one "LOG=info" "expect_info_smp1_fifo.out" -test_one "SMP=4 LOG=info FEATURES=sched_rr" "expect_info_smp4_rr.out" diff --git a/apps/task/yield/Cargo.toml b/apps/task/yield/Cargo.toml deleted file mode 100644 index b8d775bc6..000000000 --- a/apps/task/yield/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "arceos-yield" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[features] -sched_rr = ["axstd?/sched_rr"] -sched_cfs = ["axstd?/sched_cfs"] - -[dependencies] -axstd = { path = "../../../ulib/axstd", features = ["multitask"], optional = true } diff --git a/apps/task/yield/expect_debug_smp1_fifo.out b/apps/task/yield/expect_debug_smp1_fifo.out deleted file mode 100644 index 38adf4488..000000000 --- a/apps/task/yield/expect_debug_smp1_fifo.out +++ /dev/null @@ -1,54 +0,0 @@ -smp = 1 -build_mode = release -log_level = debug - -Primary CPU 0 started, -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use FIFO scheduler. -Primary CPU 0 init OK. -Hello, main task! -Hello, task 0! id = ThreadId(4) -Hello, task 1! id = ThreadId(5) -Hello, task 2! id = ThreadId(6) -Hello, task 3! id = ThreadId(7) -Hello, task 4! id = ThreadId(8) -Hello, task 5! id = ThreadId(9) -Hello, task 6! id = ThreadId(10) -Hello, task 7! id = ThreadId(11) -Hello, task 8! id = ThreadId(12) -Hello, task 9! id = ThreadId(13) -task block: Task(3, "gc") -task exit: Task(4, ""), exit_code=0 -task unblock: Task(3, "gc") -task exit: Task(5, ""), exit_code=0 -task exit: Task(6, ""), exit_code=0 -task exit: Task(7, ""), exit_code=0 -task exit: Task(8, ""), exit_code=0 -task exit: Task(9, ""), exit_code=0 -task exit: Task(10, ""), exit_code=0 -task exit: Task(11, ""), exit_code=0 -task exit: Task(12, ""), exit_code=0 -task exit: Task(13, ""), exit_code=0 -Task yielding tests run OK! -task exit: Task(2, "main"), exit_code=0 -task drop: Task(4, "") -task drop: Task(5, "") -task drop: Task(6, "") -task drop: Task(7, "") -task drop: Task(8, "") -task drop: Task(9, "") -task drop: Task(10, "") -task drop: Task(11, "") -task drop: Task(12, "") -task drop: Task(13, "") -Shutting down... diff --git a/apps/task/yield/expect_info_smp4_fifo.out b/apps/task/yield/expect_info_smp4_fifo.out deleted file mode 100644 index 5f75f056f..000000000 --- a/apps/task/yield/expect_info_smp4_fifo.out +++ /dev/null @@ -1,38 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use FIFO scheduler. -CPU 1 init OK -CPU 0 init OK -CPU 1 started -CPU 2 started -CPU 3 started -CPU 1 init OK -CPU 2 init OK -CPU 3 init OK -Hello, main task! -Hello, task 0! id = ThreadId(7) -Hello, task 1! id = ThreadId(8) -Hello, task 2! id = ThreadId(9) -Hello, task 3! id = ThreadId(10) -Hello, task 4! id = ThreadId(11) -Hello, task 5! id = ThreadId(12) -Hello, task 6! id = ThreadId(13) -Hello, task 7! id = ThreadId(14) -Hello, task 8! id = ThreadId(15) -Hello, task 9! id = ThreadId(16) -Task yielding tests run OK! -Shutting down... diff --git a/apps/task/yield/expect_info_smp4_rr.out b/apps/task/yield/expect_info_smp4_rr.out deleted file mode 100644 index daa0c7126..000000000 --- a/apps/task/yield/expect_info_smp4_rr.out +++ /dev/null @@ -1,38 +0,0 @@ -smp = 4 -build_mode = release -log_level = info - -CPU 0 started -Found physcial memory regions: - .text (READ | EXECUTE | RESERVED) - .rodata (READ | RESERVED) - .data .tdata .tbss .percpu (READ | WRITE | RESERVED) - .percpu (READ | WRITE | RESERVED) - boot stack (READ | WRITE | RESERVED) - .bss (READ | WRITE | RESERVED) - free memory (READ | WRITE | FREE) -Initialize global memory allocator... -Initialize platform devices... -Initialize scheduling... - use Round-robin scheduler. -Initialize interrupt handlers... -CPU 0 init OK -CPU 1 started -CPU 2 started -CPU 3 started -CPU 1 init OK -CPU 2 init OK -CPU 3 init OK -Hello, main task! -Hello, task 0! id = ThreadId(7) -Hello, task 1! id = ThreadId(8) -Hello, task 2! id = ThreadId(9) -Hello, task 3! id = ThreadId(10) -Hello, task 4! id = ThreadId(11) -Hello, task 5! id = ThreadId(12) -Hello, task 6! id = ThreadId(13) -Hello, task 7! id = ThreadId(14) -Hello, task 8! id = ThreadId(15) -Hello, task 9! id = ThreadId(16) -Task yielding tests run OK! -Shutting down... diff --git a/apps/task/yield/src/main.rs b/apps/task/yield/src/main.rs deleted file mode 100644 index af579e072..000000000 --- a/apps/task/yield/src/main.rs +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -#![cfg_attr(feature = "axstd", no_std)] -#![cfg_attr(feature = "axstd", no_main)] - -#[macro_use] -#[cfg(feature = "axstd")] -extern crate axstd as std; - -use std::sync::atomic::{AtomicUsize, Ordering}; -use std::thread; - -const NUM_TASKS: usize = 10; -static FINISHED_TASKS: AtomicUsize = AtomicUsize::new(0); - -#[cfg_attr(feature = "axstd", no_mangle)] -fn main() { - for i in 0..NUM_TASKS { - thread::spawn(move || { - println!("Hello, task {}! id = {:?}", i, thread::current().id()); - - #[cfg(all(not(feature = "sched_rr"), not(feature = "sched_cfs")))] - thread::yield_now(); - - let _order = FINISHED_TASKS.fetch_add(1, Ordering::Relaxed); - #[cfg(not(feature = "sched_cfs"))] - if option_env!("AX_SMP") == Some("1") { - assert!(_order == i); // FIFO scheduler - } - }); - } - println!("Hello, main task!"); - while FINISHED_TASKS.load(Ordering::Relaxed) < NUM_TASKS { - #[cfg(all(not(feature = "sched_rr"), not(feature = "sched_cfs")))] - thread::yield_now(); - } - println!("Task yielding tests run OK!"); -} diff --git a/apps/task/yield/test_cmd b/apps/task/yield/test_cmd deleted file mode 100644 index bf30e3ba4..000000000 --- a/apps/task/yield/test_cmd +++ /dev/null @@ -1,3 +0,0 @@ -test_one "LOG=debug" "expect_debug_smp1_fifo.out" -test_one "SMP=4 LOG=info" "expect_info_smp4_fifo.out" -test_one "SMP=4 LOG=info APP_FEATURES=sched_rr" "expect_info_smp4_rr.out" diff --git a/crates/allocator/benches/collections.rs b/crates/allocator/benches/collections.rs index 184f0a6c9..09b9368d5 100644 --- a/crates/allocator/benches/collections.rs +++ b/crates/allocator/benches/collections.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/benches/utils/mod.rs b/crates/allocator/benches/utils/mod.rs index a7d3fff3b..d4768999f 100644 --- a/crates/allocator/benches/utils/mod.rs +++ b/crates/allocator/benches/utils/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/src/bitmap.rs b/crates/allocator/src/bitmap.rs index 8b3a93332..d79ad1de2 100644 --- a/crates/allocator/src/bitmap.rs +++ b/crates/allocator/src/bitmap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/src/buddy.rs b/crates/allocator/src/buddy.rs index 56480d24b..046debaba 100644 --- a/crates/allocator/src/buddy.rs +++ b/crates/allocator/src/buddy.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/src/lib.rs b/crates/allocator/src/lib.rs index 23fa3a18f..8fd653b09 100644 --- a/crates/allocator/src/lib.rs +++ b/crates/allocator/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/src/slab.rs b/crates/allocator/src/slab.rs index 57d49a7f4..b6c08f242 100644 --- a/crates/allocator/src/slab.rs +++ b/crates/allocator/src/slab.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/src/tlsf.rs b/crates/allocator/src/tlsf.rs index 5298ddf35..0badb76dd 100644 --- a/crates/allocator/src/tlsf.rs +++ b/crates/allocator/src/tlsf.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/allocator/tests/allocator.rs b/crates/allocator/tests/allocator.rs index fec7b1d96..9a2b14a1b 100644 --- a/crates/allocator/tests/allocator.rs +++ b/crates/allocator/tests/allocator.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/arm_gic/src/gic_v2.rs b/crates/arm_gic/src/gic_v2.rs index bab3ca80b..3aa485295 100644 --- a/crates/arm_gic/src/gic_v2.rs +++ b/crates/arm_gic/src/gic_v2.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/arm_gic/src/lib.rs b/crates/arm_gic/src/lib.rs index f6dafc96d..5dc5bdc5e 100644 --- a/crates/arm_gic/src/lib.rs +++ b/crates/arm_gic/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/arm_pl011/src/lib.rs b/crates/arm_pl011/src/lib.rs index 855a64ee5..d442d92c0 100644 --- a/crates/arm_pl011/src/lib.rs +++ b/crates/arm_pl011/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/arm_pl011/src/pl011.rs b/crates/arm_pl011/src/pl011.rs index 2f79d201f..e6b5c44a3 100644 --- a/crates/arm_pl011/src/pl011.rs +++ b/crates/arm_pl011/src/pl011.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axerrno/build.rs b/crates/axerrno/build.rs index 731c774a0..83b4b2827 100644 --- a/crates/axerrno/build.rs +++ b/crates/axerrno/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axerrno/src/errno.h b/crates/axerrno/src/errno.h index 871a74382..7080e3b33 100644 --- a/crates/axerrno/src/errno.h +++ b/crates/axerrno/src/errno.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axerrno/src/lib.rs b/crates/axerrno/src/lib.rs index fb276ef86..0ef5d5ede 100644 --- a/crates/axerrno/src/lib.rs +++ b/crates/axerrno/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_devfs/src/dir.rs b/crates/axfs_devfs/src/dir.rs index fbd62096c..2245fcb49 100644 --- a/crates/axfs_devfs/src/dir.rs +++ b/crates/axfs_devfs/src/dir.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_devfs/src/lib.rs b/crates/axfs_devfs/src/lib.rs index 9d3c53e4a..3334fb777 100644 --- a/crates/axfs_devfs/src/lib.rs +++ b/crates/axfs_devfs/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -17,6 +17,7 @@ extern crate alloc; mod dir; mod null; +mod random; mod zero; #[cfg(test)] @@ -24,6 +25,7 @@ mod tests; pub use self::dir::DirNode; pub use self::null::NullDev; +pub use self::random::RandomDev; pub use self::zero::ZeroDev; use alloc::sync::Arc; diff --git a/crates/axfs_devfs/src/null.rs b/crates/axfs_devfs/src/null.rs index 3e04a889a..183428411 100644 --- a/crates/axfs_devfs/src/null.rs +++ b/crates/axfs_devfs/src/null.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_devfs/src/random.rs b/crates/axfs_devfs/src/random.rs new file mode 100644 index 000000000..2bf10fe77 --- /dev/null +++ b/crates/axfs_devfs/src/random.rs @@ -0,0 +1,65 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Rukos] is licensed under Mulan PSL v2. + * 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. + */ + +use axfs_vfs::{VfsNodeAttr, VfsNodeOps, VfsNodePerm, VfsNodeType, VfsResult}; +use core::sync::atomic::{AtomicU64, Ordering::SeqCst}; + +static SEED: AtomicU64 = AtomicU64::new(0xae_f3); + +/// A random device behaves like `/dev/random`. +/// +/// It always returns a chunk of random bytes when read, and all writes are discarded. +pub struct RandomDev; + +/// Returns a 32-bit unsigned pseudo random interger using LCG. +fn rand_lcg32() -> u32 { + let new_seed = SEED + .load(SeqCst) + .wrapping_mul(6364136223846793005) + .wrapping_add(1); + SEED.store(new_seed, SeqCst); + (new_seed >> 33) as u32 +} + +impl VfsNodeOps for RandomDev { + fn get_attr(&self) -> VfsResult { + Ok(VfsNodeAttr::new( + VfsNodePerm::default_file(), + VfsNodeType::CharDevice, + 0, + 0, + )) + } + + fn read_at(&self, _offset: u64, buf: &mut [u8]) -> VfsResult { + let len = buf.len() >> 2; + let remainder = buf.len() & 0x3; + for i in 0..len { + let random = rand_lcg32(); + let start_idx = i * 4; + // MSB + buf[start_idx..start_idx + 4].copy_from_slice(random.to_be_bytes().as_ref()); + } + + let random = rand_lcg32(); + buf[len * 4..].copy_from_slice(random.to_be_bytes()[..remainder].as_ref()); + + Ok(buf.len()) + } + + fn write_at(&self, _offset: u64, buf: &[u8]) -> VfsResult { + Ok(buf.len()) + } + + fn truncate(&self, _size: u64) -> VfsResult { + Ok(()) + } + + axfs_vfs::impl_vfs_non_dir_default! {} +} diff --git a/crates/axfs_devfs/src/tests.rs b/crates/axfs_devfs/src/tests.rs index 1e58cfaaa..71c8007ad 100644 --- a/crates/axfs_devfs/src/tests.rs +++ b/crates/axfs_devfs/src/tests.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_devfs/src/zero.rs b/crates/axfs_devfs/src/zero.rs index 991cf74ed..b4244349a 100644 --- a/crates/axfs_devfs/src/zero.rs +++ b/crates/axfs_devfs/src/zero.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_ramfs/src/dir.rs b/crates/axfs_ramfs/src/dir.rs index 8b98fe734..e685bd255 100644 --- a/crates/axfs_ramfs/src/dir.rs +++ b/crates/axfs_ramfs/src/dir.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_ramfs/src/file.rs b/crates/axfs_ramfs/src/file.rs index 0df8c8ca6..7464c5d4e 100644 --- a/crates/axfs_ramfs/src/file.rs +++ b/crates/axfs_ramfs/src/file.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_ramfs/src/lib.rs b/crates/axfs_ramfs/src/lib.rs index a8bf60c38..45f11b66b 100644 --- a/crates/axfs_ramfs/src/lib.rs +++ b/crates/axfs_ramfs/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_ramfs/src/tests.rs b/crates/axfs_ramfs/src/tests.rs index eb3115564..1e767635e 100644 --- a/crates/axfs_ramfs/src/tests.rs +++ b/crates/axfs_ramfs/src/tests.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_vfs/src/lib.rs b/crates/axfs_vfs/src/lib.rs index 77af729b1..00fbfd036 100644 --- a/crates/axfs_vfs/src/lib.rs +++ b/crates/axfs_vfs/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_vfs/src/macros.rs b/crates/axfs_vfs/src/macros.rs index c11c14ff8..99f8ab3e3 100644 --- a/crates/axfs_vfs/src/macros.rs +++ b/crates/axfs_vfs/src/macros.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_vfs/src/path.rs b/crates/axfs_vfs/src/path.rs index 321a75068..37faf3555 100644 --- a/crates/axfs_vfs/src/path.rs +++ b/crates/axfs_vfs/src/path.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axfs_vfs/src/structs.rs b/crates/axfs_vfs/src/structs.rs index ee26c83de..7a4b3834b 100644 --- a/crates/axfs_vfs/src/structs.rs +++ b/crates/axfs_vfs/src/structs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axio/src/buffered/bufreader.rs b/crates/axio/src/buffered/bufreader.rs index 4be7af425..27e0cc647 100644 --- a/crates/axio/src/buffered/bufreader.rs +++ b/crates/axio/src/buffered/bufreader.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axio/src/buffered/mod.rs b/crates/axio/src/buffered/mod.rs index eadd8e11a..83d5c3bec 100644 --- a/crates/axio/src/buffered/mod.rs +++ b/crates/axio/src/buffered/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axio/src/error.rs b/crates/axio/src/error.rs index 6a30cb171..bd7d2e4a0 100644 --- a/crates/axio/src/error.rs +++ b/crates/axio/src/error.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axio/src/impls.rs b/crates/axio/src/impls.rs index cc81f35cb..e1c4c1245 100644 --- a/crates/axio/src/impls.rs +++ b/crates/axio/src/impls.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axio/src/lib.rs b/crates/axio/src/lib.rs index 6d5f3b16b..6a34e59f3 100644 --- a/crates/axio/src/lib.rs +++ b/crates/axio/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/axio/src/prelude.rs b/crates/axio/src/prelude.rs index 33b6bfaca..8b8f51057 100644 --- a/crates/axio/src/prelude.rs +++ b/crates/axio/src/prelude.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/capability/src/lib.rs b/crates/capability/src/lib.rs index 9ee6db256..af5015021 100644 --- a/crates/capability/src/lib.rs +++ b/crates/capability/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/crate_interface/src/lib.rs b/crates/crate_interface/src/lib.rs index d6298945e..6ae5e40fd 100644 --- a/crates/crate_interface/src/lib.rs +++ b/crates/crate_interface/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/crate_interface/tests/test_crate_interface.rs b/crates/crate_interface/tests/test_crate_interface.rs index 12a9c0bfd..a90079e5b 100644 --- a/crates/crate_interface/tests/test_crate_interface.rs +++ b/crates/crate_interface/tests/test_crate_interface.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_9p/Cargo.toml b/crates/driver_9p/Cargo.toml index 455236792..8c07a9808 100644 --- a/crates/driver_9p/Cargo.toml +++ b/crates/driver_9p/Cargo.toml @@ -3,11 +3,10 @@ name = "driver_9p" version = "0.1.0" edition = "2021" authors = ["Zheng Wu "] -description = "Common traits and types for block storage drivers" +description = "Common traits and types for 9p drivers" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/crates/driver_common" -documentation = "https://rcore-os.github.io/arceos/driver_common/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/crates/driver_9p" [features] default = [] @@ -15,4 +14,4 @@ default = [] [dependencies] log = "0.4" spin = "0.9" -driver_common = { path = "../driver_common" } \ No newline at end of file +driver_common = { path = "../driver_common" } diff --git a/crates/driver_9p/src/lib.rs b/crates/driver_9p/src/lib.rs index 599ba5262..96fe41d07 100644 --- a/crates/driver_9p/src/lib.rs +++ b/crates/driver_9p/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_block/src/bcm2835sdhci.rs b/crates/driver_block/src/bcm2835sdhci.rs index 400005dad..851fc5392 100644 --- a/crates/driver_block/src/bcm2835sdhci.rs +++ b/crates/driver_block/src/bcm2835sdhci.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_block/src/lib.rs b/crates/driver_block/src/lib.rs index aa59c9191..deed8cad1 100644 --- a/crates/driver_block/src/lib.rs +++ b/crates/driver_block/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_block/src/ramdisk.rs b/crates/driver_block/src/ramdisk.rs index efddf134d..2715aed3e 100644 --- a/crates/driver_block/src/ramdisk.rs +++ b/crates/driver_block/src/ramdisk.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_common/Cargo.toml b/crates/driver_common/Cargo.toml index b3bfe7add..243bc3cc5 100644 --- a/crates/driver_common/Cargo.toml +++ b/crates/driver_common/Cargo.toml @@ -2,11 +2,13 @@ name = "driver_common" version = "0.1.0" edition = "2021" -authors = ["Yuekai Jia "] -description = "Device driver interfaces used by ArceOS" +authors = [ + "Yuekai Jia ", + "Zheng Wu ", +] +description = "Device driver interfaces used by RuxOS" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/crates/driver_common" -documentation = "https://rcore-os.github.io/arceos/driver_common/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/crates/driver_common" [dependencies] diff --git a/crates/driver_common/src/lib.rs b/crates/driver_common/src/lib.rs index 2c6c1c803..9d9f795c7 100644 --- a/crates/driver_common/src/lib.rs +++ b/crates/driver_common/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_display/Cargo.toml b/crates/driver_display/Cargo.toml index e199c626b..5c8836802 100644 --- a/crates/driver_display/Cargo.toml +++ b/crates/driver_display/Cargo.toml @@ -5,9 +5,8 @@ edition = "2021" authors = ["Shiping Yuan "] description = "Common traits and types for graphics device drivers" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/crates/driver_display" -documentation = "https://rcore-os.github.io/arceos/driver_display/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/crates/driver_display" [dependencies] driver_common = { path = "../driver_common" } diff --git a/crates/driver_display/src/lib.rs b/crates/driver_display/src/lib.rs index 139189540..691b1a414 100644 --- a/crates/driver_display/src/lib.rs +++ b/crates/driver_display/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_net/src/ixgbe.rs b/crates/driver_net/src/ixgbe.rs index 4daacf992..27fd4363a 100644 --- a/crates/driver_net/src/ixgbe.rs +++ b/crates/driver_net/src/ixgbe.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_net/src/lib.rs b/crates/driver_net/src/lib.rs index 95f021a6a..6ceb95e47 100644 --- a/crates/driver_net/src/lib.rs +++ b/crates/driver_net/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_net/src/net_buf.rs b/crates/driver_net/src/net_buf.rs index 035c097c9..b218320cb 100644 --- a/crates/driver_net/src/net_buf.rs +++ b/crates/driver_net/src/net_buf.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_pci/src/lib.rs b/crates/driver_pci/src/lib.rs index fd396fff2..11f5d95d9 100644 --- a/crates/driver_pci/src/lib.rs +++ b/crates/driver_pci/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_virtio/src/blk.rs b/crates/driver_virtio/src/blk.rs index f8811130f..3a2e9ffad 100644 --- a/crates/driver_virtio/src/blk.rs +++ b/crates/driver_virtio/src/blk.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_virtio/src/gpu.rs b/crates/driver_virtio/src/gpu.rs index f59605eae..f4577fd16 100644 --- a/crates/driver_virtio/src/gpu.rs +++ b/crates/driver_virtio/src/gpu.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_virtio/src/lib.rs b/crates/driver_virtio/src/lib.rs index 106590463..269a5c1d5 100644 --- a/crates/driver_virtio/src/lib.rs +++ b/crates/driver_virtio/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_virtio/src/net.rs b/crates/driver_virtio/src/net.rs index 8c7849ccd..3569738c1 100644 --- a/crates/driver_virtio/src/net.rs +++ b/crates/driver_virtio/src/net.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/driver_virtio/src/v9p.rs b/crates/driver_virtio/src/v9p.rs index 9d1c876a7..f5d227d16 100644 --- a/crates/driver_virtio/src/v9p.rs +++ b/crates/driver_virtio/src/v9p.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/dtb/Cargo.toml b/crates/dtb/Cargo.toml index 54e10b658..64f5e1cb7 100644 --- a/crates/dtb/Cargo.toml +++ b/crates/dtb/Cargo.toml @@ -5,10 +5,9 @@ edition = "2021" authors = ["Leping Wang "] description = "Device tree basic operations" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/crates/dtb" -documentation = "https://rcore-os.github.io/arceos/dtb/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/crates/dtb" [dependencies] fdt-rs = { version = "0.4.3", default-features = false } -lazy_init = { path = "../../crates/lazy_init" } \ No newline at end of file +lazy_init = { path = "../../crates/lazy_init" } diff --git a/crates/dw_apb_uart/src/lib.rs b/crates/dw_apb_uart/src/lib.rs index 99f06911b..c7a3e1d6c 100644 --- a/crates/dw_apb_uart/src/lib.rs +++ b/crates/dw_apb_uart/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/flatten_objects/src/lib.rs b/crates/flatten_objects/src/lib.rs index 74a5f0702..25760028a 100644 --- a/crates/flatten_objects/src/lib.rs +++ b/crates/flatten_objects/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/handler_table/src/lib.rs b/crates/handler_table/src/lib.rs index a3eb7af1b..efe992e53 100644 --- a/crates/handler_table/src/lib.rs +++ b/crates/handler_table/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/kernel_guard/src/arch/aarch64.rs b/crates/kernel_guard/src/arch/aarch64.rs index d7d89334b..d8fe72831 100644 --- a/crates/kernel_guard/src/arch/aarch64.rs +++ b/crates/kernel_guard/src/arch/aarch64.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/kernel_guard/src/arch/mod.rs b/crates/kernel_guard/src/arch/mod.rs index b88326d68..c88782965 100644 --- a/crates/kernel_guard/src/arch/mod.rs +++ b/crates/kernel_guard/src/arch/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/kernel_guard/src/arch/riscv.rs b/crates/kernel_guard/src/arch/riscv.rs index eecad89d5..c11f7e180 100644 --- a/crates/kernel_guard/src/arch/riscv.rs +++ b/crates/kernel_guard/src/arch/riscv.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/kernel_guard/src/arch/x86.rs b/crates/kernel_guard/src/arch/x86.rs index b33a542c2..272b2659a 100644 --- a/crates/kernel_guard/src/arch/x86.rs +++ b/crates/kernel_guard/src/arch/x86.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/kernel_guard/src/lib.rs b/crates/kernel_guard/src/lib.rs index fbbd43b20..ebe97c7ad 100644 --- a/crates/kernel_guard/src/lib.rs +++ b/crates/kernel_guard/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/lazy_init/src/lib.rs b/crates/lazy_init/src/lib.rs index a4b09e553..2aedfc277 100644 --- a/crates/lazy_init/src/lib.rs +++ b/crates/lazy_init/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/linked_list/src/lib.rs b/crates/linked_list/src/lib.rs index 19a4678cf..4172d6452 100644 --- a/crates/linked_list/src/lib.rs +++ b/crates/linked_list/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/linked_list/src/linked_list.rs b/crates/linked_list/src/linked_list.rs index 5eaf79b2c..1dc5c861c 100644 --- a/crates/linked_list/src/linked_list.rs +++ b/crates/linked_list/src/linked_list.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/linked_list/src/unsafe_list.rs b/crates/linked_list/src/unsafe_list.rs index d3c92e047..030156208 100644 --- a/crates/linked_list/src/unsafe_list.rs +++ b/crates/linked_list/src/unsafe_list.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/memory_addr/src/lib.rs b/crates/memory_addr/src/lib.rs index e2fae64ec..55646faf0 100644 --- a/crates/memory_addr/src/lib.rs +++ b/crates/memory_addr/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table/src/arch/aarch64.rs b/crates/page_table/src/arch/aarch64.rs index e2c71e070..e51e7ed03 100644 --- a/crates/page_table/src/arch/aarch64.rs +++ b/crates/page_table/src/arch/aarch64.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table/src/arch/mod.rs b/crates/page_table/src/arch/mod.rs index 18eddeaff..78c249522 100644 --- a/crates/page_table/src/arch/mod.rs +++ b/crates/page_table/src/arch/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table/src/arch/riscv.rs b/crates/page_table/src/arch/riscv.rs index db4f5cd01..2ddd90cfd 100644 --- a/crates/page_table/src/arch/riscv.rs +++ b/crates/page_table/src/arch/riscv.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table/src/arch/x86_64.rs b/crates/page_table/src/arch/x86_64.rs index dfa735f32..89eac0596 100644 --- a/crates/page_table/src/arch/x86_64.rs +++ b/crates/page_table/src/arch/x86_64.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table/src/bits64.rs b/crates/page_table/src/bits64.rs index 4de002008..8cd8ac896 100644 --- a/crates/page_table/src/bits64.rs +++ b/crates/page_table/src/bits64.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table/src/lib.rs b/crates/page_table/src/lib.rs index f5e95c45e..1ff711300 100644 --- a/crates/page_table/src/lib.rs +++ b/crates/page_table/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table_entry/src/arch/aarch64.rs b/crates/page_table_entry/src/arch/aarch64.rs index 5336ace80..da736d01e 100644 --- a/crates/page_table_entry/src/arch/aarch64.rs +++ b/crates/page_table_entry/src/arch/aarch64.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table_entry/src/arch/mod.rs b/crates/page_table_entry/src/arch/mod.rs index c48c80499..c8a40e9dd 100644 --- a/crates/page_table_entry/src/arch/mod.rs +++ b/crates/page_table_entry/src/arch/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table_entry/src/arch/riscv.rs b/crates/page_table_entry/src/arch/riscv.rs index 4848753a5..3c656ee70 100644 --- a/crates/page_table_entry/src/arch/riscv.rs +++ b/crates/page_table_entry/src/arch/riscv.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table_entry/src/arch/x86_64.rs b/crates/page_table_entry/src/arch/x86_64.rs index 1761f89a1..14b847623 100644 --- a/crates/page_table_entry/src/arch/x86_64.rs +++ b/crates/page_table_entry/src/arch/x86_64.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/page_table_entry/src/lib.rs b/crates/page_table_entry/src/lib.rs index f760286a9..20a6fe665 100644 --- a/crates/page_table_entry/src/lib.rs +++ b/crates/page_table_entry/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu/build.rs b/crates/percpu/build.rs index 89ff09cc3..926b4c3f5 100644 --- a/crates/percpu/build.rs +++ b/crates/percpu/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu/src/imp.rs b/crates/percpu/src/imp.rs index a29ac6429..aa7aeed99 100644 --- a/crates/percpu/src/imp.rs +++ b/crates/percpu/src/imp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu/src/lib.rs b/crates/percpu/src/lib.rs index 6bf478089..758582199 100644 --- a/crates/percpu/src/lib.rs +++ b/crates/percpu/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu/src/naive.rs b/crates/percpu/src/naive.rs index 4e4f00bd4..432a13321 100644 --- a/crates/percpu/src/naive.rs +++ b/crates/percpu/src/naive.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu/tests/test_percpu.rs b/crates/percpu/tests/test_percpu.rs index 57ec12ae5..c5832092e 100644 --- a/crates/percpu/tests/test_percpu.rs +++ b/crates/percpu/tests/test_percpu.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu_macros/src/arch.rs b/crates/percpu_macros/src/arch.rs index 742b0ac0a..89c9a97bc 100644 --- a/crates/percpu_macros/src/arch.rs +++ b/crates/percpu_macros/src/arch.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu_macros/src/lib.rs b/crates/percpu_macros/src/lib.rs index 0250d9352..e8ff57333 100644 --- a/crates/percpu_macros/src/lib.rs +++ b/crates/percpu_macros/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/percpu_macros/src/naive.rs b/crates/percpu_macros/src/naive.rs index 89bd27e7e..a8490d69e 100644 --- a/crates/percpu_macros/src/naive.rs +++ b/crates/percpu_macros/src/naive.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/ratio/src/lib.rs b/crates/ratio/src/lib.rs index 978db829d..5362c609b 100644 --- a/crates/ratio/src/lib.rs +++ b/crates/ratio/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/scheduler/src/cfs.rs b/crates/scheduler/src/cfs.rs index 92644ae3d..1ff2eee19 100644 --- a/crates/scheduler/src/cfs.rs +++ b/crates/scheduler/src/cfs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/scheduler/src/fifo.rs b/crates/scheduler/src/fifo.rs index cf502b925..02d5d34d0 100644 --- a/crates/scheduler/src/fifo.rs +++ b/crates/scheduler/src/fifo.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/scheduler/src/lib.rs b/crates/scheduler/src/lib.rs index 4350c07b2..2cd6000ec 100644 --- a/crates/scheduler/src/lib.rs +++ b/crates/scheduler/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/scheduler/src/round_robin.rs b/crates/scheduler/src/round_robin.rs index a8dd71e03..d0d5ff368 100644 --- a/crates/scheduler/src/round_robin.rs +++ b/crates/scheduler/src/round_robin.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/scheduler/src/tests.rs b/crates/scheduler/src/tests.rs index a798a3011..5f6047806 100644 --- a/crates/scheduler/src/tests.rs +++ b/crates/scheduler/src/tests.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/slab_allocator/src/lib.rs b/crates/slab_allocator/src/lib.rs index 61b35f40d..40752015a 100644 --- a/crates/slab_allocator/src/lib.rs +++ b/crates/slab_allocator/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/slab_allocator/src/slab.rs b/crates/slab_allocator/src/slab.rs index 1d85e535a..14a5d8c4e 100644 --- a/crates/slab_allocator/src/slab.rs +++ b/crates/slab_allocator/src/slab.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/slab_allocator/src/tests.rs b/crates/slab_allocator/src/tests.rs index c1daf1916..46c5faac5 100644 --- a/crates/slab_allocator/src/tests.rs +++ b/crates/slab_allocator/src/tests.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/spinlock/src/base.rs b/crates/spinlock/src/base.rs index 389a5534a..1dd6e5e3a 100644 --- a/crates/spinlock/src/base.rs +++ b/crates/spinlock/src/base.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/spinlock/src/lib.rs b/crates/spinlock/src/lib.rs index e7ff22f22..2ce00ebaf 100644 --- a/crates/spinlock/src/lib.rs +++ b/crates/spinlock/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/timer_list/src/lib.rs b/crates/timer_list/src/lib.rs index 33b083060..f23a0a092 100644 --- a/crates/timer_list/src/lib.rs +++ b/crates/timer_list/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/tuple_for_each/src/lib.rs b/crates/tuple_for_each/src/lib.rs index 6a8505ec7..ce9332aa5 100644 --- a/crates/tuple_for_each/src/lib.rs +++ b/crates/tuple_for_each/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/crates/tuple_for_each/tests/test_tuple_for_each.rs b/crates/tuple_for_each/tests/test_tuple_for_each.rs index f39c943a2..5e7df1c5e 100644 --- a/crates/tuple_for_each/tests/test_tuple_for_each.rs +++ b/crates/tuple_for_each/tests/test_tuple_for_each.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/doc/README.md b/doc/README.md index 40603ab39..5d0a93ca5 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,35 +1,37 @@ -# ArceOS Architecture Overview +# Ruxos Architecture Overview ## Rustdoc -* https://rcore-os.github.io/arceos/ +* https://github.com/syswonder/ruxos -## ArceOS Modules +## Ruxos Modules -* [axalloc](../modules/axalloc): ArceOS global memory allocator. -* [axconfig](../modules/axconfig): Platform-specific constants and parameters for ArceOS. -* [axdisplay](../modules/axdisplay): ArceOS graphics module. -* [axdriver](../modules/axdriver): ArceOS device drivers. -* [axfs](../modules/axfs): ArceOS filesystem module. -* [axhal](../modules/axhal): ArceOS hardware abstraction layer, provides unified APIs for platform-specific operations. -* [axlog](../modules/axlog): Macros for multi-level formatted logging used by ArceOS. -* [axnet](../modules/axnet): ArceOS network module. -* [axruntime](../modules/axruntime): Runtime library of ArceOS. -* [axsync](../modules/axsync): ArceOS synchronization primitives. -* [axtask](../modules/axtask): ArceOS task management module. +* [rux9p](../modules/rux9p/): 9pfs integration for Ruxos. +* [axalloc](../modules/axalloc): Ruxos global memory allocator. +* [ruxconfig](../modules/ruxconfig): Platform-specific constants and parameters for Ruxos. +* [ruxdisplay](../modules/ruxdisplay): Ruxos graphics module. +* [ruxdriver](../modules/ruxdriver): Ruxos device drivers. +* [ruxfs](../modules/ruxfs): Ruxos filesystem module. +* [ruxhal](../modules/ruxhal): Ruxos hardware abstraction layer, provides unified APIs for platform-specific operations. +* [axlog](../modules/axlog): Macros for multi-level formatted logging used by Ruxos. +* [axnet](../modules/axnet): Ruxos network module. +* [ruxruntime](../modules/ruxruntime): Runtime library of Ruxos. +* [axsync](../modules/axsync): Ruxos synchronization primitives. +* [ruxtask](../modules/ruxtask): Ruxos task management module. ## Crates * [allocator](../crates/allocator): Various allocator algorithms in a unified interface. * [arm_gic](../crates/arm_gic): ARM Generic Interrupt Controller (GIC) register definitions and basic operations. -* [axerrno](../crates/axerrno): Error code definition used by ArceOS. -* [axfs_devfs](../crates/axfs_devfs): Device filesystem used by ArceOS. -* [axfs_vfs](../crates/axfs_vfs): Virtual filesystem interfaces used by ArceOS. +* [axerrno](../crates/axerrno): Error code definition used by Ruxos. +* [axfs_devfs](../crates/axfs_devfs): Device filesystem used by Ruxos. +* [axfs_vfs](../crates/axfs_vfs): Virtual filesystem interfaces used by Ruxos. * [axio](../crates/axio): `std::io`-like I/O traits for `no_std` environment. * [capability](../crates/capability): Provide basic capability-based security. * [crate_interface](../crates/crate_interface): Provides a way to define an interface (trait) in a crate, but can implement or use it in any crate. [![Crates.io](https://img.shields.io/crates/v/crate_interface)](https://crates.io/crates/crate_interface) +* [driver_9p](../crates/driver_9p/): Basic 9pfs operation traits for 9p protocol drivers. * [driver_block](../crates/driver_block): Common traits and types for block storage drivers. -* [driver_common](../crates/driver_common): Device driver interfaces used by ArceOS. +* [driver_common](../crates/driver_common): Device driver interfaces used by Ruxos. * [driver_display](../crates/driver_display): Common traits and types for graphics device drivers. * [driver_net](../crates/driver_net): Common traits and types for network device (NIC) drivers. * [driver_pci](../crates/driver_pci): Structures and functions for PCI bus operations. @@ -58,25 +60,25 @@ | [helloworld](../apps/helloworld/) | | | A minimal app that just prints a string | | [exception](../apps/exception/) | | paging | Exception handling test | | [memtest](../apps/memtest/) | axalloc | alloc, paging | Dynamic memory allocation test | -| [display](../apps/display/) | axalloc, axdisplay | alloc, paging, display | Graphic/GUI test | -| [yield](../apps/task/yield/) | axalloc, axtask | alloc, paging, multitask, sched_fifo | Multi-threaded yielding test | -| [parallel](../apps/task/parallel/) | axalloc, axtask | alloc, paging, multitask, sched_fifo, irq | Parallel computing test (to test synchronization & mutex) | -| [sleep](../apps/task/sleep/) | axalloc, axtask | alloc, paging, multitask, sched_fifo, irq | Thread sleeping test | -| [priority](../apps/task/priority/) | axalloc, axtask | alloc, paging, multitask, sched_cfs | Thread priority test | -| [shell](../apps/fs/shell/) | axalloc, axdriver, axfs | alloc, paging, fs | A simple shell that responds to filesystem operations | -| [httpclient](../apps/net/httpclient/) | axalloc, axdriver, axnet | alloc, paging, net | A simple client that sends an HTTP request and then prints the response | -| [echoserver](../apps/net/echoserver/) | axalloc, axdriver, axnet, axtask | alloc, paging, net, multitask | A multi-threaded TCP server that reverses messages sent by the client | -| [httpserver](../apps/net/httpserver/) | axalloc, axdriver, axnet, axtask | alloc, paging, net, multitask | A multi-threaded HTTP server that serves a static web page | -| [udpserver](../apps/net/udpserver/) | axalloc, axdriver, axnet | alloc, paging, net | A simple echo server using UDP protocol | +| [display](../apps/display/) | axalloc, ruxdisplay | alloc, paging, display | Graphic/GUI test | +| [yield](../apps/task/yield/) | axalloc, ruxtask | alloc, paging, multitask, sched_fifo | Multi-threaded yielding test | +| [parallel](../apps/task/parallel/) | axalloc, ruxtask | alloc, paging, multitask, sched_fifo, irq | Parallel computing test (to test synchronization & mutex) | +| [sleep](../apps/task/sleep/) | axalloc, ruxtask | alloc, paging, multitask, sched_fifo, irq | Thread sleeping test | +| [priority](../apps/task/priority/) | axalloc, ruxtask | alloc, paging, multitask, sched_cfs | Thread priority test | +| [shell](../apps/fs/shell/) | axalloc, ruxdriver, ruxfs | alloc, paging, fs | A simple shell that responds to filesystem operations | +| [httpclient](../apps/net/httpclient/) | axalloc, ruxdriver, axnet | alloc, paging, net | A simple client that sends an HTTP request and then prints the response | +| [echoserver](../apps/net/echoserver/) | axalloc, ruxdriver, axnet, ruxtask | alloc, paging, net, multitask | A multi-threaded TCP server that reverses messages sent by the client | +| [httpserver](../apps/net/httpserver/) | axalloc, ruxdriver, axnet, ruxtask | alloc, paging, net, multitask | A multi-threaded HTTP server that serves a static web page | +| [udpserver](../apps/net/udpserver/) | axalloc, ruxdriver, axnet | alloc, paging, net | A simple echo server using UDP protocol | ## Applications (C) | App | Extra modules | Enabled features | Description | |-|-|-|-| | [helloworld](../apps/c/helloworld/) | | | A minimal C app that just prints a string | | [memtest](../apps/c/memtest/) | axalloc | alloc, paging | Dynamic memory allocation test in C | -| [sqlite3](../apps/c/sqlite3/) | axalloc, axdriver, axfs | alloc, paging, fp_simd, fs | Porting of [SQLite3](https://sqlite.org/index.html) | -| [iperf](../apps/c/iperf/) | axalloc, axdriver, axfs, axnet | alloc, paging, fp_simd, fs, net, select | Porting of [iPerf3](https://iperf.fr/) | -| [redis](../apps/c/redis/) | axalloc, axdriver, axtask, axfs, axnet | alloc, paging, fp_simd, irq, multitask, fs, net, pipe, epoll | Porting of [Redis](https://redis.io/) | +| [sqlite3](../apps/c/sqlite3/) | axalloc, ruxdriver, ruxfs | alloc, paging, fp_simd, fs | Porting of [SQLite3](https://sqlite.org/index.html) | +| [iperf](../apps/c/iperf/) | axalloc, ruxdriver, ruxfs, axnet | alloc, paging, fp_simd, fs, net, select | Porting of [iPerf3](https://iperf.fr/) | +| [redis](../apps/c/redis/) | axalloc, ruxdriver, ruxtask, ruxfs, axnet | alloc, paging, fp_simd, irq, multitask, fs, net, pipe, epoll | Porting of [Redis](https://redis.io/) | ## Dependencies @@ -86,7 +88,7 @@ subgraph "User Apps" A["Rust App"] C["C App"] end -subgraph "ArceOS ulib" +subgraph "Ruxos ulib" B["rust_libax"] D["c_libax"] E("rust_std") @@ -105,18 +107,18 @@ H("linux") end B --> G; F --> H; -subgraph "ArceOS modules" -I[axruntime] +subgraph "Ruxos modules" +I[ruxruntime] J[axlog] K[axsync] -L[axhal] -M[axconfig] +L[ruxhal] +M[ruxconfig] N[axalloc] -O[axtask] -P[axdriver] +O[ruxtask] +P[ruxdriver] Q[axnet] -Q1[axdisplay] -M1[axfs] +Q1[ruxdisplay] +M1[ruxfs] end G --> I; H --> I; @@ -194,7 +196,7 @@ M1 --> F1; M1 --> F2; M1 --> P; M1 --> K; -subgraph "ArceOS crates" +subgraph "Ruxos crates" R[allocator] IN12[arm_gic] IN13[axerrno] diff --git a/doc/apps_display.md b/doc/apps_display.md deleted file mode 100644 index c4f04e980..000000000 --- a/doc/apps_display.md +++ /dev/null @@ -1,106 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [display](../apps/display/) | embedded-graphics, axdisplay, axdriver | alloc, paging, display | Display some graphics in a new window | - -# RUN - -```bash -make A=apps/display GRAPHIC=y LOG=debug run -``` - -# RESULT - -```text -... -[ 0.408067 axdriver:59] Initialize device drivers... -[ 0.410941 driver_virtio:50] Detected virtio MMIO device with vendor id: 0x554D4551, device type: GPU, version: Legacy -[ 0.414473 virtio_drivers::device::gpu:47] Device features EDID | NOTIFY_ON_EMPTY | ANY_LAYOUT | RING_INDIRECT_DESC | RING_EVENT_IDX -[ 0.418886 virtio_drivers::device::gpu:57] events_read: 0x0, num_scanouts: 0x1 -[ 0.423408 virtio_drivers::device::gpu:102] => RespDisplayInfo { header: CtrlHeader { hdr_type: Command(4353), flags: 0, fence_id: 0, ctx_id: 0, _padding: 0 }, rect: Rect { x: 0, y: 0, width: 1280, height: 800 }, enabled: 1, flags: 0 } -[ 0.452037 axdriver::virtio:88] created a new Display device: "virtio-gpu" -[ 0.455473 axdisplay:17] Initialize Display subsystem... -[ 0.458124 axdisplay:19] number of Displays: 1 -... -... -... -(never end) -``` -![display](figures/display.png) - -# STEPS - -## step1 - -``` rust -let mut board = DrawingBoard::new(); -board.disp.clear(Rgb888::BLACK).unwrap(); -``` - -**flow chart** -```mermaid -graph TD; - A["DrawingBoard::new()"] --> B["display::Display::new()"]; - A --> C["embedded_graphics::prelude::Point::new(INIT_X, INIT_Y)"]; - B --> D["libax::display::framebuffer_info"] - B --> E["core::slice::from_raw_parts_mut"] - B --> F["embedded_graphics::prelude::Size::new"] - D --> G["axsync::Mutex(axdriver::DisplayDevices)::lock"] - D --> H["axdriver::DisplayDevices::info"] -``` - -## step2 -``` rust -for _ in 0..5 { - board.latest_pos.x += RECT_SIZE as i32 + 20; - board.paint(); - framebuffer_flush(); - } -... -impl DrawingBoard { - ... - fn paint(&mut self) { - Rectangle::with_center(self.latest_pos, Size::new(RECT_SIZE, RECT_SIZE)) - .into_styled(PrimitiveStyle::with_stroke(Rgb888::RED, 10)) - .draw(&mut self.disp) - .ok(); - Circle::new(self.latest_pos + Point::new(-70, -300), 150) - .into_styled(PrimitiveStyle::with_fill(Rgb888::BLUE)) - .draw(&mut self.disp) - .ok(); - Triangle::new( - self.latest_pos + Point::new(0, 150), - self.latest_pos + Point::new(80, 200), - self.latest_pos + Point::new(-120, 300), - ) - .into_styled(PrimitiveStyle::with_stroke(Rgb888::GREEN, 10)) - .draw(&mut self.disp) - .ok(); - let text = "ArceOS"; - Text::with_alignment( - text, - self.latest_pos + Point::new(0, 300), - MonoTextStyle::new(&FONT_10X20, Rgb888::YELLOW), - Alignment::Center, - ) - .draw(&mut self.disp) - .ok(); - } -} -``` - -**flow chart** -```mermaid -graph TD; - A["DrawingBoard::paint"] --> B["embedded_graphics::primitives::{Circle, PrimitiveStyle, Rectangle, Triangle}"]; - A --> C["embedded_graphics::text::{Alignment, Text}"] - B --> D["impl embedded_graphics::draw_target::DrawTarget, embedded_graphics::prelude::OriginDimensions for Display"] - C --> D -``` - -## step3 -``` rust -loop { - core::hint::spin_loop(); -} -``` diff --git a/doc/apps_echoserver.md b/doc/apps_echoserver.md deleted file mode 100644 index 10b327a6b..000000000 --- a/doc/apps_echoserver.md +++ /dev/null @@ -1,106 +0,0 @@ -# INTRODUCTION - -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [echoserver](../apps/net/echoserver/) | axalloc, axdriver, axnet, axtask | alloc, paging, net, multitask | A multi-threaded TCP server that reverses messages sent by the client | - -# RUN - -```console -$ make A=apps/net/echoserver NET=y run -... -Hello, echo server! -listen on: 10.0.2.15:5555 -``` - -In another shell, use `telnet` (or `nc`) to connect to localhost (`127.0.0.1`) to view the reversed echo message: - -```console -$ telnet localhost 5555 -Trying 127.0.0.1... -Connected to localhost. -Escape character is '^]'. -hello -olleh -12345 -54321 -``` - -```console -$ nc 127.0.0.1 5555 -hello -olleh -12345 -54321 -``` - -# STEPS - -## step1 - -[init](./init.md) - -After executed all initial actions, then arceos calls `main` function in `echoserver` app. - -## step2 - -`main` calls `accept_loop()`, which will keep processing incoming tcp connection. - -```rust -let (addr, port) = (IpAddr::from_str(LOCAL_IP).unwrap(), LOCAL_PORT); -let mut listener = TcpListener::bind((addr, port).into())?; -println!("listen on: {}", listener.local_addr().unwrap()); - -let mut i = 0; -loop { - match listener.accept() { - ... - } - Err(e) => return Err(e), - } - i += 1; -} -``` - -## step3 - -Once it receives a tcp connection. It will get a `(stream, addr)` pair from `libax::net`. -`main` task will spawn a task to reverse every package it receives. - -```rust -Ok((stream, addr)) => { - info!("new client {}: {}", i, addr); - task::spawn(move || match echo_server(stream) { - Err(e) => error!("client connection error: {:?}", e), - Ok(()) => info!("client {} closed successfully", i), - }); -} -``` - -## step4 - -Reverse bytes in package it receives. - -```rust -fn reverse(buf: &[u8]) -> Vec { - let mut lines = buf - .split(|&b| b == b'\n') - .map(Vec::from) - .collect::>(); - for line in lines.iter_mut() { - line.reverse(); - } - lines.join(&b'\n') -} - -fn echo_server(mut stream: TcpStream) -> io::Result { - let mut buf = [0u8; 1024]; - loop { - let n = stream.read(&mut buf)?; - if n == 0 { - return Ok(()); - } - stream.write_all(reverse(&buf[..n]).as_slice())?; - } -} -``` diff --git a/doc/apps_exception.md b/doc/apps_exception.md deleted file mode 100644 index a9f59e321..000000000 --- a/doc/apps_exception.md +++ /dev/null @@ -1,66 +0,0 @@ -# INTRODUCTION - -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [exception](../apps/exception/) | | paging | Exception handling test | - -# RUN - -```console -$ make A=apps/exception LOG=debug run -... -Running exception tests... -[ 0.249873 0 axhal::arch::riscv::trap:13] Exception(Breakpoint) @ 0xffffffc0802001e8 -Exception tests run OK! -[ 0.068358 0 axtask::api:6] main task exited: exit_code=0 -[ 0.069128 0 axhal::platform::qemu_virt_riscv::misc:2] Shutting down... -``` - -# STEPS - -## step1 - -[init](./init.md) - -After executed all initial actions, then arceos calls `main` function in `exception` app. - -## step2 - -``` Rust -fn raise_break_exception() { - unsafe { - #[cfg(target_arch = "x86_64")] - asm!("int3"); - #[cfg(target_arch = "aarch64")] - asm!("brk #0"); - #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] - asm!("ebreak"); - } -} - -#[no_mangle] -fn main() { - println!("Running exception tests..."); - raise_break_exception(); - println!("Exception tests run OK!"); -} -``` - -**flow chart** - -```mermaid -graph TD; - A[" asm!(ebreak)"] --> B["raise exception"]; - B --> C["axhal::arch::riscv::trap.S::trap_vector_base"]; - C --> D["switch sscratch and sp"]; - C -- "from U mode" --> E["Ltrap_entry_u: SAVE_REGS 1; a1 <-- 1"]; - C -- "from S mode" --> F["Ltrap_entry_s: SAVE_REGS 0; a1 <-- 0"]; - E --> G[axhal::arch::riscv::trap::riscv_trap_handler]; - F --> G; - G -- "Trap::Exception(E::Breakpoint)" --> H["handle_breakpoint(&mut tf.sepc)"]; - H --> I["debug!(Exception(Breakpoint) @ {:#x} , sepc);*sepc += 2;"]; - I -- "from U mode" --> J["Ltrap_entry_u: RESTORE_REGS 1"]; - I -- "from S mode" --> K["Ltrap_entry_s: RESTORE_REGS 0"]; - J --> L[sret]; - K --> L; -``` diff --git a/doc/apps_fs_shell.md b/doc/apps_fs_shell.md index 251bec1b2..5442a9d61 100644 --- a/doc/apps_fs_shell.md +++ b/doc/apps_fs_shell.md @@ -2,7 +2,7 @@ | App | Extra modules | Enabled features | Description | |-|-|-|-| -| [shell](../apps/fs/shell/) | axalloc, axdriver, axfs | alloc, paging, fs | A simple shell that responds to filesystem operations | +| [shell](../apps/fs/shell/) | axalloc, ruxdriver, ruxfs | alloc, paging, fs | A simple shell that responds to filesystem operations | # RUN @@ -22,21 +22,21 @@ make A=apps/fs/shell ARCH=aarch64 LOG=debug BLK=y run ``` ... -[ 0.006204 0 axdriver:64] Initialize device drivers... +[ 0.006204 0 ruxdriver:64] Initialize device drivers... [ 0.006396 0 driver_virtio:50] Detected virtio MMIO device with vendor id: 0x554D4551, device type: Block, version: Legacy [ 0.006614 0 virtio_drivers::device::blk:55] device features: SEG_MAX | GEOMETRY | BLK_SIZE | SCSI | FLUSH | TOPOLOGY | CONFIG_WCE | DISCARD | WRITE_ZEROES | NOTIFY_ON_EMPTY | RING_INDIRECT_DESC | RING_EVENT_IDX [ 0.007094 0 virtio_drivers::device::blk:64] config: 0xffff00000a003f00 [ 0.007270 0 virtio_drivers::device::blk:69] found a block device of size 34000KB -[ 0.007956 0 axdriver::virtio:88] created a new Block device: "virtio-blk" -[ 0.008488 0 axfs:25] Initialize filesystems... -[ 0.008584 0 axfs:26] use block device: "virtio-blk" +[ 0.007956 0 ruxdriver::virtio:88] created a new Block device: "virtio-blk" +[ 0.008488 0 ruxfs:25] Initialize filesystems... +[ 0.008584 0 ruxfs:26] use block device: "virtio-blk" [ 0.025432 0 axalloc:57] expand heap memory: [0xffff00004012f000, 0xffff00004013f000) [ 0.025680 0 axalloc:57] expand heap memory: [0xffff00004013f000, 0xffff00004015f000) -[ 0.026510 0 axfs::fs::fatfs:122] create Dir at fatfs: /dev -[ 0.043112 0 axfs::fs::fatfs:102] lookup at fatfs: /dev +[ 0.026510 0 ruxfs::fs::fatfs:122] create Dir at fatfs: /dev +[ 0.043112 0 ruxfs::fs::fatfs:102] lookup at fatfs: /dev [ 0.049562 0 fatfs::dir:140] Is a directory -[ 0.057550 0 axruntime:137] Initialize interrupt handlers... -[ 0.057870 0 axruntime:143] Primary CPU 0 init OK. +[ 0.057550 0 ruxruntime:137] Initialize interrupt handlers... +[ 0.057870 0 ruxruntime:143] Primary CPU 0 init OK. Available commands: cat cd @@ -48,7 +48,7 @@ Available commands: pwd rm uname -arceos:/$ +Ruxos:/$ ``` # STEPS @@ -57,7 +57,7 @@ arceos:/$ [init](./init.md) -After executed all initial actions, then arceos calls `main` function in `shell` app. +After executed all initial actions, then Ruxos calls `main` function in `shell` app. ## Step2 @@ -196,18 +196,18 @@ graph TD lib_create[libax::fs::File::create] --> |WRITE/CREATE/TRUNCATE| open_opt lib_open[libax::fs::File::open] --> |READ ONLY| open_opt lib_meta[libax::fs::metadata] --> lib_open1[libax::fs::File::open] --> |READ ONLY| open_opt - lib_meta --> f_meta[axfs::fops::File::get_attr] --> vfs_getattr + lib_meta --> f_meta[ruxfs::fops::File::get_attr] --> vfs_getattr lib_meta -..-> |not found/permission denied| err(Return error) - open_opt["axfs::api::file::OpenOptions::open"] --> fops_open + open_opt["ruxfs::api::file::OpenOptions::open"] --> fops_open - fops_open["axfs::fops::File::open"] --> fops_openat - fops_openat["axfs::fops::File::_open_at"] + fops_open["ruxfs::fops::File::open"] --> fops_openat + fops_openat["ruxfs::fops::File::_open_at"] fops_openat --> lookup fops_openat --> |w/ CREATE flag| create_file fops_openat --> vfs_getattr - lookup["axfs::root::lookup"] --> vfs_lookup - create_file["axfs::root::create_file"] + lookup["ruxfs::root::lookup"] --> vfs_lookup + create_file["ruxfs::root::create_file"] create_file --> vfs_lookup create_file --> vfs_create create_file --> vfs_truncate @@ -227,8 +227,8 @@ graph TD ```mermaid graph TD - lib_mkdir[libax::fs::create_dir] --> builder_create["axfs::api::DirBuilder::create"] - builder_create --> root_create[axfs::root::create_dir] --> lookup[axfs::root::lookup] + lib_mkdir[libax::fs::create_dir] --> builder_create["ruxfs::api::DirBuilder::create"] + builder_create --> root_create[ruxfs::root::create_dir] --> lookup[ruxfs::root::lookup] lookup -..-> |exists/other error| err(Return error) root_create -->|type=VfsNodeType::Dir| node_create[axfs_vfs::VfsNodeOps::create] --> fs_impl[[FS implementation]] @@ -242,11 +242,11 @@ graph TD ```mermaid graph LR lib_read[libax::fs::File::read] --> fops_read - fops_read[axfs::fops::File::read] ---> |w/ read permission| vfs_read_at + fops_read[ruxfs::fops::File::read] ---> |w/ read permission| vfs_read_at vfs_read_at[axfs_vfs::VfsNodeOps::read] --> fs_impl[[FS implementation]] lib_write[libax::fs::File::write] --> fops_write - fops_write[axfs::fops::File::write] ---> |w/ write permission| vfs_write_at + fops_write[ruxfs::fops::File::write] ---> |w/ write permission| vfs_write_at vfs_write_at[axfs_vfs::VfsNodeOps::write] --> fs_impl[[FS implementation]] fops_read -.-> |else| err1(Return error) @@ -257,7 +257,7 @@ graph LR ```mermaid graph LR - lib_gwd[libax::fs::current_dir] --> root_gwd[axfs::root::current_dir] + lib_gwd[libax::fs::current_dir] --> root_gwd[ruxfs::root::current_dir] lib_gwd -.-> return("Return path") ``` @@ -265,10 +265,10 @@ graph LR ```mermaid graph TD - lib_cd[libax::fs::set_current_dir] --> root_cd[axfs::root::set_current_dir] + lib_cd[libax::fs::set_current_dir] --> root_cd[ruxfs::root::set_current_dir] root_cd -..-> |is root| change[Set CURRENT_DIR and CURRENT_DIR_PATH] - root_cd --> |else| lookup["axfs::root::lookup"] + root_cd --> |else| lookup["ruxfs::root::lookup"] vfs_lookup["axfs_vfs::VfsNodeOps::lookup"] lookup --> vfs_lookup --> fs_impl[[FS implementation]] @@ -280,11 +280,11 @@ graph TD ```mermaid graph TD - lib_rmdir[libax::fs::remove_dir] --> root_rmdir[axfs::root::remove_dir] + lib_rmdir[libax::fs::remove_dir] --> root_rmdir[ruxfs::root::remove_dir] root_rmdir -.-> |empty/is root/invalid/permission denied| ret_err(Return error) - root_rmdir --> lookup[axfs::root::lookup] --> vfs_lookup["axfs_vfs::VfsNodeOps::lookup"] ---> fs_impl[[FS implementation]] + root_rmdir --> lookup[ruxfs::root::lookup] --> vfs_lookup["axfs_vfs::VfsNodeOps::lookup"] ---> fs_impl[[FS implementation]] lookup -...-> |not found| ret_err root_rmdir --> meta[axfs_vfs::VfsNodeOps::get_attr] --> fs_impl @@ -298,9 +298,9 @@ graph TD ```mermaid graph TD - lib_rm[libax::fs::remove_file] --> root_rm[axfs::root::remove_file] + lib_rm[libax::fs::remove_file] --> root_rm[ruxfs::root::remove_file] - root_rm --> lookup[axfs::root::lookup] --> vfs_lookup["axfs_vfs::VfsNodeOps::lookup"] + root_rm --> lookup[ruxfs::root::lookup] --> vfs_lookup["axfs_vfs::VfsNodeOps::lookup"] ---> fs_impl[[FS implementation]] lookup -.-> |not found| ret_err root_rm ---> meta[axfs_vfs::VfsNodeOps::get_attr] ---> fs_impl diff --git a/doc/apps_helloworld.md b/doc/apps_helloworld.md deleted file mode 100644 index 502ccfd64..000000000 --- a/doc/apps_helloworld.md +++ /dev/null @@ -1,59 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [helloworld](../apps/helloworld/) | | | A minimal app that just prints a string | - -# RUN - -```shell -make A=apps/helloworld SMP=4 LOG=debug run -``` - -# STEPS - -## step1 -[init](./init.md) - -After executed all initial actions, then arceos calls `main` function in `helloworld` app. - -## step2 - -```Rust -fn main() { - libax::println!("Hello, world!"); -} -``` - -**flow chart** - -```mermaid -graph TD; - A[main] --> B["libax::println!(Hello, world!)"]; - B --> C[libax:io::__print_impl]; - C --> D[INLINE_LOCK=Mutex::new]; - C --> _guard=INLINE_LOCK.lock; - C --> E["stdout().write_fmt(args)"]; -``` - -### step2.1 - -```mermaid -graph TD; - T["stdout()"] --> A["libax::io::stdio.rs::stdout()"]; - A --> B["INSTANCE: Mutex = Mutex::new(StdoutRaw)"]; - A --> C["return Stdout { inner: &INSTANCE }"]; -``` - -### step2.2 - -```mermaid -graph TD; - T["stdout().write_fmt(args)"] --> A["Stdout::write"]; - A --> B["self.inner.lock().write(buf)"]; - B --> C["StdoutRaw::write"]; - C --> D["axhal::console::write_bytes(buf);"]; - C --> E["Ok(buf.len())"]; - D --> F["putchar"]; - F --> G["axhal::platform::qemu_virt_riscv::console::putchar"]; - G --> H["sbi_rt::legacy::console_putchar"]; -``` diff --git a/doc/apps_httpserver.md b/doc/apps_httpserver.md deleted file mode 100644 index 8a2841bdc..000000000 --- a/doc/apps_httpserver.md +++ /dev/null @@ -1,177 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [httpserver](../apps/net/httpserver) | axalloc, axnet, axdriver, axtask | alloc, paging, net, multitask | A multi-threaded HTTP server that serves a static web page | - -# RUN - -```shell -make A=apps/net/httpserver SMP=4 NET=y LOG=info run -``` - -# RESULT - -``` -... -[ 0.101078 axtask:75] use FIFO scheduler. -[ 0.102733 axdriver:59] Initialize device drivers... -[ 0.104475 driver_virtio:50] Detected virtio MMIO device with vendor id: 0x554D4551, device type: Network, version: Legacy -[ 0.107095 virtio_drivers::device::net:117] Device features CTRL_GUEST_OFFLOADS | MAC | GSO | MRG_RXBUF | STATUS | CTRL_VQ | CTRL_RX | CTRL_VLAN | CTRL_RX_EXTRA | GUEST_ANNOUNCE | CTL_MAC_ADDR | RING_INDIRECT_DESC | RING_EVENT_IDX -[ 0.113234 virtio_drivers::device::net:127] Got MAC=[52, 54, 00, 12, 34, 56], status=LINK_UP -[ 0.116326 axdriver::virtio:88] created a new Net device: "virtio-net" -[ 0.118063 axnet:22] Initialize network subsystem... -[ 0.119247 axnet:24] number of NICs: 1 -[ 0.120442 axnet:27] NIC 0: "virtio-net" -[ 0.121819 axalloc:57] expand heap memory: [0xffffffc080654000, 0xffffffc080a54000) -[ 0.124142 axalloc:57] expand heap memory: [0xffffffc080a54000, 0xffffffc081254000) -[ 0.127314 axnet::smoltcp_impl:273] created net interface "eth0": -[ 0.128951 axnet::smoltcp_impl:275] ether: 52-54-00-12-34-56 -[ 0.130706 axnet::smoltcp_impl:277] ip: 10.0.2.15/24 -[ 0.132189 axnet::smoltcp_impl:278] gateway: 10.0.2.2 -[ 0.133746 axruntime:134] Initialize interrupt handlers... -... -Hello, ArceOS HTTP server! -... -[ 0.148419 0:2 axnet::smoltcp_impl:67] socket #0: created -[ 0.148850 0:2 axnet::smoltcp_impl::tcp:111] socket listening on 10.0.2.15:5555 -[ 0.149305 0:2 axnet::smoltcp_impl:95] socket #0: destroyed -listen on: http://10.0.2.15:5555/ -``` - -Open http://127.0.0.1:5555/ in your browser, or use command lines in another shell to view the web page: - -```console -$ curl http://127.0.0.1:5555/ - - - Hello, ArceOS - - -
-

Hello, ArceOS

-
-
-
- Powered by ArceOS example HTTP server v0.1.0 -
- - -``` - -# STEPS - -## step 1 -[init](./init.md) - -After executed all initial actions, then arceos calls `main` function in `memtest` app. - -## step 2 -```Rust -fn http_server(mut stream: TcpStream) -> io::Result { - ... - stream.read(&mut buf)?; - ... - stream.write_all(reponse.as_bytes())?; - ... -} - -fn accept_loop() -> io::Result { - let (addr, port) = (IpAddr::from_str(LOCAL_IP).unwrap(), LOCAL_PORT); - let mut listener = TcpListener::bind((addr, port).into())?; - ... - loop { - match listener.accept() { - Ok((stream, addr)) => { - task::spawn(move || match http_server(stream) { - Err(e) => error!("client connection error: {:?}", e), - Ok(()) => info!("client {} closed successfully", i), - }); - } - Err(e) => return Err(e), - } - i += 1; - } -} - -#[no_mangle] -fn main() { - println!("Hello, ArceOS HTTP server!"); - accept_loop().expect("test HTTP server failed"); -} -``` - -### step 2.1 - -```Rust -let (addr, port) = (IpAddr::from_str(LOCAL_IP).unwrap(), LOCAL_PORT); -let mut listener = TcpListener::bind((addr, port).into())?; -``` - -**flow chart** - -```mermaid -graph TD; -T["libax::net::tcp::TcpStream::bind()"] -T-->A["smoltcp::wire::ip::IpAddr::from_str()"] -T-->B["axnet::smoltcp_impl::tcp::TcpSocket::new()"] -T-->C["axnet::smoltcp_impl::tcp::TcpSocket::bind()"] -T-->D["axnet::smoltcp_impl::tcp::TcpSocket::listen()"] -B-->E["axnet::smoltcp_impl::SocketSetWrapper::new_tcp_socket()"] -E-->F["axsync::mutex< smoltcp::iface::socket_set::SocketSet >"] -F-->G["managed::slice::ManagedSlice< smoltcp::iface::socket_set::SocketStorage >"] -G-->H["smoltcp::iface::socket_meta::Meta + smoltcp::socket::Socket"] -H-->I["SocketHandle + NeighborState"] -H-->J["Raw + Icmp + udp + tcp"] - -D-->K["ListenTable: Box< [Mutex< Option< Box< ListenTableEntry > > >] >(tcp)"] -K-->L["ListenTableEntry: VecDeque< SocketHandle >(syn_queue)"] -L-->M["Tcp is a multi-wrapped sync queue of SocketHandle"] -``` - -### step 2.2 - -```Rust -match listener.accept() { - Ok((stream, addr)) => { - ... - } - Err(e) => return Err(e), -} -``` - -**flow chart** - -```mermaid -graph TD; -T["libax::net::tcp::TcpListener::accept()"] -T-->A["axnet::smoltcp_impl::tcp::TcpSocket::accept()"] -A-->B["Mutex< SocketSet >.poll_interfaces()"] -B-->C["axnet::smoltcp_impl::InterfaceWrapper< axdriver::VirtIoNetDev >.poll"] -C-->Z["many things"] -A-->D["axnet::smoltcp_impl::listen_table::ListenTable::accept()"] -D-->E["check the sync queue"] - -``` - - - - - -### step 2.3 - -```Rust -stream.read(&mut buf)?; -stream.write_all(reponse.as_bytes())?; -``` - -**flow chart** - -```mermaid -graph TD; - A["impl Read, Write for libax::TcpStream"] --> B["libax::TcpStream::read"] - A["impl Read, Write for libax::TcpStream"] --> C["libax::TcpStream::write"] - B --> D["smoltcp_impl::TcpSocket::recv(buf)"] - C --> E["smoltcp_impl::TcpSocket::send(buf)"] - -``` - diff --git a/doc/apps_memtest.md b/doc/apps_memtest.md deleted file mode 100644 index 86be3bb5a..000000000 --- a/doc/apps_memtest.md +++ /dev/null @@ -1,55 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [memtest](../apps/memtest/) | axalloc | alloc, paging | Dynamic memory allocation test | - -# RUN - -```console -$ make A=apps/memtest SMP=4 LOG=info run -... -Running memory tests... -test_vec() OK! -test_btree_map() OK! -Memory tests run OK! -[ 0.523323 3 axhal::platform::qemu_virt_riscv::misc:2] Shutting down... -... -``` - -# STEPS - -## step1 - -[init](./init.md) - -After executed all initial actions, then arceos calls `main` function in `memtest` app. - -## step2 -```Rust -fn test_vec() { -... - let mut v = Vec::with_capacity(N); -... -} -fn test_btree_map() { -... - let mut m = BTreeMap::new(); -... -} -fn main() { - println!("Running memory tests..."); - test_vec(); - test_btree_map(); - println!("Memory tests run OK!"); -} -``` - -**flow chart** - -```mermaid -graph TD; -A["rust.alloc runtime"] --> B["impl GlobalAlloc for axalloc::GlobalAllocator alloc()"]; -B --> C["axalloc::GlobalAllocator::alloc()"]; -C --> D["simple two-level allocator: if no heap memory, allocate from the page allocator"]; - -``` diff --git a/doc/apps_net-httpclient.md b/doc/apps_net-httpclient.md deleted file mode 100644 index 3100406a2..000000000 --- a/doc/apps_net-httpclient.md +++ /dev/null @@ -1,88 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [httpclient](../apps/net/httpclient/) | axalloc, axdriver, axnet | alloc, paging, net | A simple client that sends an HTTP request and then prints the response | - -# RUN -```bash -make A=apps/net/httpclient SMP=1 NET=y LOG=debug run -``` - -# RESULT -```text -... -[ 0.065494 0 axalloc:128] initialize global allocator at: [0xffffffc080286000, 0xffffffc088000000) -[ 0.068109 0 axruntime:115] Initialize kernel page table... -[ 0.070549 0 axdriver:59] Initialize device drivers... -[ 0.072131 0 driver_virtio:50] Detected virtio MMIO device with vendor id: 0x554D4551, device type: Network, version: Legacy -[ 0.074003 0 virtio_drivers::device::net:117] Device features CTRL_GUEST_OFFLOADS | MAC | GSO | MRG_RXBUF | STATUS | CTRL_VQ | CTRL_RX | CTRL_VLAN | CTRL_RX_EXTRA | GUEST_ANNOUNCE | CTL_MAC_ADDR | RING_INDIRECT_DESC | RING_EVENT_IDX -[ 0.077999 0 virtio_drivers::device::net:127] Got MAC=[52, 54, 00, 12, 34, 56], status=LINK_UP -[ 0.080748 0 axalloc:57] expand heap memory: [0xffffffc080298000, 0xffffffc0802a8000) -[ 0.082357 0 axalloc:57] expand heap memory: [0xffffffc0802a8000, 0xffffffc0802c8000) -[ 0.083769 0 axalloc:57] expand heap memory: [0xffffffc0802c8000, 0xffffffc080308000) -[ 0.085864 0 axdriver::virtio:88] created a new Net device: "virtio-net" -[ 0.087057 0 axnet:22] Initialize network subsystem... -[ 0.087859 0 axnet:24] number of NICs: 1 -[ 0.088517 0 axnet:27] NIC 0: "virtio-net" -[ 0.089360 0 axalloc:57] expand heap memory: [0xffffffc080308000, 0xffffffc080408000) -[ 0.092033 0 axnet::smoltcp_impl:273] created net interface "eth0": -[ 0.093315 0 axnet::smoltcp_impl:275] ether: 52-54-00-12-34-56 -[ 0.094667 0 axnet::smoltcp_impl:277] ip: 10.0.2.15/24 -[ 0.095947 0 axnet::smoltcp_impl:278] gateway: 10.0.2.2 -[ 0.097154 0 axruntime:134] Initialize interrupt handlers... -[ 0.098892 0 axruntime:140] Primary CPU 0 init OK. -Hello, simple http client! -[ 0.100960 0 axnet::smoltcp_impl:67] socket #0: created -[ 0.103106 0 smoltcp::iface::interface:1599] address 10.0.2.2 not in neighbor cache, sending ARP request -HTTP/1.1 200 OK -Server: nginx -Date: Sat, 08 Apr 2023 18:58:27 GMT -Content-Type: text/plain -Content-Length: 13 -Connection: keep-alive -Access-Control-Allow-Origin: * -Cache-Control: no-cache, no-store, must-revalidate - -183.172.74.58 -[ 0.585681 0 axnet::smoltcp_impl::tcp:148] socket #0: shutting down -[ 0.587517 0 axnet::smoltcp_impl:95] socket #0: destroyed -... -``` - -# STEPS - -## step1 -``` rust -let (addr, port) = (IpAddr::from_str(DEST_IP).unwrap(), 80); -let mut stream = TcpStream::connect((addr, port).into())?; -``` - -**flow chart** -```mermaid -graph TD; - A["libax::tcp::TcpStream::connect"] --> B["smoltcp::wire::IpEndpoint::From(addr, port)"] - A --> C["axnet::smoltcp_impl::TcpSocket::new"] - A --> D["axnet::smoltcp_impl::TcpSocket::connect(addr)"] - C --> E["axsync::Mutex(smoltcp::iface::SocketSet)::new"] -``` - -## step2 -``` rust -stream.write(REQUEST.as_bytes())?; - -let mut buf = [0; 1024]; -let n = stream.read(&mut buf)?; -let response = core::str::from_utf8(&buf[..n]).unwrap(); -println!("{}", response); -``` - -**flow chart** -```mermaid -graph TD; - A["impl Read, Write for libax::TcpStream"] --> B["libax::TcpStream::read"] - A["impl Read, Write for libax::TcpStream"] --> C["libax::TcpStream::write"] - B --> D["smoltcp_impl::TcpSocket::recv(buf)"] - C --> E["smoltcp_impl::TcpSocket::send(buf)"] - D --> F["libax::println"] - E --> F -``` diff --git a/doc/apps_parallel.md b/doc/apps_parallel.md deleted file mode 100644 index 7dde8d5c2..000000000 --- a/doc/apps_parallel.md +++ /dev/null @@ -1,184 +0,0 @@ -# INTRODUCTION - -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [parallel](../apps/task/parallel/) | axalloc, axtask | alloc, paging, multitask, sched_fifo | Parallel computing test (to test synchronization & mutex) | - -# RUN - -## Without preemption (FIFO scheduler) - -```shell -make A=apps/task/parallel LOG=info run -``` - -## With preemption (RR scheduler) - -```shell -make A=apps/task/parallel LOG=info APP_FEATURES=preempt run -``` - -## Using multicore - -```shell -make A=apps/task/parallel LOG=info SMP=4 run -``` - -# RESULT - -```console -$ make A=apps/task/parallel APP_FEATURES=preempt SMP=4 run -... -part 0: TaskId(7) [0, 125000) -part 3: TaskId(10) [375000, 500000) -part 1: TaskId(8) [125000, 250000) -part 2: TaskId(9) [250000, 375000) -part 4: TaskId(11) [500000, 625000) -part 5: TaskId(12) [625000, 750000) -part 6: TaskId(13) [750000, 875000) -part 7: TaskId(14) [875000, 1000000) -part 8: TaskId(15) [1000000, 1125000) -part 9: TaskId(16) [1125000, 1250000) -part 10: TaskId(17) [1250000, 1375000) -part 11: TaskId(18) [1375000, 1500000) -part 12: TaskId(19) [1500000, 1625000) -part 13: TaskId(20) [1625000, 1750000) -part 14: TaskId(21) [1750000, 1875000) -part 15: TaskId(22) [1875000, 2000000) -part 15: TaskId(22) finished -part 3: TaskId(10) finished -part 2: TaskId(9) finished -part 1: TaskId(8) finished -part 0: TaskId(7) finished -part 7: TaskId(14) finished -part 4: TaskId(11) finished -part 6: TaskId(13) finished -part 5: TaskId(12) finished -part 8: TaskId(15) finished -part 10: TaskId(17) finished -part 9: TaskId(16) finished -part 11: TaskId(18) finished -part 13: TaskId(20) finished -part 14: TaskId(21) finished -part 12: TaskId(19) finished -main task woken up! timeout=false -sum = 61783189038 -Parallel summation tests run OK! -[ 1.219708 3:2 axhal::platform::qemu_virt_aarch64::psci:25] Shutting down... -``` - -# PROCESS - -`main`使用`MAIN_WQ`睡眠 500ms,并检查`main`的唤醒是因为时间到(而非其他`task`的`notify()`)。 - -`main`调用`task::spawn`产生`NUM_TASKS`个`task`,分别进行计算。计算完毕后,使用一个`WaitQueue`(`static BARRIER_WQ`)以等待其他`task`的完成。 -在全部`task`完成后,执行`BARRIER_WQ.notify_all(true)`,继续各`task`的执行。 - -`main`在生成`task`后,调用`MAIN_WQ.wait_timeout()`等待 600ms,随后检查`task`的计算结果。 - -# FUNCTIONS - -## barrier - -`BARRIER_COUNT += 1`,记录已经完成计算的`task`数量。 - -`BARRIER_WQ.wait_until()`,block 至所有`task`均完成计算。 - -`BARRIER_WQ.notify_all()`,唤醒`BARRIER_WQ`内的所有 task 继续执行。 - -# STEPS - -## step1 - -[init](./init.md) - -After executed all initial actions, then arceos calls `main` function in `parallel` app. - -## step2 - -Calculate expected value from tasks. - -```rust -let vec = Arc::new( - (0..NUM_DATA) - .map(|_| rand::rand_u32() as u64) - .collect::>(), -); -let expect: u64 = vec.iter().map(sqrt).sum(); -``` - -## step3 - -Sleep `main` task in `MAIN_WQ` for 500ms. `main` **must** be timed out to wake up since there's no other task to `notify()` it. - -```rust -let timeout = MAIN_WQ.wait_timeout(Duration::from_millis(500)); -assert!(timeout); -``` - -## step4 - -`main` task spawn all `NUM_TASKS` tasks. - -```rust -for i in 0..NUM_TASKS { - let vec = vec.clone(); - task::spawn(move || { - ... - }); -} -``` - -Each task will do the calculation, then call `barrier()`. - -```rust -// task: -let left = i * (NUM_DATA / NUM_TASKS); -let right = (left + (NUM_DATA / NUM_TASKS)).min(NUM_DATA); -println!( - "part {}: {:?} [{}, {})", - i, - task::current().id(), - left, - right -); - -RESULTS.lock()[i] = vec[left..right].iter().map(sqrt).sum(); - -barrier(); - -println!("part {}: {:?} finished", i, task::current().id()); -let n = FINISHED_TASKS.fetch_add(1, Ordering::Relaxed); -if n == NUM_TASKS - 1 { - MAIN_WQ.notify_one(true); -} - -fn barrier() { - static BARRIER_WQ: WaitQueue = WaitQueue::new(); - static BARRIER_COUNT: AtomicUsize = AtomicUsize::new(0); - BARRIER_COUNT.fetch_add(1, Ordering::Relaxed); - BARRIER_WQ.wait_until(|| BARRIER_COUNT.load(Ordering::Relaxed) == NUM_TASKS); - BARRIER_WQ.notify_all(true); -} -``` - -`barrier()` will keep track of how many tasks have finished calculation in `BARRIER_COUNT`. - -Task will sleep in `BARRIER_WQ` until all tasks have finished. Then, the first awake task will `notify_all()` tasks to wake up. - -Task will print some info, add 1 to `FINISHED_TASKS`. The last task (`n == NUM_TASKS - 1`) will notify the `main` task to wake up. - -## step5 - -`main` will sleep 600ms in `MAIN_WQ` after spawning all the tasks. Once awake, `main` will check the actual calculation results. - -```rust -let timeout = MAIN_WQ.wait_timeout(Duration::from_millis(600)); -println!("main task woken up! timeout={}", timeout); - -let actual = RESULTS.lock().iter().sum(); -println!("sum = {}", actual); -assert_eq!(expect, actual); - -println!("Parallel summation tests run OK!"); -``` diff --git a/doc/apps_priority.md b/doc/apps_priority.md deleted file mode 100644 index 0b9238e63..000000000 --- a/doc/apps_priority.md +++ /dev/null @@ -1,41 +0,0 @@ -# INTRODUCTION - -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [priority](../apps/task/priority/) | axalloc, axtask | alloc, paging, multitask, sched_fifo, sched_rr, sched_cfs | test priority according to cfs::nice| - -# RUN -```shell -make A=apps/task/priority ARCH=riscv64 SMP=1 APP_FEATURES=sched_cfs run LOG=info -``` -Other choises of APP_FEATURES: sched_fifo, sched_rr -## Using multicore -```shell -make A=apps/task/sched-realtime ARCH=riscv64 SMP=4 APP_FEATURES=sched_cfs run LOG=info -``` -Other choises of APP_FEATURES: sched_fifo, sched_rr - -# RESULT -``` -make A=apps/task/priority ARCH=riscv64 SMP=1 APP_FEATURES=sched_cfs run LOG=info -... -part 0: TaskId(4) [0, 40) -part 1: TaskId(5) [0, 40) -part 2: TaskId(6) [0, 40) -part 3: TaskId(7) [0, 40) -part 4: TaskId(8) [0, 4) -part 3: TaskId(7) finished -part 4: TaskId(8) finished -part 2: TaskId(6) finished -part 1: TaskId(5) finished -part 0: TaskId(4) finished -sum = 3318102132 -leave time: -task 0 = 614ms -task 1 = 479ms -task 2 = 374ms -task 3 = 166ms -task 4 = 371ms -Priority tests run OK! -[ 1.274073 0:2 axhal::platform::qemu_virt_riscv::misc:3] Shutting down... -``` \ No newline at end of file diff --git a/doc/apps_sleep.md b/doc/apps_sleep.md deleted file mode 100644 index 02cd14600..000000000 --- a/doc/apps_sleep.md +++ /dev/null @@ -1,122 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [sleep](../apps/task/sleep) |axalloc,axtask |alloc, paging, multitask, sched_fifo | Thread sleeping test | - -# RUN - -``` -make A=apps/task/sleep SMP=4 LOG=debug run -``` - -# RESULT -``` -... - -[ 0.077898 axruntime:109] Initialize global memory allocator... -[ 0.080584 axalloc:128] initialize global allocator at: [0xffffffc08033c000, 0xffffffc088000000) -[ 0.084562 axruntime:115] Initialize kernel page table... -[ 0.088103 axtask:69] Initialize scheduling... -[ 0.090130 axtask::task:113] new task: Task(1, "idle") -[ 0.091833 axalloc:57] expand heap memory: [0xffffffc08034a000, 0xffffffc08035a000) - -... - -[ 9.205714 1:2 axtask::run_queue:127] task sleep: Task(2, "main"), deadline=9.2151238s -[ 9.207086 1:6 axtask:144] idle task: waiting for IRQs... -[ 9.207282 2:1 axtask::run_queue:49] task yield: Task(1, "idle") -[ 9.208362 2:1 axtask:144] idle task: waiting for IRQs... -[ 9.209530 0:4 axtask::run_queue:114] task unblock: Task(11, "") -[ 9.210129 0:4 axtask::run_queue:49] task yield: Task(4, "idle") -[ 9.210775 0:11 arceos_sleep:40] task 3 actual sleep 4.0016563s seconds (1). -task 3 sleep 4 seconds (2) ... - -... - -Sleep tests run OK! -[ 16.228092 2:2 axtask::run_queue:80] task exit: Task(2, "main"), exit_code=0 -[ 16.228823 2:2 axhal::platform::qemu_virt_riscv::misc:2] Shutting down... -``` - -# STEPS - -## step1 -[init](./init.md) -After executed all initial actions, then arceos calls `main` function in `helloworld` app. - -## step2 -```Rust -fn main(){ -... -} -``` - -### step2.1 -```Rust - println!("Hello, main task!"); - let now = Instant::now(); - task::sleep(Duration::from_secs(1)); - let elapsed = now.elapsed(); - println!("main task sleep for {:?}", elapsed); -``` - -**flow chart** - -```mermaid -graph TD; - S["libax::task::sleep()"] - - S-->arg["libax::time::Duration::from_secs()"] - arg-->argA["libax::time::Duration::new(secs)"] - - S-->A["axhal::time::current_time()"] - A-->AA["axhal::time::TimeValue::from_nanos()"] - - S-->B["axtask::run_queue::AxRunQueue::sleep_until()"] - B-->B.lock["SpinNoIrq< axtask::run_queue::AxRunQueue >"] - B-->BA["axtask::timers::set_alarm_wakeup()"] - BA-->BAA["SpinNoIrq < timer_list::TimeList< axtask::timers::TaskWakeupEvent>>"] - BAA-->BAAA["BinaryHeap < timer_list::TimerEventWrapper >"] - BAA-->BAAB["AxTaskRef = Arc< AxTask >"] - BAAB-->BAABA["scheduler::FifoTask< axtask::task::TaskInner >"] - B-->BB["axtask::run_queue::resched_inner()"] - BB-->BBA["axtask::task::set_state()"] -``` - -### step2.2 - -```Rust - task::spawn(|| { - for i in 0..30 { - info!(" tick {}", i); - task::sleep(Duration::from_millis(500)); - } - }); -``` - -**flow chart** - -```mermaid -graph TD; - T["axtask::task::spawn(closure fn)"] - T-->A["axtask::task::TaskInner::new(entry, name, axconfig::TASK_STACK_SIZE)"] - A-->B["axtask::task::TaskInner::new_common(axtask::task::TaskId, name)"] - A-->C["axtask::task::TaskStack::alloc(size)"] -``` - -### step2.3 - -```Rust - while FINISHED_TASKS.load(Ordering::Relaxed) < NUM_TASKS { - task::sleep(Duration::from_millis(10)); - } -``` - -**flow chart** - -```mermaid -graph TD; - T["FINISHED_TASKS.load(Ordering::Relaxed)"] - T --> A["core::sync::atomic::AtomicUsize::new(num)"] - T --> B["core::sync::atomic::Ordering::Relaxed"] -``` diff --git a/doc/apps_yield.md b/doc/apps_yield.md deleted file mode 100644 index 3b037ae74..000000000 --- a/doc/apps_yield.md +++ /dev/null @@ -1,91 +0,0 @@ -# INTRODUCTION -| App | Extra modules | Enabled features | Description | -|-|-|-|-| -| [yield](../apps/task/yield/) | axalloc, axtask | alloc, paging, multitask, sched_fifo | Multi-threaded yielding test | - -# RUN - -## Without preemption (FIFO scheduler) - -```shell -make A=apps/task/yield ARCH=riscv64 LOG=info NET=y SMP=1 run -``` - -## With preemption (RR scheduler) - -```shell -make A=apps/task/yield ARCH=riscv64 LOG=info NET=y SMP=1 APP_FEATURES=preempt run -``` - -## RESULT - -``` -Hello, main task! -Hello, task 0! id = TaskId(4) -Hello, task 1! id = TaskId(5) -Hello, task 2! id = TaskId(6) -Hello, task 3! id = TaskId(7) -Hello, task 4! id = TaskId(8) -Hello, task 5! id = TaskId(9) -Hello, task 6! id = TaskId(10) -Hello, task 7! id = TaskId(11) -Hello, task 8! id = TaskId(12) -Hello, task 9! id = TaskId(13) -Task yielding tests run OK! -``` - -# STEPS - -## step1 - -* OS init -* After executed all initial actions, then arceos call main function in `yield` app. - -## step2 - -* Use the `task::spawn` cycle to generate `NUM_TASKS` tasks (similar to threads). -* Each task executes a function, just print its ID. -* If preemption is disabled, the task voluntarily executes `yield` to give up the CPU. -* If SMP is not enabled, the execution order of tasks must be FIFO. -* `main task` will wait for all other tasks to complete. If not, continue to execute `yield` and wait. - -```rust -fn main() { - for i in 0..NUM_TASKS { - task::spawn(move || { - println!("Hello, task {}! id = {:?}", i, task::current().id()); - // 此时已经启动了yield - // 因为preempt所需要的依赖libax/sched_rr并没有被包含进去 - #[cfg(not(feature = "preempt"))] - task::yield_now(); - - let order = FINISHED_TASKS.fetch_add(1, Ordering::Relaxed); - if option_env!("SMP") == Some("1") { - assert!(order == i); // FIFO scheduler - } - }); - } - println!("Hello, main task{}!"); - while FINISHED_TASKS.load(Ordering::Relaxed) < NUM_TASKS { - #[cfg(not(feature = "preempt"))] - task::yield_now(); - } - println!("Task yielding tests run OK!"); -} -``` - -**flow chart** - -```mermaid -graph TD; - T["main task"] --> A["axtask::lib::spawn"]; - A -- "task_i" --> B["axtask::run_queue::AxRunqQueue.scheduler.push_back(tasak_i)"]; - A --> C["RUN_QUEUE.lock()"]; - B -- "repeat n times" --> A; - B -- "main task" --> D["axtask::lib::yield_now"]; - D --> E["axtask::run_queue::AxRunqQueue::resched_inner"]; - E -- "prev" --> F["axtask::run_queue::AxRunqQueue.scheduler.push_back(prev)"]; - E -- "next=axtask::run_queue::AxRunqQueue.scheduler.pop_front()" --> G["axtask::run_queue::AxRunqQueue:: switch_to(prev,next)"]; - G -- "repeat n times" --> D; - G -- "all n subtask finished" --> H["finished"] -``` diff --git a/doc/build.md b/doc/build.md index 8cc302a65..7ae32634f 100644 --- a/doc/build.md +++ b/doc/build.md @@ -1,28 +1,28 @@ -# ArceOS Build Flow +# Ruxos Build Flow -We will provide an example to illustrate the process of building and running ArceOS: +We will provide an example to illustrate the process of building and running Ruxos: **Examples:** What happens when "make A=apps/net/httpserver ARCH=aarch64 LOG=info NET=y SMP=1 run" is executed? -- How ArceOS build? +- How Ruxos build? - Firstly check Makefile: Based on different parameters, select whether FS/NET/GRAPHIC param is yes or not. If it is y, it will be compiled in conditional compilation. - `cargo.mk` determines whether to add the corresponding feature based on whether FS/NET/GRAPHIC is set to y. ``` - features-$(FS) += libax/fs - features-$(NET) += libax/net - features-$(GRAPHIC) += libax/display + features-$(FS) += axstd/fs + features-$(NET) += axstd/net + features-$(GRAPHIC) += axstd/display ``` - `_cargo_build`: The `_cargo_build` method is defined in cargo.mk. Different compilation methods are selected based on the language. For example, for Rust, when `cargo_build,--manifest-path $(APP)/Cargo.toml` is called, where $(APP) represents the current application to be run. - - Taking httpserver as an example, let's see how ArceOS are conditionally compiled. First, in the `Cargo.toml` file of httpserver, the dependency is specified as: `libax = { path = "../../../ulib/libax", features = ["paging", "multitask", "net"] }`. This indicates that libax needs to be compiled and has the three features mentioned above. - - After checking libax, the following three features were found: - - `paging = ["axruntime/paging"]` - - `multitask = ["axruntime/multitask", "axtask/multitask", "axsync/multitask"]` - - `net = ["axruntime/net", "dep:axnet"]` + - Taking httpserver as an example, let's see how Ruxos are conditionally compiled. First, in the `Cargo.toml` file of httpserver, the dependency is specified as: `axstd = { path = "../../../ulib/axstd", features = ["alloc", "multitask", "net"], optional = true }`. This indicates that axstd needs to be compiled and has the three features mentioned above. + - After checking axstd and arceos-api, the following three features were found: + - `paging = ["ruxruntime/paging"]` + - `multitask = ["ruxruntime/multitask", "ruxtask/multitask", "axsync/multitask"]` + - `net = ["ruxruntime/net", "dep:axnet"]` - This involves modules such as axruntime, axtask, axsync, etc., and conditional compilation is performed on these modules. + This involves modules such as ruxruntime, ruxtask, axsync, etc., and conditional compilation is performed on these modules. - The above are some modules required for compilation, next we will look at how to perform conditional compilation. The `cargo.mk` file describes how to use the cargo method for conditional compilation, with the following build parameters: ``` build_args := \ @@ -32,13 +32,13 @@ What happens when "make A=apps/net/httpserver ARCH=aarch64 LOG=info NET=y SMP=1 --target-dir $(CURDIR)/target \ --features "$(features-y)" \ ``` - Note that the -Zbuild-std option is mentioned here, indicating the replacement of the standard library for the application and the use of libraries provided by ArceOS. + Note that the -Zbuild-std option is mentioned here, indicating the replacement of the standard library for the application and the use of libraries provided by Ruxos. - Therefore, to summarize: choose conditions in Makefile and select the corresponding app directory for conditional compilation in `cargo.mk`. -- Next, describe how ArceOS run: +- Next, describe how Ruxos run: - Firstly, examining the Makefile reveals that in addition to building, running an application also requires `justrun`. - Following this, it was found that the `qemu.mk` file would call run_qemu. Similar to the build process, the execution process would also use conditional selection and run. - - At runtime, Arceos first performs some boot operations, such as executing in the riscv64 environment: + - At runtime, Ruxos first performs some boot operations, such as executing in the riscv64 environment: ```rust #[naked] #[no_mangle] @@ -86,6 +86,6 @@ What happens when "make A=apps/net/httpserver ARCH=aarch64 LOG=info NET=y SMP=1 ) } ``` - - Later, it jumps to `rust_main` in `axruntime` to run. After some conditional initialization, `rust_main` executes `main()`. Since this main is defined by the application, symbol linkage should be established and jumped to (no context switch is needed since it's a single address space). + - Later, it jumps to `rust_main` in `ruxruntime` to run. After some conditional initialization, `rust_main` executes `main()`. Since this main is defined by the application, symbol linkage should be established and jumped to (no context switch is needed since it's a single address space). - - Then, the user program begins executing through `libax`'s API. The application runs in kernel mode, without the need for syscall and context switching, resulting in higher efficiency. + - Then, the user program begins executing through `axstd`'s API. The application runs in kernel mode, without the need for syscall and context switching, resulting in higher efficiency. diff --git a/doc/figures/rukos.svg b/doc/figures/rukos.svg deleted file mode 100644 index 127a6ac3b..000000000 --- a/doc/figures/rukos.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - -
rukos modules
rukos modules
ArceOS and rukos crates
ArceOS and rukos crates
User Apps
User Apps
Hypervisor
Hypervisor
axnet
axnet
axtask
axtask
axconfig
axconfig
axruntime
axruntime
axhal
axhal
axdriver
axdriver
allocator
allocator
axalloc
axalloc
scheduler
scheduler
page_table
page_table
linked_list
linked_list
driver_blk
driver_blk
axasync
axasync
smoltcp
smoltcp
buddy
buddy
slab
slab
FIFO
FIFO
CFS
CFS
ixgbe
ixgbe
lwip_rust
lwip_rust
driver_virtio
driver_virtio
driver_net
driver_net
axfs
axfs
page_table_entry
page_table_entry
rukos API
rukos API
rukos_posix_api
rukos_posix_api
rukos_rust_api
rukos_rust_api
rukos ulib
rukos ulib
axstd
axstd
axlibc
axlibc
rust std
rust std
Rust App
Rust App
C App
C App
Rust std App
Rust std App
C App
C App
musl libc
musl libc
axfeat
axfeat
feature selection
feature selection
Text is not SVG - cannot display
\ No newline at end of file diff --git a/doc/figures/ruxos.svg b/doc/figures/ruxos.svg new file mode 100644 index 000000000..7d06cf785 --- /dev/null +++ b/doc/figures/ruxos.svg @@ -0,0 +1,4 @@ + + + +
ruxos modules
ruxos modules
Basic OS Components as Rust Crates
Basic OS Components as Rust Crates
User Apps
User Apps
Hypervisor
Hypervisor
axnet
axnet
ruxtask
ruxtask
ruxconfig
ruxconfig
ruxruntime
ruxruntime
ruxhal
ruxhal
ruxdriver
ruxdriver
allocator
allocator
axalloc
axalloc
scheduler
scheduler
page_table
page_table
linked_list
linked_list
driver_blk
driver_blk
ruxdisplay
ruxdisplay
smoltcp
smoltcp
buddy
buddy
slab
slab
FIFO
FIFO
CFS
CFS
ixgbe
ixgbe
driver_virtio
driver_virtio
driver_net
driver_net
ruxfs
ruxfs
page_table_entry
page_table_entry
ruxos API
ruxos API
ruxos_posix_api
ruxos_posix_api
arceos_api
arceos_api
ruxos ulib
ruxos ulib
axstd
axstd
ruxlibc
ruxlibc
rust std
rust std
Rust App
Rust App
C App
C App
Rust std App
Rust std App
C App
C App
ruxmusl
ruxmusl
ruxfeat
ruxfeat
feature selection
feature selection
rux9p
rux9p
driver_9p
driver_9p
Text is not SVG - cannot display
\ No newline at end of file diff --git a/doc/init.md b/doc/init.md index 3218fe7a3..ab7834302 100644 --- a/doc/init.md +++ b/doc/init.md @@ -1,28 +1,28 @@ ```mermaid graph TD; - A[axhal::platform::qemu_virt_riscv::boot.rs::_boot] --> init_boot_page_table; + A[ruxhal::platform::qemu_virt_riscv::boot.rs::_boot] --> init_boot_page_table; A --> init_mmu; A --> P[platform_init]; - A --> B[axruntime::rust_main]; - P --> P1["axhal::mem::clear_bss()"]; - P --> P2["axhal::arch::riscv::set_trap_vector_base()"]; - P --> P3["axhal::cpu::init_percpu()"]; - P --> P4["axhal::platform::qemu_virt_riscv::irq.rs::init()"]; - P --> P5["axhal::platform::qemu_virt_riscv::time.rs::init()"]; + A --> B[ruxruntime::rust_main]; + P --> P1["ruxhal::mem::clear_bss()"]; + P --> P2["ruxhal::arch::riscv::set_trap_vector_base()"]; + P --> P3["ruxhal::cpu::init_percpu()"]; + P --> P4["ruxhal::platform::qemu_virt_riscv::irq.rs::init()"]; + P --> P5["ruxhal::platform::qemu_virt_riscv::time.rs::init()"]; B --> axlog::init; B --> D[init_allocator]; B --> remap_kernel_memory; - B --> axtask::init_scheduler; - B --> axdriver::init_drivers; - B --> Q[axfs::init_filesystems]; + B --> ruxtask::init_scheduler; + B --> ruxdriver::init_drivers; + B --> Q[ruxfs::init_filesystems]; B --> axnet::init_network; - B --> axdisplay::init_display; + B --> ruxdisplay::init_display; B --> init_interrupt; B --> mp::start_secondary_cpus; B --> C[main]; - Q --> Q1["disk=axfs::dev::Disk::new()"]; - Q --> Q2["axfs::root::init_rootfs(disk)"]; - Q2 --fatfs--> Q21["main_fs=axfs::fs::fatfs::FatFileSystem::new()"]; + Q --> Q1["disk=ruxfs::dev::Disk::new()"]; + Q --> Q2["ruxfs::root::init_rootfs(disk)"]; + Q2 --fatfs--> Q21["main_fs=ruxfs::fs::fatfs::FatFileSystem::new()"]; Q2 --> Q22["MAIN_FS.init_by(main_fs); MAIN_FS.init()"]; Q2 --> Q23["root_dir = RootDirectory::new(MAIN_FS)"]; Q2 --devfs--> Q24["axfs_devfs::DeviceFileSystem::new()"]; diff --git a/doc/ixgbe.md b/doc/ixgbe.md index cba58e3b6..db13e3609 100644 --- a/doc/ixgbe.md +++ b/doc/ixgbe.md @@ -1,4 +1,4 @@ -# How to run arceos with ixgbe NIC? +# How to run Ruxos with ixgbe NIC? You need to specify the platform that owns this network card. For example, we defined a toml file named `x86_64-pc-oslab`` under the platforms directory to describe the platform characteristics. diff --git a/doc/platform_raspi4.md b/doc/platform_raspi4.md deleted file mode 100644 index 88f1a8166..000000000 --- a/doc/platform_raspi4.md +++ /dev/null @@ -1,28 +0,0 @@ -# How to run ArceOS on raspi4 - -Recommand you download this tutorial first: - -https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials - -And follow this tutorial to run the 06_uart_chainloader chapter. -It will help you to connect your raspi4 to your computer and it will also teach you how to use `make chainboot` to run your code on raspi4. - -Then run with features `ARCH=aarch64 PLATFORM = raspi4-aarch64` and use the command `make chainboot` to transmit the xxxx_raspi4-aarch64.bin to your raspi4. - -# How to debug ArceOS on raspi4 - -Recommand you download this tutorial first: - -https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials - -And follow this tutorial to run the 08_hw_debug_JTAG chapter. -It will help you to connect your raspi4 to the JTAG and connect your JTAG to your computer and it will also teach you how to use `make jtagboot` to debug your raspi4. - -Because the JTAG only support the first line of code be loaded at `0x80000` and only support single core, so you have to -1. Change the file: /modules/axconfig/src/platform/raspi4_aarch64, replace the "kernel-base-vaddr" with "0x8_0000" and replace the "phys-virt-offset" with "0x0" -2. set the feature `SMP=1` - -Then run with features `ARCH=aarch64 PLATFORM = raspi4-aarch64` and -1. use the command `make jtagboot` to run a halt program on your raspi4 -2. start a new terminal, and run `make openocd` to connect your PC with the JTAG -3. start a new terminal, and run `make gdb` to start a gdb, and type `target remote :3333` to connect with your openocd, and type `load` to load the xxxx_raspi4-aarch64.bin to your raspi4 and start to debug. diff --git a/modules/ax9p/Cargo.toml b/modules/ax9p/Cargo.toml deleted file mode 100644 index 2f661affb..000000000 --- a/modules/ax9p/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "ax9p" -version = "0.1.0" -edition = "2021" -authors = ["Zheng Wu "] -description = "RukOS Plan-9 filesystem module" -license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/rukos" -repository = "https://github.com/rcore-os/rukos/tree/main/modules/ax9p" -documentation = "https://rcore-os.github.io/rukos/ax9p/index.html" - -[features] -virtio-9p = ["axdriver/virtio-9p", "axdriver/virtio-9p"] -net-9p = ["axnet", "driver_common", "axdriver/dyn" , "axdriver/_9p"] -need_auth = [] - -[dependencies] -log = "0.4" -spin = "0.9" -driver_9p = { path = "../../crates/driver_9p"} -axfs_vfs = { path = "../../crates/axfs_vfs"} -driver_common = { path = "../../crates/driver_common", optional = true} - -axfs = { path = "../axfs"} -axnet = { path = "../axnet", optional = true} -axdriver = { path = "../axdriver"} \ No newline at end of file diff --git a/modules/axalloc/src/lib.rs b/modules/axalloc/src/lib.rs index 93a9f312c..6a0017a61 100644 --- a/modules/axalloc/src/lib.rs +++ b/modules/axalloc/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) global memory allocator. +//! [Ruxos](https://github.com/syswonder/ruxos) global memory allocator. //! //! It provides [`GlobalAllocator`], which implements the trait //! [`core::alloc::GlobalAlloc`]. A static global variable of type @@ -42,7 +42,7 @@ cfg_if::cfg_if! { } } -/// The global allocator used by ArceOS. +/// The global allocator used by Ruxos. /// /// It combines a [`ByteAllocator`] and a [`PageAllocator`] into a simple /// two-level allocator: firstly tries allocate from the byte allocator, if diff --git a/modules/axalloc/src/page.rs b/modules/axalloc/src/page.rs index 8611a7051..bbd03a9d6 100644 --- a/modules/axalloc/src/page.rs +++ b/modules/axalloc/src/page.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axconfig/Cargo.toml b/modules/axconfig/Cargo.toml deleted file mode 100644 index c0ffe34b4..000000000 --- a/modules/axconfig/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "axconfig" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] -description = "Platform-specific constants and parameters for ArceOS" -license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axconfig" -documentation = "https://rcore-os.github.io/arceos/axconfig/index.html" - -[build-dependencies] -toml_edit = "0.19" -serde = "1.0" diff --git a/modules/axdisplay/Cargo.toml b/modules/axdisplay/Cargo.toml deleted file mode 100644 index 0ce0bf341..000000000 --- a/modules/axdisplay/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "axdisplay" -version = "0.1.0" -edition = "2021" -authors = ["Shiping Yuan "] -description = "ArceOS graphics module" -license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axdisplay" -documentation = "https://rcore-os.github.io/arceos/axdisplay/index.html" - -[dependencies] -log = "0.4" -axdriver = { path = "../axdriver", features = ["display"] } -lazy_init = { path = "../../crates/lazy_init" } -axsync = { path = "../axsync" } -driver_display = { path = "../../crates/driver_display" } diff --git a/modules/axhal/src/platform/aarch64_bsta1000b/dw_apb_uart.rs b/modules/axhal/src/platform/aarch64_bsta1000b/dw_apb_uart.rs deleted file mode 100644 index 02bc4dba4..000000000 --- a/modules/axhal/src/platform/aarch64_bsta1000b/dw_apb_uart.rs +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -//! snps,dw-apb-uart serial driver - -use crate::mem::phys_to_virt; -use dw_apb_uart::DW8250; -use memory_addr::PhysAddr; -use spinlock::SpinNoIrq; - -const UART_BASE: PhysAddr = PhysAddr::from(axconfig::UART_PADDR); - -static UART: SpinNoIrq = SpinNoIrq::new(DW8250::new(phys_to_virt(UART_BASE).as_usize())); - -/// Writes a byte to the console. -pub fn putchar(c: u8) { - let mut uart = UART.lock(); - match c { - b'\r' | b'\n' => { - uart.putchar(b'\r'); - uart.putchar(b'\n'); - } - c => uart.putchar(c), - } -} - -/// Reads a byte from the console, or returns [`None`] if no input is available. -pub fn getchar() -> Option { - UART.lock().getchar() -} - -/// UART simply initialize -pub fn init_early() { - UART.lock().init(); -} - -/// Set UART IRQ Enable -#[cfg(feature = "irq")] -pub fn init_irq() { - UART.lock().set_ier(true); - crate::irq::register_handler(crate::platform::irq::UART_IRQ_NUM, handle); -} - -/// UART IRQ Handler -pub fn handle() { - trace!("Uart IRQ Handler"); -} diff --git a/modules/axhal/src/platform/aarch64_bsta1000b/mem.rs b/modules/axhal/src/platform/aarch64_bsta1000b/mem.rs deleted file mode 100644 index c8ab0932a..000000000 --- a/modules/axhal/src/platform/aarch64_bsta1000b/mem.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::mem::{MemRegion, PhysAddr}; -use page_table_entry::{aarch64::A64PTE, GenericPTE, MappingFlags}; - -/// Returns platform-specific memory regions. -pub(crate) fn platform_regions() -> impl Iterator { - crate::mem::default_free_regions().chain(crate::mem::default_mmio_regions()) -} - -pub(crate) unsafe fn init_boot_page_table( - boot_pt_l0: &mut [A64PTE; 512], - boot_pt_l1: &mut [A64PTE; 512], -) { - // 0x0000_0000_0000 ~ 0x0080_0000_0000, table - boot_pt_l0[0] = A64PTE::new_table(PhysAddr::from(boot_pt_l1.as_ptr() as usize)); - // 0x0000_0000_0000..0x0000_4000_0000, 1G block, device memory - boot_pt_l1[0] = A64PTE::new_page( - PhysAddr::from(0), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::DEVICE, - true, - ); - // 1G block, device memory - boot_pt_l1[1] = A64PTE::new_page( - PhysAddr::from(0x40000000), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::DEVICE, - true, - ); - // 1G block, normal memory - boot_pt_l1[2] = A64PTE::new_page( - PhysAddr::from(0x80000000), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::EXECUTE, - true, - ); -} diff --git a/modules/axhal/src/platform/aarch64_bsta1000b/misc.rs b/modules/axhal/src/platform/aarch64_bsta1000b/misc.rs deleted file mode 100644 index 619e4217f..000000000 --- a/modules/axhal/src/platform/aarch64_bsta1000b/misc.rs +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -pub use crate::platform::aarch64_common::psci::system_off as terminate; - -use crate::mem::phys_to_virt; -use crate::time::{busy_wait, Duration}; -use core::ptr::{read_volatile, write_volatile}; - -/// Do QSPI reset -pub fn reset_qspi() { - // qspi exit 4-byte mode - // exit_4byte_qspi(); - - let ptr = phys_to_virt((axconfig::A1000BASE_SAFETYCRM + 0x8).into()).as_mut_ptr() as *mut u32; - unsafe { - let value = read_volatile(ptr); - trace!("SAFETY CRM RESET CTRL = {:#x}", value); - write_volatile(ptr, value & !(0b11 << 15)); - busy_wait(Duration::from_millis(100)); - - write_volatile(ptr, value | (0b11 << 15)); - busy_wait(Duration::from_millis(100)); - } -} - -/// Do CPU reset -pub fn reset_cpu() { - reset_qspi(); - - //Data Width = 32 - let ptr = phys_to_virt((axconfig::A1000BASE_SAFETYCRM + 0x8).into()).as_mut_ptr() as *mut u32; - unsafe { - write_volatile(ptr, read_volatile(ptr) & !0b1); - } - - loop {} -} - -/// reboot system -#[allow(dead_code)] -pub fn do_reset() { - axlog::ax_println!("resetting ...\n"); - - // wait 50 ms - busy_wait(Duration::from_millis(50)); - - // disable_interrupts(); - - reset_cpu(); - - // NOT REACHED - warn!("NOT REACHED Resetting"); -} - -/// bootmode define bit [27:26], from strap pin -#[allow(dead_code)] -pub fn get_bootmode() -> u32 { - unsafe { - let ptr = phys_to_virt((axconfig::A1000BASE_TOPCRM).into()).as_mut_ptr() as *mut u32; - (ptr.read_volatile() >> 26) & 0x7 - } -} diff --git a/modules/axhal/src/platform/aarch64_bsta1000b/mod.rs b/modules/axhal/src/platform/aarch64_bsta1000b/mod.rs deleted file mode 100644 index 6735bb503..000000000 --- a/modules/axhal/src/platform/aarch64_bsta1000b/mod.rs +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -mod dw_apb_uart; - -pub mod mem; -pub mod misc; - -#[cfg(feature = "smp")] -pub mod mp; - -#[cfg(feature = "irq")] -pub mod irq { - pub use crate::platform::aarch64_common::gic::*; -} - -pub mod console { - pub use super::dw_apb_uart::*; -} - -pub mod time { - pub use crate::platform::aarch64_common::generic_timer::*; -} - -extern "C" { - fn exception_vector_base(); - fn rust_main(cpu_id: usize, dtb: usize); - #[cfg(feature = "smp")] - fn rust_main_secondary(cpu_id: usize); -} - -pub(crate) unsafe extern "C" fn rust_entry(cpu_id: usize, dtb: usize) { - crate::mem::clear_bss(); - crate::arch::set_exception_vector_base(exception_vector_base as usize); - crate::cpu::init_primary(cpu_id); - dw_apb_uart::init_early(); - super::aarch64_common::generic_timer::init_early(); - rust_main(cpu_id, dtb); -} - -#[cfg(feature = "smp")] -pub(crate) unsafe extern "C" fn rust_entry_secondary(cpu_id: usize) { - crate::arch::set_exception_vector_base(exception_vector_base as usize); - crate::cpu::init_secondary(cpu_id); - rust_main_secondary(cpu_id); -} - -/// Initializes the platform devices for the primary CPU. -/// -/// For example, the interrupt controller and the timer. -pub fn platform_init() { - #[cfg(feature = "irq")] - super::aarch64_common::gic::init_primary(); - super::aarch64_common::generic_timer::init_percpu(); - #[cfg(feature = "irq")] - dw_apb_uart::init_irq(); -} - -/// Initializes the platform devices for secondary CPUs. -#[cfg(feature = "smp")] -pub fn platform_init_secondary() { - #[cfg(feature = "irq")] - super::aarch64_common::gic::init_secondary(); - super::aarch64_common::generic_timer::init_percpu(); -} diff --git a/modules/axhal/src/platform/aarch64_bsta1000b/mp.rs b/modules/axhal/src/platform/aarch64_bsta1000b/mp.rs deleted file mode 100644 index 8be93e25d..000000000 --- a/modules/axhal/src/platform/aarch64_bsta1000b/mp.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::mem::{virt_to_phys, PhysAddr, VirtAddr}; - -/// Hart number of bsta1000b board -pub const MAX_HARTS: usize = 8; -/// CPU HWID from cpu device tree nodes with "reg" property -pub const CPU_HWID: [usize; MAX_HARTS] = [0x00, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700]; - -/// Starts the given secondary CPU with its boot stack. -pub fn start_secondary_cpu(cpu_id: usize, stack_top: PhysAddr) { - if cpu_id >= MAX_HARTS { - error!("No support for bsta1000b core {}", cpu_id); - return; - } - extern "C" { - fn _start_secondary(); - } - let entry = virt_to_phys(VirtAddr::from(_start_secondary as usize)); - crate::platform::aarch64_common::psci::cpu_on( - CPU_HWID[cpu_id], - entry.as_usize(), - stack_top.as_usize(), - ); -} diff --git a/modules/axhal/src/platform/aarch64_raspi/mem.rs b/modules/axhal/src/platform/aarch64_raspi/mem.rs deleted file mode 100644 index a56114082..000000000 --- a/modules/axhal/src/platform/aarch64_raspi/mem.rs +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::mem::*; -use page_table_entry::{aarch64::A64PTE, GenericPTE, MappingFlags}; - -/// Returns platform-specific memory regions. -pub(crate) fn platform_regions() -> impl Iterator { - core::iter::once(MemRegion { - paddr: 0x0.into(), - size: 0x1000, - flags: MemRegionFlags::RESERVED | MemRegionFlags::READ | MemRegionFlags::WRITE, - name: "spintable", - }) - .chain(crate::mem::default_free_regions()) - .chain(crate::mem::default_mmio_regions()) -} - -pub(crate) unsafe fn init_boot_page_table( - boot_pt_l0: &mut [A64PTE; 512], - boot_pt_l1: &mut [A64PTE; 512], -) { - // 0x0000_0000_0000 ~ 0x0080_0000_0000, table - boot_pt_l0[0] = A64PTE::new_table(PhysAddr::from(boot_pt_l1.as_ptr() as usize)); - // 0x0000_0000_0000..0x0000_4000_0000, 1G block, device memory - boot_pt_l1[0] = A64PTE::new_page( - PhysAddr::from(0), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::EXECUTE, - true, - ); - // 0x0000_4000_0000..0x0000_8000_0000, 1G block, normal memory - boot_pt_l1[1] = A64PTE::new_page( - PhysAddr::from(0x4000_0000), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::EXECUTE, - true, - ); - // 0x0000_8000_0000..0x0000_C000_0000, 1G block, normal memory - boot_pt_l1[2] = A64PTE::new_page( - PhysAddr::from(0x8000_0000), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::EXECUTE, - true, - ); - // 0x0000_C000_0000..0x0001_0000_0000, 1G block, DEVICE memory - boot_pt_l1[3] = A64PTE::new_page( - PhysAddr::from(0xc000_0000), - MappingFlags::READ | MappingFlags::WRITE | MappingFlags::DEVICE, - true, - ); -} diff --git a/modules/axhal/src/platform/aarch64_raspi/mod.rs b/modules/axhal/src/platform/aarch64_raspi/mod.rs deleted file mode 100644 index bed5e3045..000000000 --- a/modules/axhal/src/platform/aarch64_raspi/mod.rs +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -pub mod mem; - -#[cfg(feature = "smp")] -pub mod mp; - -#[cfg(feature = "irq")] -pub mod irq { - pub use crate::platform::aarch64_common::gic::*; -} - -pub mod console { - pub use crate::platform::aarch64_common::pl011::*; -} - -pub mod time { - pub use crate::platform::aarch64_common::generic_timer::*; - #[cfg(feature = "rtc")] - pub use crate::platform::aarch64_common::pl031::*; -} - -pub mod misc { - pub fn terminate() -> ! { - info!("Shutting down..."); - loop { - crate::arch::halt(); - } - } -} - -extern "C" { - fn exception_vector_base(); - fn rust_main(cpu_id: usize, dtb: usize); - #[cfg(feature = "smp")] - fn rust_main_secondary(cpu_id: usize); -} - -pub(crate) unsafe extern "C" fn rust_entry(cpu_id: usize, dtb: usize) { - crate::mem::clear_bss(); - crate::arch::set_exception_vector_base(exception_vector_base as usize); - crate::arch::write_page_table_root0(0.into()); // disable low address access - crate::cpu::init_primary(cpu_id); - super::aarch64_common::pl011::init_early(); - super::aarch64_common::generic_timer::init_early(); - rust_main(cpu_id, dtb); -} - -#[cfg(feature = "smp")] -pub(crate) unsafe extern "C" fn rust_entry_secondary(cpu_id: usize) { - crate::arch::set_exception_vector_base(exception_vector_base as usize); - crate::arch::write_page_table_root0(0.into()); // disable low address access - crate::cpu::init_secondary(cpu_id); - rust_main_secondary(cpu_id); -} - -/// Initializes the platform devices for the primary CPU. -/// -/// For example, the interrupt controller and the timer. -pub fn platform_init() { - #[cfg(feature = "irq")] - super::aarch64_common::gic::init_primary(); - super::aarch64_common::generic_timer::init_percpu(); - #[cfg(feature = "rtc")] - super::aarch64_common::pl031::init(); - super::aarch64_common::pl011::init(); -} - -/// Initializes the platform devices for secondary CPUs. -#[cfg(feature = "smp")] -pub fn platform_init_secondary() { - #[cfg(feature = "irq")] - super::aarch64_common::gic::init_secondary(); - super::aarch64_common::generic_timer::init_percpu(); -} diff --git a/modules/axhal/src/platform/aarch64_raspi/mp.rs b/modules/axhal/src/platform/aarch64_raspi/mp.rs deleted file mode 100644 index a3ced8389..000000000 --- a/modules/axhal/src/platform/aarch64_raspi/mp.rs +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::mem::{phys_to_virt, virt_to_phys, PhysAddr, VirtAddr}; - -static mut SECONDARY_STACK_TOP: usize = 0; - -extern "C" { - fn _start_secondary(); -} - -#[naked] -#[link_section = ".text.boot"] -unsafe extern "C" fn modify_stack_and_start() { - core::arch::asm!(" - ldr x21, ={secondary_boot_stack} // the secondary CPU hasn't set the TTBR1 - mov x8, {phys_virt_offset} // minus the offset to get the phys addr of the boot stack - sub x21, x21, x8 - ldr x21, [x21] - mov x0, x21 // x0 will be set to SP in the beginning of _start_secondary - b _start_secondary", - secondary_boot_stack = sym SECONDARY_STACK_TOP, - phys_virt_offset = const axconfig::PHYS_VIRT_OFFSET, - options(noreturn) - ); -} - -pub static CPU_SPIN_TABLE: [PhysAddr; 4] = [ - PhysAddr::from(0xd8), - PhysAddr::from(0xe0), - PhysAddr::from(0xe8), - PhysAddr::from(0xf0), -]; - -/// Starts the given secondary CPU with its boot stack. -pub fn start_secondary_cpu(cpu_id: usize, stack_top: PhysAddr) { - let entry_paddr = virt_to_phys(VirtAddr::from(modify_stack_and_start as usize)).as_usize(); - unsafe { - // set the boot code address of the given secondary CPU - let spintable_vaddr = phys_to_virt(CPU_SPIN_TABLE[cpu_id]); - let release_ptr = spintable_vaddr.as_mut_ptr() as *mut usize; - release_ptr.write_volatile(entry_paddr); - crate::arch::flush_dcache_line(spintable_vaddr); - - // set the boot stack of the given secondary CPU - SECONDARY_STACK_TOP = stack_top.as_usize(); - crate::arch::flush_dcache_line(VirtAddr::from( - (&SECONDARY_STACK_TOP as *const usize) as usize, - )); - } - aarch64_cpu::asm::sev(); -} diff --git a/modules/axlog/src/lib.rs b/modules/axlog/src/lib.rs index cbd8ff179..2b954a0cc 100644 --- a/modules/axlog/src/lib.rs +++ b/modules/axlog/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,7 +8,7 @@ */ //! Macros for multi-level formatted logging used by -//! [ArceOS](https://github.com/rcore-os/arceos). +//! [Ruxos](https://github.com/syswonder/ruxos). //! //! The log macros, in descending order of level, are: [`error!`], [`warn!`], //! [`info!`], [`debug!`], and [`trace!`]. diff --git a/modules/axnet/Cargo.toml b/modules/axnet/Cargo.toml index 32919787a..7f40b6bf0 100644 --- a/modules/axnet/Cargo.toml +++ b/modules/axnet/Cargo.toml @@ -20,10 +20,10 @@ spin = "0.9" driver_net = { path = "../../crates/driver_net" } lazy_init = { path = "../../crates/lazy_init" } axerrno = { path = "../../crates/axerrno" } -axhal = { path = "../axhal" } +ruxhal = { path = "../ruxhal" } axsync = { path = "../axsync" } -axtask = { path = "../axtask" } -axdriver = { path = "../axdriver", features = ["net"] } +ruxtask = { path = "../ruxtask" } +ruxdriver = { path = "../ruxdriver", features = ["net"] } axio = { path = "../../crates/axio" } [dependencies.smoltcp] diff --git a/modules/axnet/src/lib.rs b/modules/axnet/src/lib.rs index 892ab591f..e744facda 100644 --- a/modules/axnet/src/lib.rs +++ b/modules/axnet/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) network module. +//! [Ruxos](https://github.com/syswonder/ruxos) network module. //! //! It provides unified networking primitives for TCP/UDP communication //! using various underlying network stacks. Currently, only [smoltcp] is @@ -46,7 +46,7 @@ pub use self::net_impl::UdpSocket; pub use self::net_impl::{bench_receive, bench_transmit}; pub use self::net_impl::{dns_query, poll_interfaces}; -use axdriver::{prelude::*, AxDeviceContainer}; +use ruxdriver::{prelude::*, AxDeviceContainer}; /// Initializes the network subsystem by NIC devices. pub fn init_network(mut net_devs: AxDeviceContainer) { diff --git a/modules/axnet/src/smoltcp_impl/addr.rs b/modules/axnet/src/smoltcp_impl/addr.rs index f586ec281..928e7fb50 100644 --- a/modules/axnet/src/smoltcp_impl/addr.rs +++ b/modules/axnet/src/smoltcp_impl/addr.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axnet/src/smoltcp_impl/bench.rs b/modules/axnet/src/smoltcp_impl/bench.rs index 19ce75c77..58c934d7e 100644 --- a/modules/axnet/src/smoltcp_impl/bench.rs +++ b/modules/axnet/src/smoltcp_impl/bench.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axnet/src/smoltcp_impl/dns.rs b/modules/axnet/src/smoltcp_impl/dns.rs index ffd1714d8..00b7c0575 100644 --- a/modules/axnet/src/smoltcp_impl/dns.rs +++ b/modules/axnet/src/smoltcp_impl/dns.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -77,7 +77,7 @@ impl DnsSocket { } return Ok(res); } - Err(AxError::WouldBlock) => axtask::yield_now(), + Err(AxError::WouldBlock) => ruxtask::yield_now(), Err(e) => return Err(e), } } diff --git a/modules/axnet/src/smoltcp_impl/listen_table.rs b/modules/axnet/src/smoltcp_impl/listen_table.rs index 58341e4c7..a89b20d02 100644 --- a/modules/axnet/src/smoltcp_impl/listen_table.rs +++ b/modules/axnet/src/smoltcp_impl/listen_table.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axnet/src/smoltcp_impl/mod.rs b/modules/axnet/src/smoltcp_impl/mod.rs index 3817d7859..da911f2f7 100644 --- a/modules/axnet/src/smoltcp_impl/mod.rs +++ b/modules/axnet/src/smoltcp_impl/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -18,11 +18,11 @@ use alloc::vec; use core::cell::RefCell; use core::ops::DerefMut; -use axdriver::prelude::*; -use axhal::time::{current_time_nanos, NANOS_PER_MICROS}; use axsync::Mutex; use driver_net::{DevError, NetBufPtr}; use lazy_init::LazyInit; +use ruxdriver::prelude::*; +use ruxhal::time::{current_time_nanos, NANOS_PER_MICROS}; use smoltcp::iface::{Config, Interface, SocketHandle, SocketSet}; use smoltcp::phy::{Device, DeviceCapabilities, Medium, RxToken, TxToken}; use smoltcp::socket::{self, AnySocket}; @@ -44,8 +44,8 @@ macro_rules! env_or_default { }; } -const IP: &str = env_or_default!("AX_IP"); -const GATEWAY: &str = env_or_default!("AX_GW"); +const IP: &str = env_or_default!("RUX_IP"); +const GATEWAY: &str = env_or_default!("RUX_GW"); const DNS_SEVER: &str = "8.8.8.8"; const IP_PREFIX: u8 = 24; diff --git a/modules/axnet/src/smoltcp_impl/tcp.rs b/modules/axnet/src/smoltcp_impl/tcp.rs index b3da5d079..a115ce365 100644 --- a/modules/axnet/src/smoltcp_impl/tcp.rs +++ b/modules/axnet/src/smoltcp_impl/tcp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -494,7 +494,7 @@ impl TcpSocket { SOCKET_SET.poll_interfaces(); match f() { Ok(t) => return Ok(t), - Err(AxError::WouldBlock) => axtask::yield_now(), + Err(AxError::WouldBlock) => ruxtask::yield_now(), Err(e) => return Err(e), } } diff --git a/modules/axnet/src/smoltcp_impl/udp.rs b/modules/axnet/src/smoltcp_impl/udp.rs index fae4f93f6..69b703de9 100644 --- a/modules/axnet/src/smoltcp_impl/udp.rs +++ b/modules/axnet/src/smoltcp_impl/udp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -272,7 +272,7 @@ impl UdpSocket { SOCKET_SET.poll_interfaces(); match f() { Ok(t) => return Ok(t), - Err(AxError::WouldBlock) => axtask::yield_now(), + Err(AxError::WouldBlock) => ruxtask::yield_now(), Err(e) => return Err(e), } } diff --git a/modules/axruntime/Cargo.toml b/modules/axruntime/Cargo.toml deleted file mode 100644 index c09502af4..000000000 --- a/modules/axruntime/Cargo.toml +++ /dev/null @@ -1,50 +0,0 @@ -[package] -name = "axruntime" -version = "0.1.0" -edition = "2021" -authors = ["Yuekai Jia "] -description = "Runtime library of ArceOS" -license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axruntime" -documentation = "https://rcore-os.github.io/arceos/axruntime/index.html" - -[features] -default = [] - -smp = ["axhal/smp"] -irq = ["axhal/irq", "axtask?/irq", "percpu", "kernel_guard"] -tls = ["axhal/tls", "axtask?/tls"] -alloc = ["axalloc", "dtb"] -paging = ["axhal/paging", "lazy_init"] -rtc = ["axhal/rtc"] - -multitask = ["axtask/multitask"] -fs = ["axdriver", "axfs"] -blkfs = ["fs"] -virtio-9p = ["fs", "ax9p"] -net-9p = ["fs", "ax9p"] -net = ["axdriver", "axnet"] -display = ["axdriver", "axdisplay"] -signal = [] - -musl = [] - -[dependencies] -cfg-if = "1.0" -axhal = { path = "../axhal" } -axlog = { path = "../axlog" } -axconfig = { path = "../axconfig" } -axalloc = { path = "../axalloc", optional = true } -axdriver = { path = "../axdriver", optional = true } -axfs = { path = "../axfs", optional = true } -ax9p = { path = "../ax9p", optional = true } -axnet = { path = "../axnet", optional = true } -axdisplay = { path = "../axdisplay", optional = true } -axtask = { path = "../axtask", optional = true } - -crate_interface = { path = "../../crates/crate_interface" } -percpu = { path = "../../crates/percpu", optional = true } -kernel_guard = { path = "../../crates/kernel_guard", optional = true } -lazy_init = { path = "../../crates/lazy_init", optional = true } -dtb = { path = "../../crates/dtb", optional = true} diff --git a/modules/axsync/Cargo.toml b/modules/axsync/Cargo.toml index 50a4203c3..c3359fdd0 100644 --- a/modules/axsync/Cargo.toml +++ b/modules/axsync/Cargo.toml @@ -10,14 +10,14 @@ repository = "https://github.com/rcore-os/arceos/tree/main/modules/axsync" documentation = "https://rcore-os.github.io/arceos/axsync/index.html" [features] -multitask = ["axtask/multitask"] +multitask = ["ruxtask/multitask"] default = [] [dependencies] spinlock = { path = "../../crates/spinlock" } -axtask = { path = "../axtask" } +ruxtask = { path = "../ruxtask" } [dev-dependencies] rand = "0.8" axsync = { path = ".", features = ["multitask"] } -axtask = { path = "../axtask", features = ["test"] } +ruxtask = { path = "../ruxtask", features = ["test"] } diff --git a/modules/axsync/src/lib.rs b/modules/axsync/src/lib.rs index b8d0918e3..32c62e199 100644 --- a/modules/axsync/src/lib.rs +++ b/modules/axsync/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) synchronization primitives. +//! [Ruxos](https://github.com/syswonder/ruxos) synchronization primitives. //! //! Currently supported primitives: //! diff --git a/modules/axsync/src/mutex.rs b/modules/axsync/src/mutex.rs index f5fa745c2..25eb18815 100644 --- a/modules/axsync/src/mutex.rs +++ b/modules/axsync/src/mutex.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -14,7 +14,7 @@ use core::fmt; use core::ops::{Deref, DerefMut}; use core::sync::atomic::{AtomicU64, Ordering}; -use axtask::{current, WaitQueue}; +use ruxtask::{current, WaitQueue}; /// A mutual exclusion primitive useful for protecting shared data, similar to /// [`std::sync::Mutex`](https://doc.rust-lang.org/std/sync/struct.Mutex.html). @@ -209,7 +209,7 @@ impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { #[cfg(test)] mod tests { use crate::Mutex; - use axtask as thread; + use ruxtask as thread; use std::sync::Once; static INIT: Once = Once::new(); diff --git a/modules/rux9p/Cargo.toml b/modules/rux9p/Cargo.toml new file mode 100644 index 000000000..a792d24f1 --- /dev/null +++ b/modules/rux9p/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "rux9p" +version = "0.1.0" +edition = "2021" +authors = ["Zheng Wu "] +description = "RuxOS Plan-9 filesystem module" +license = "GPL-3.0-or-later OR Apache-2.0" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/rux9p" + +[features] +virtio-9p = ["ruxdriver/virtio-9p", "ruxdriver/virtio-9p"] +net-9p = ["axnet", "driver_common", "ruxdriver/dyn" , "ruxdriver/_9p"] +need_auth = [] + +[dependencies] +log = "0.4" +spin = "0.9" +driver_9p = { path = "../../crates/driver_9p"} +axfs_vfs = { path = "../../crates/axfs_vfs"} +driver_common = { path = "../../crates/driver_common", optional = true} + +ruxfs = { path = "../ruxfs"} +axnet = { path = "../axnet", optional = true} +ruxdriver = { path = "../ruxdriver"} \ No newline at end of file diff --git a/modules/ax9p/src/drv.rs b/modules/rux9p/src/drv.rs similarity index 99% rename from modules/ax9p/src/drv.rs rename to modules/rux9p/src/drv.rs index 7330e602b..1da41c98c 100644 --- a/modules/ax9p/src/drv.rs +++ b/modules/rux9p/src/drv.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,8 +10,8 @@ #![allow(dead_code)] use alloc::{string::String, string::ToString, sync::Arc, vec, vec::Vec}; -use axdriver::prelude::*; use log::*; +use ruxdriver::prelude::*; use spin::RwLock; const EIO: u8 = 5; diff --git a/modules/ax9p/src/fs.rs b/modules/rux9p/src/fs.rs similarity index 98% rename from modules/ax9p/src/fs.rs rename to modules/rux9p/src/fs.rs index 3dd5da9b3..a1ee8bfac 100644 --- a/modules/ax9p/src/fs.rs +++ b/modules/rux9p/src/fs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! 9P filesystem used by [RukOS](https://github.com/rcore-os/arceos). +//! 9P filesystem used by [Ruxos](https://github.com/syswonder/ruxos). //! //! The implementation is based on [`axfs_vfs`]. use crate::drv::{self, Drv9pOps}; @@ -70,13 +70,13 @@ impl _9pFileSystem { // AUTH afid #[cfg(feature = "need_auth")] handle_result!( - dev.write().tauth(AFID, "rukos", "/"), + dev.write().tauth(AFID, "ruxos", "/"), "9pfs auth failed! error code: {}" ); // attach dir to fid handle_result!( - dev.write().tattach(fid, AFID, "rukos", aname), + dev.write().tattach(fid, AFID, "ruxos", aname), "9pfs attach failed! error code: {}" ); diff --git a/modules/ax9p/src/lib.rs b/modules/rux9p/src/lib.rs similarity index 91% rename from modules/ax9p/src/lib.rs rename to modules/rux9p/src/lib.rs index 50e891e67..46d0d200f 100644 --- a/modules/ax9p/src/lib.rs +++ b/modules/rux9p/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [RukOS](https://github.com/syswonder/rukos) 9p module. +//! [RuxOS](https://github.com/syswonder/ruxos) 9p module. //! //! Implement `net-9p` and `virtio-9p` //! Shouldn't mount file or directory with the same path as file or directory in 9P host @@ -28,12 +28,12 @@ mod fs; mod netdev; use alloc::sync::Arc; -use axfs::MountPoint; use log::*; +use ruxfs::MountPoint; use spin::RwLock; #[cfg(feature = "virtio-9p")] -use axdriver::{prelude::*, AxDeviceContainer}; +use ruxdriver::{prelude::*, AxDeviceContainer}; #[cfg(feature = "net-9p")] use { alloc::{boxed::Box, vec::Vec}, @@ -70,7 +70,7 @@ pub fn init_net_9pfs(ip_port: &str, aname: &str, protocol: &str) -> MountPoint { }; info!("use 9pfs device 0: {:?}", net9p.device_name()); - // Enabling `dyn` feature in axdriver, pub type Ax9pDevice = Box; + // Enabling `dyn` feature in ruxdriver, pub type Ax9pDevice = Box; // TODO: consider a more elegant implement. let net9p_driver = self::drv::Drv9pOps::new(Box::new(net9p)); let n9p_fs = self::fs::_9pFileSystem::new(Arc::new(RwLock::new(net9p_driver)), aname, protocol); diff --git a/modules/ax9p/src/netdev.rs b/modules/rux9p/src/netdev.rs similarity index 98% rename from modules/ax9p/src/netdev.rs rename to modules/rux9p/src/netdev.rs index e8321dd0a..53d28d997 100644 --- a/modules/ax9p/src/netdev.rs +++ b/modules/rux9p/src/netdev.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/ruxconfig/Cargo.toml b/modules/ruxconfig/Cargo.toml new file mode 100644 index 000000000..ab77686db --- /dev/null +++ b/modules/ruxconfig/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "ruxconfig" +version = "0.1.0" +edition = "2021" +authors = ["Yuekai Jia "] +description = "Platform-specific constants and parameters for Ruxos" +license = "GPL-3.0-or-later OR Apache-2.0" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxconfig" + +[build-dependencies] +toml_edit = "0.19" +serde = "1.0" diff --git a/modules/axconfig/build.rs b/modules/ruxconfig/build.rs similarity index 95% rename from modules/axconfig/build.rs rename to modules/ruxconfig/build.rs index e29437914..2ce36af0f 100644 --- a/modules/axconfig/build.rs +++ b/modules/ruxconfig/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -107,7 +107,7 @@ fn gen_config_rs(config_path: &Path) -> Result> { add_config( &mut config, "smp", - toml_edit::value(std::env::var("AX_SMP").unwrap_or("1".into())), + toml_edit::value(std::env::var("RUX_SMP").unwrap_or("1".into())), Some("# Number of CPUs"), ); @@ -163,7 +163,7 @@ fn gen_config_rs(config_path: &Path) -> Result> { } fn main() -> Result<()> { - let platform = option_env!("AX_PLATFORM"); + let platform = option_env!("RUX_PLATFORM"); let config_path = resolve_config_path(platform)?; println!("Reading config file: {:?}", config_path); @@ -175,7 +175,7 @@ fn main() -> Result<()> { std::fs::write(out_path, config_rs)?; println!("cargo:rerun-if-changed={}", config_path.display()); - println!("cargo:rerun-if-env-changed=AX_PLATFORM"); - println!("cargo:rerun-if-env-changed=AX_SMP"); + println!("cargo:rerun-if-env-changed=RUX_PLATFORM"); + println!("cargo:rerun-if-env-changed=RUX_SMP"); Ok(()) } diff --git a/modules/axconfig/defconfig.toml b/modules/ruxconfig/defconfig.toml similarity index 100% rename from modules/axconfig/defconfig.toml rename to modules/ruxconfig/defconfig.toml diff --git a/modules/axconfig/src/lib.rs b/modules/ruxconfig/src/lib.rs similarity index 77% rename from modules/axconfig/src/lib.rs rename to modules/ruxconfig/src/lib.rs index 9dedc41fd..ff18cc9e3 100644 --- a/modules/axconfig/src/lib.rs +++ b/modules/ruxconfig/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,13 +7,13 @@ * See the Mulan PSL v2 for more details. */ -//! Platform-specific constants and parameters for [ArceOS]. +//! Platform-specific constants and parameters for [Ruxos]. //! //! Currently supported platforms can be found in the [platforms] directory of -//! the [ArceOS] root. +//! the [Ruxos] root. //! -//! [ArceOS]: https://github.com/rcore-os/arceos -//! [platforms]: https://github.com/rcore-os/arceos/tree/main/platforms +//! [Ruxos]: https://github.com/syswonder/ruxos +//! [platforms]: https://github.com/syswonder/ruxos/tree/main/platforms #![no_std] diff --git a/modules/ruxdisplay/Cargo.toml b/modules/ruxdisplay/Cargo.toml new file mode 100644 index 000000000..d4daaef87 --- /dev/null +++ b/modules/ruxdisplay/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "ruxdisplay" +version = "0.1.0" +edition = "2021" +authors = ["Shiping Yuan "] +description = "Ruxos graphics module" +license = "GPL-3.0-or-later OR Apache-2.0" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxdisplay" + +[dependencies] +log = "0.4" +ruxdriver = { path = "../ruxdriver", features = ["display"] } +lazy_init = { path = "../../crates/lazy_init" } +axsync = { path = "../axsync" } +driver_display = { path = "../../crates/driver_display" } diff --git a/modules/axdisplay/src/lib.rs b/modules/ruxdisplay/src/lib.rs similarity index 89% rename from modules/axdisplay/src/lib.rs rename to modules/ruxdisplay/src/lib.rs index 1ec45d639..83d39c394 100644 --- a/modules/axdisplay/src/lib.rs +++ b/modules/ruxdisplay/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) graphics module. +//! [Ruxos](https://github.com/syswonder/ruxos) graphics module. //! //! Currently only supports direct writing to the framebuffer. @@ -19,9 +19,9 @@ extern crate log; #[doc(no_inline)] pub use driver_display::DisplayInfo; -use axdriver::{prelude::*, AxDeviceContainer}; use axsync::Mutex; use lazy_init::LazyInit; +use ruxdriver::{prelude::*, AxDeviceContainer}; static MAIN_DISPLAY: LazyInit> = LazyInit::new(); diff --git a/modules/axdriver/Cargo.toml b/modules/ruxdriver/Cargo.toml similarity index 66% rename from modules/axdriver/Cargo.toml rename to modules/ruxdriver/Cargo.toml index 3a7afdd61..b90a247c6 100644 --- a/modules/axdriver/Cargo.toml +++ b/modules/ruxdriver/Cargo.toml @@ -1,25 +1,28 @@ [package] -name = "axdriver" +name = "ruxdriver" version = "0.1.0" edition = "2021" -authors = ["Yuekai Jia ", "ChengXiang Qi "] -description = "ArceOS device drivers" +authors = [ + "Yuekai Jia ", + "ChengXiang Qi ", + "Zheng Wu ", +] +description = "Ruxos device drivers" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axdriver" -documentation = "https://rcore-os.github.io/arceos/axdriver/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxdriver" [features] dyn = [] bus-mmio = [] -bus-pci = ["dep:driver_pci", "dep:axhal", "dep:axconfig"] +bus-pci = ["dep:driver_pci", "dep:ruxhal", "dep:ruxconfig"] net = ["driver_net"] block = ["driver_block"] display = ["driver_display"] _9p = ["driver_9p"] # Enabled by features `virtio-*` -virtio = ["driver_virtio", "dep:axalloc", "dep:axhal", "dep:axconfig"] +virtio = ["driver_virtio", "dep:axalloc", "dep:ruxhal", "dep:ruxconfig"] # various types of drivers virtio-blk = ["block", "virtio", "driver_virtio/block"] @@ -28,7 +31,7 @@ virtio-gpu = ["display", "virtio", "driver_virtio/gpu"] virtio-9p = ["_9p","virtio", "driver_virtio/v9p"] ramdisk = ["block", "driver_block/ramdisk"] bcm2835-sdhci = ["block", "driver_block/bcm2835-sdhci"] -ixgbe = ["net", "driver_net/ixgbe", "dep:axalloc", "dep:axhal"] +ixgbe = ["net", "driver_net/ixgbe", "dep:axalloc", "dep:ruxhal"] # more devices example: e1000 = ["net", "driver_net/e1000"] default = ["bus-mmio"] @@ -44,5 +47,5 @@ driver_9p = { path = "../../crates/driver_9p", optional = true } driver_pci = { path = "../../crates/driver_pci", optional = true } driver_virtio = { path = "../../crates/driver_virtio", optional = true } axalloc = { path = "../axalloc", optional = true } -axhal = { path = "../axhal", optional = true } -axconfig = { path = "../axconfig", optional = true } +ruxhal = { path = "../ruxhal", optional = true } +ruxconfig = { path = "../ruxconfig", optional = true } diff --git a/modules/axdriver/build.rs b/modules/ruxdriver/build.rs similarity index 97% rename from modules/axdriver/build.rs rename to modules/ruxdriver/build.rs index 61ddfdfd6..6e1c859a8 100644 --- a/modules/axdriver/build.rs +++ b/modules/ruxdriver/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/bus/mmio.rs b/modules/ruxdriver/src/bus/mmio.rs similarity index 92% rename from modules/axdriver/src/bus/mmio.rs rename to modules/ruxdriver/src/bus/mmio.rs index 8253e3ac2..498a4d487 100644 --- a/modules/axdriver/src/bus/mmio.rs +++ b/modules/ruxdriver/src/bus/mmio.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -14,7 +14,7 @@ impl AllDevices { pub(crate) fn probe_bus_devices(&mut self) { // TODO: parse device tree #[cfg(feature = "virtio")] - for reg in axconfig::VIRTIO_MMIO_REGIONS { + for reg in ruxconfig::VIRTIO_MMIO_REGIONS { for_each_drivers!(type Driver, { if let Some(dev) = Driver::probe_mmio(reg.0, reg.1) { info!( diff --git a/modules/axdriver/src/bus/mod.rs b/modules/ruxdriver/src/bus/mod.rs similarity index 92% rename from modules/axdriver/src/bus/mod.rs rename to modules/ruxdriver/src/bus/mod.rs index abad3c9b4..0b1be6fa7 100644 --- a/modules/axdriver/src/bus/mod.rs +++ b/modules/ruxdriver/src/bus/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/bus/pci.rs b/modules/ruxdriver/src/bus/pci.rs similarity index 94% rename from modules/axdriver/src/bus/pci.rs rename to modules/ruxdriver/src/bus/pci.rs index 585cfa131..5007166b4 100644 --- a/modules/axdriver/src/bus/pci.rs +++ b/modules/ruxdriver/src/bus/pci.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,10 +8,10 @@ */ use crate::{prelude::*, AllDevices}; -use axhal::mem::phys_to_virt; use driver_pci::{ BarInfo, Cam, Command, DeviceFunction, HeaderType, MemoryBarType, PciRangeAllocator, PciRoot, }; +use ruxhal::mem::phys_to_virt; const PCI_BAR_NUM: u8 = 6; @@ -93,15 +93,15 @@ fn config_pci_device( impl AllDevices { pub(crate) fn probe_bus_devices(&mut self) { - let base_vaddr = phys_to_virt(axconfig::PCI_ECAM_BASE.into()); + let base_vaddr = phys_to_virt(ruxconfig::PCI_ECAM_BASE.into()); let mut root = unsafe { PciRoot::new(base_vaddr.as_mut_ptr(), Cam::Ecam) }; // PCI 32-bit MMIO space - let mut allocator = axconfig::PCI_RANGES + let mut allocator = ruxconfig::PCI_RANGES .get(1) .map(|range| PciRangeAllocator::new(range.0 as u64, range.1 as u64)); - for bus in 0..=axconfig::PCI_BUS_END as u8 { + for bus in 0..=ruxconfig::PCI_BUS_END as u8 { for (bdf, dev_info) in root.enumerate_bus(bus) { debug!("PCI {}: {}", bdf, dev_info); if dev_info.header_type != HeaderType::Standard { diff --git a/modules/axdriver/src/drivers.rs b/modules/ruxdriver/src/drivers.rs similarity index 98% rename from modules/axdriver/src/drivers.rs rename to modules/ruxdriver/src/drivers.rs index a5a7a38b7..7fe1115bc 100644 --- a/modules/axdriver/src/drivers.rs +++ b/modules/ruxdriver/src/drivers.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -99,7 +99,7 @@ cfg_if::cfg_if! { cfg_if::cfg_if! { if #[cfg(net_dev = "ixgbe")] { use crate::ixgbe::IxgbeHalImpl; - use axhal::mem::phys_to_virt; + use ruxhal::mem::phys_to_virt; pub struct IxgbeDriver; register_net_driver!(IxgbeDriver, driver_net::ixgbe::IxgbeNic); impl DriverProbe for IxgbeDriver { diff --git a/modules/axdriver/src/dummy.rs b/modules/ruxdriver/src/dummy.rs similarity index 99% rename from modules/axdriver/src/dummy.rs rename to modules/ruxdriver/src/dummy.rs index 4f4d2a937..ba13b8f13 100644 --- a/modules/axdriver/src/dummy.rs +++ b/modules/ruxdriver/src/dummy.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/ixgbe.rs b/modules/ruxdriver/src/ixgbe.rs similarity index 92% rename from modules/axdriver/src/ixgbe.rs rename to modules/ruxdriver/src/ixgbe.rs index 06249aa39..e42b76fcb 100644 --- a/modules/axdriver/src/ixgbe.rs +++ b/modules/ruxdriver/src/ixgbe.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,9 +8,9 @@ */ use axalloc::global_allocator; -use axhal::mem::{phys_to_virt, virt_to_phys}; use core::{alloc::Layout, ptr::NonNull}; use driver_net::ixgbe::{IxgbeHal, PhysAddr as IxgbePhysAddr}; +use ruxhal::mem::{phys_to_virt, virt_to_phys}; pub struct IxgbeHalImpl; @@ -41,7 +41,7 @@ unsafe impl IxgbeHal for IxgbeHalImpl { } fn wait_until(duration: core::time::Duration) -> Result<(), &'static str> { - axhal::time::busy_wait_until(duration); + ruxhal::time::busy_wait_until(duration); Ok(()) } } diff --git a/modules/axdriver/src/lib.rs b/modules/ruxdriver/src/lib.rs similarity index 98% rename from modules/axdriver/src/lib.rs rename to modules/ruxdriver/src/lib.rs index 774fc616e..32343e0e7 100644 --- a/modules/axdriver/src/lib.rs +++ b/modules/ruxdriver/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) device drivers. +//! [Ruxos](https://github.com/syswonder/ruxos) device drivers. //! //! # Usage //! diff --git a/modules/axdriver/src/macros.rs b/modules/ruxdriver/src/macros.rs similarity index 98% rename from modules/axdriver/src/macros.rs rename to modules/ruxdriver/src/macros.rs index 3776fa1ab..e9aa44192 100644 --- a/modules/axdriver/src/macros.rs +++ b/modules/ruxdriver/src/macros.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/prelude.rs b/modules/ruxdriver/src/prelude.rs similarity index 95% rename from modules/axdriver/src/prelude.rs rename to modules/ruxdriver/src/prelude.rs index 0fa32c74e..3b9d0e176 100644 --- a/modules/axdriver/src/prelude.rs +++ b/modules/ruxdriver/src/prelude.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/structs/dyn.rs b/modules/ruxdriver/src/structs/dyn.rs similarity index 98% rename from modules/axdriver/src/structs/dyn.rs rename to modules/ruxdriver/src/structs/dyn.rs index 4dda46dfe..dbb70bc95 100644 --- a/modules/axdriver/src/structs/dyn.rs +++ b/modules/ruxdriver/src/structs/dyn.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/structs/mod.rs b/modules/ruxdriver/src/structs/mod.rs similarity index 97% rename from modules/axdriver/src/structs/mod.rs rename to modules/ruxdriver/src/structs/mod.rs index a2380be52..888188dc3 100644 --- a/modules/axdriver/src/structs/mod.rs +++ b/modules/ruxdriver/src/structs/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/structs/static.rs b/modules/ruxdriver/src/structs/static.rs similarity index 98% rename from modules/axdriver/src/structs/static.rs rename to modules/ruxdriver/src/structs/static.rs index 6d5c48dc5..c6eaa168f 100644 --- a/modules/axdriver/src/structs/static.rs +++ b/modules/ruxdriver/src/structs/static.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axdriver/src/virtio.rs b/modules/ruxdriver/src/virtio.rs similarity index 98% rename from modules/axdriver/src/virtio.rs rename to modules/ruxdriver/src/virtio.rs index cede00baa..cf30b49e4 100644 --- a/modules/axdriver/src/virtio.rs +++ b/modules/ruxdriver/src/virtio.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,10 +11,10 @@ use core::marker::PhantomData; use core::ptr::NonNull; use axalloc::global_allocator; -use axhal::mem::{phys_to_virt, virt_to_phys}; use cfg_if::cfg_if; use driver_common::{BaseDriverOps, DevResult, DeviceType}; use driver_virtio::{BufferDirection, PhysAddr, VirtIoHal}; +use ruxhal::mem::{phys_to_virt, virt_to_phys}; use crate::{drivers::DriverProbe, AxDeviceEnum}; diff --git a/modules/axfs/Cargo.toml b/modules/ruxfs/Cargo.toml similarity index 64% rename from modules/axfs/Cargo.toml rename to modules/ruxfs/Cargo.toml index 46df7ff33..91d3356c7 100644 --- a/modules/axfs/Cargo.toml +++ b/modules/ruxfs/Cargo.toml @@ -1,24 +1,29 @@ [package] -name = "axfs" +name = "ruxfs" version = "0.1.0" edition = "2021" -authors = ["Yuekai Jia "] -description = "ArceOS filesystem module" +authors = [ + "Yuekai Jia ", + "Zheng Wu ", +] +description = "Ruxos filesystem module" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axfs" -documentation = "https://rcore-os.github.io/arceos/axfs/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxfs" [features] devfs = ["dep:axfs_devfs"] ramfs = ["dep:axfs_ramfs"] procfs = ["dep:axfs_ramfs"] sysfs = ["dep:axfs_ramfs"] +etcfs = ["dep:axfs_ramfs"] fatfs = ["dep:fatfs"] myfs = ["dep:crate_interface"] use-ramdisk = [] +alloc = ["axalloc"] +fp_simd = [] -default = ["devfs", "ramfs", "fatfs", "procfs", "sysfs"] +default = ["devfs", "ramfs", "fatfs", "procfs", "sysfs", "etcfs"] [dependencies] log = "0.4" @@ -31,9 +36,11 @@ axerrno = { path = "../../crates/axerrno" } axfs_vfs = { path = "../../crates/axfs_vfs" } axfs_devfs = { path = "../../crates/axfs_devfs", optional = true } axfs_ramfs = { path = "../../crates/axfs_ramfs", optional = true } -axdriver = { path = "../axdriver", features = ["block"] } +ruxdriver = { path = "../ruxdriver", features = ["block"] } axsync = { path = "../axsync" } crate_interface = { path = "../../crates/crate_interface", optional = true } +axalloc = { path = "../axalloc", optional = true } +memory_addr = { path = "../../crates/memory_addr" } [dependencies.fatfs] git = "https://github.com/rafalh/rust-fatfs" @@ -48,7 +55,7 @@ features = [ # no std ] [dev-dependencies] -axdriver = { path = "../axdriver", features = ["block", "ramdisk"] } +ruxdriver = { path = "../ruxdriver", features = ["block", "ramdisk"] } driver_block = { path = "../../crates/driver_block", features = ["ramdisk"] } axsync = { path = "../axsync", features = ["multitask"] } -axtask = { path = "../axtask", features = ["test"] } +ruxtask = { path = "../ruxtask", features = ["test"] } diff --git a/modules/axfs/resources/create_test_img.sh b/modules/ruxfs/resources/create_test_img.sh similarity index 100% rename from modules/axfs/resources/create_test_img.sh rename to modules/ruxfs/resources/create_test_img.sh diff --git a/modules/axfs/resources/fat16.img b/modules/ruxfs/resources/fat16.img similarity index 99% rename from modules/axfs/resources/fat16.img rename to modules/ruxfs/resources/fat16.img index 6a220b4f3..fba7a5cd0 100644 Binary files a/modules/axfs/resources/fat16.img and b/modules/ruxfs/resources/fat16.img differ diff --git a/modules/axfs/src/api/dir.rs b/modules/ruxfs/src/api/dir.rs similarity index 99% rename from modules/axfs/src/api/dir.rs rename to modules/ruxfs/src/api/dir.rs index 4ef49859a..ea84986f3 100644 --- a/modules/axfs/src/api/dir.rs +++ b/modules/ruxfs/src/api/dir.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axfs/src/api/file.rs b/modules/ruxfs/src/api/file.rs similarity index 99% rename from modules/axfs/src/api/file.rs rename to modules/ruxfs/src/api/file.rs index 0236597f7..ea4eecdf0 100644 --- a/modules/axfs/src/api/file.rs +++ b/modules/ruxfs/src/api/file.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axfs/src/api/mod.rs b/modules/ruxfs/src/api/mod.rs similarity index 98% rename from modules/axfs/src/api/mod.rs rename to modules/ruxfs/src/api/mod.rs index a018b1354..f81c375cf 100644 --- a/modules/axfs/src/api/mod.rs +++ b/modules/ruxfs/src/api/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/ruxfs/src/arch/aarch64.rs b/modules/ruxfs/src/arch/aarch64.rs new file mode 100644 index 000000000..a38c1de81 --- /dev/null +++ b/modules/ruxfs/src/arch/aarch64.rs @@ -0,0 +1,45 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Rukos] is licensed under Mulan PSL v2. + * 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. + */ + +use alloc::format; +use alloc::string::String; + +fn read_cpuid() -> u64 { + let val: u64; + unsafe { + core::arch::asm!("mrs {}, midr_el1", out(reg) val); + } + val +} + +pub fn get_cpuinfo() -> String { + let cpuid = read_cpuid(); + let mut cpuinfo = String::new(); + + cpuinfo.push_str( + format!( + "Processor\t: {} rev {} ({})\n", + "AArch64 Processor", + cpuid & 15, + "aarch64" + ) + .as_ref(), + ); + cpuinfo.push_str("Features\t: "); + #[cfg(feature = "fp_simd")] + cpuinfo.push_str("fp asimd"); + + cpuinfo.push_str(format!("\nCPU implementer\t: {:#02x}\n", cpuid >> 24).as_ref()); + cpuinfo.push_str("CPU architecture: AArch64\n"); + cpuinfo.push_str(format!("CPU variant\t: {:#x}\n", (cpuid >> 20) & 15).as_ref()); + cpuinfo.push_str(format!("CPU part\t: {:#03x}\n", (cpuid >> 4) & 0xfff).as_ref()); + cpuinfo.push_str(format!("CPU revision\t: {}\n", cpuid & 15).as_ref()); + + cpuinfo +} diff --git a/modules/ruxfs/src/arch/mod.rs b/modules/ruxfs/src/arch/mod.rs new file mode 100644 index 000000000..9f1709f86 --- /dev/null +++ b/modules/ruxfs/src/arch/mod.rs @@ -0,0 +1,49 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Rukos] is licensed under Mulan PSL v2. + * 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. + */ + +use alloc::format; +use alloc::string::String; + +#[cfg(target_arch = "x86_64")] +mod x86_64; + +#[cfg(target_arch = "aarch64")] +mod aarch64; + +pub fn get_cpuinfo() -> String { + cfg_if::cfg_if! { + if #[cfg(target_arch = "aarch64")] { + aarch64::get_cpuinfo() + } else if #[cfg(target_arch = "x86_64")] { + x86_64::get_cpuinfo() + } else { + String::new() + } + } +} + +pub fn get_meminfo() -> String { + #[cfg(feature = "alloc")] + { + use core::ffi::c_ulong; + let allocator = axalloc::global_allocator(); + let freeram = (allocator.available_bytes() + + allocator.available_pages() * memory_addr::PAGE_SIZE_4K) + as c_ulong; + let totalram = freeram + allocator.used_bytes() as c_ulong; + + let mut meminfo = String::new(); + meminfo.push_str(format!("MemTotal: {:8}\n", totalram).as_ref()); + meminfo.push_str(format!("MemFree: {:8}\n", freeram).as_ref()); + + meminfo + } + #[cfg(not(feature = "alloc"))] + String::new() +} diff --git a/modules/ruxfs/src/arch/x86_64.rs b/modules/ruxfs/src/arch/x86_64.rs new file mode 100644 index 000000000..3d78ac27a --- /dev/null +++ b/modules/ruxfs/src/arch/x86_64.rs @@ -0,0 +1,117 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Rukos] is licensed under Mulan PSL v2. + * 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. + */ + +use alloc::format; +use alloc::string::String; +use core::arch::x86_64::__cpuid; + +#[derive(Default)] +struct CpuinfoX86 { + x86_family: u8, + x86_model: u8, + x86_mask: u8, + cpuid_level: i32, // Maximum supported CPUID level, -1=no CPUID + x86_model_id: [u32; 16], + extended_cpuid_level: u32, // Max extended CPUID function supported +} + +impl CpuinfoX86 { + fn get_model_name(&self) -> [u8; 64] { + let mut model_name = [0; 64]; + for i in 0..16 { + let bytes = self.x86_model_id[i].to_le_bytes(); + model_name[i * 4..i * 4 + 4].copy_from_slice(bytes.as_ref()); + } + + model_name + } +} + +/// Identifies and stores CPU's family, model, mask, +/// and the highest supported standard and extended CPUID levels. +fn cpu_dect(c: &mut CpuinfoX86) { + // Get vendor name + let eax = read_cpuid_eax(0x00000000); + c.cpuid_level = eax as i32; + + // Set default x86 family + c.x86_family = 4; + if c.cpuid_level >= 0x00000001 { + let tfms = read_cpuid_eax(0x00000001); + c.x86_family = (tfms >> 8) as u8 & 0xf; + c.x86_model = (tfms >> 4) as u8 & 0xf; + c.x86_mask = tfms as u8 & 0xf; + + if c.x86_family == 0xf { + c.x86_family += (tfms >> 20) as u8; + } + if c.x86_family >= 0x6 { + c.x86_model += ((tfms >> 16) as u8 & 0xf) << 4; + } + } + + c.extended_cpuid_level = read_cpuid_eax(0x80000000); +} + +fn gen_model_name(c: &mut CpuinfoX86) { + if c.extended_cpuid_level < 0x80000004 { + return; + } + + let v = &mut c.x86_model_id; + (v[0], v[1], v[2], v[3]) = read_cpuid(0x80000002); + (v[4], v[5], v[6], v[7]) = read_cpuid(0x80000003); + (v[8], v[9], v[10], v[11]) = read_cpuid(0x80000004); + + v[12] &= 0xffff_ff00; +} + +fn read_cpuid(eax: u32) -> (u32, u32, u32, u32) { + let cpuid_result = unsafe { __cpuid(eax) }; + + ( + cpuid_result.eax, + cpuid_result.ebx, + cpuid_result.ecx, + cpuid_result.edx, + ) +} + +fn read_cpuid_eax(eax: u32) -> u32 { + let cpuid_result = unsafe { __cpuid(eax) }; + + cpuid_result.eax +} + +pub fn get_cpuinfo() -> String { + let mut c = CpuinfoX86::default(); + cpu_dect(&mut c); + gen_model_name(&mut c); + + let mut cpuinfo = String::new(); + cpuinfo.push_str(format!("processor\t: {}\n", 0).as_ref()); + cpuinfo.push_str(format!("cpu family\t: {}\n", c.x86_family).as_ref()); + cpuinfo.push_str(format!("model\t\t: {}\n", c.x86_model).as_ref()); + + let model_bytes = c.get_model_name(); + if model_bytes[0] == 0 { + cpuinfo.push_str("model name\t: unknown\n".as_ref()); + } else { + let model_name = String::from_utf8_lossy(&model_bytes); + cpuinfo.push_str(format!("model name\t: {}\n", model_name).as_ref()); + } + + if c.x86_mask != 0 || c.cpuid_level >= 0 { + cpuinfo.push_str(format!("stepping\t: {}\n", c.x86_mask).as_ref()); + } else { + cpuinfo.push_str("stepping\t: unknown\n".as_ref()); + } + + cpuinfo +} diff --git a/modules/axfs/src/dev.rs b/modules/ruxfs/src/dev.rs similarity index 97% rename from modules/axfs/src/dev.rs rename to modules/ruxfs/src/dev.rs index 8f0e3dfab..d0d8ea201 100644 --- a/modules/axfs/src/dev.rs +++ b/modules/ruxfs/src/dev.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -use axdriver::prelude::*; +use ruxdriver::prelude::*; const BLOCK_SIZE: usize = 512; diff --git a/modules/axfs/src/fops.rs b/modules/ruxfs/src/fops.rs similarity index 99% rename from modules/axfs/src/fops.rs rename to modules/ruxfs/src/fops.rs index b2058bf3c..dfc8b46fc 100644 --- a/modules/axfs/src/fops.rs +++ b/modules/ruxfs/src/fops.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axfs/src/fs/fatfs.rs b/modules/ruxfs/src/fs/fatfs.rs similarity index 93% rename from modules/axfs/src/fs/fatfs.rs rename to modules/ruxfs/src/fs/fatfs.rs index 623ca2a63..102b59afb 100644 --- a/modules/axfs/src/fs/fatfs.rs +++ b/modules/ruxfs/src/fs/fatfs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -84,14 +84,34 @@ impl VfsNodeOps for FileWrapper<'static> { fn read_at(&self, offset: u64, buf: &mut [u8]) -> VfsResult { let mut file = self.0.lock(); - file.seek(SeekFrom::Start(offset)).map_err(as_vfs_err)?; // TODO: more efficient - file.read(buf).map_err(as_vfs_err) + file.seek(SeekFrom::Start(offset)).map_err(as_vfs_err)?; + + let mut total_read = 0; + while total_read < buf.len() { + let read_len = file.read(&mut buf[total_read..]).map_err(as_vfs_err)?; + if read_len == 0 { + break; + } + total_read += read_len; + } + + Ok(total_read) } fn write_at(&self, offset: u64, buf: &[u8]) -> VfsResult { let mut file = self.0.lock(); file.seek(SeekFrom::Start(offset)).map_err(as_vfs_err)?; // TODO: more efficient - file.write(buf).map_err(as_vfs_err) + + let mut total_write = 0; + while total_write < buf.len() { + let write_len = file.write(&buf[total_write..]).map_err(as_vfs_err)?; + if write_len == 0 { + break; + } + total_write += write_len; + } + + Ok(total_write) } fn truncate(&self, size: u64) -> VfsResult { diff --git a/modules/axfs/src/fs/mod.rs b/modules/ruxfs/src/fs/mod.rs similarity index 94% rename from modules/axfs/src/fs/mod.rs rename to modules/ruxfs/src/fs/mod.rs index 0a599703f..1e976b9a2 100644 --- a/modules/axfs/src/fs/mod.rs +++ b/modules/ruxfs/src/fs/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axfs/src/fs/myfs.rs b/modules/ruxfs/src/fs/myfs.rs similarity index 95% rename from modules/axfs/src/fs/myfs.rs rename to modules/ruxfs/src/fs/myfs.rs index 1bdcbd1dc..e1d122273 100644 --- a/modules/axfs/src/fs/myfs.rs +++ b/modules/ruxfs/src/fs/myfs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axfs/src/lib.rs b/modules/ruxfs/src/lib.rs similarity index 90% rename from modules/axfs/src/lib.rs rename to modules/ruxfs/src/lib.rs index c1e767bcf..6db931721 100644 --- a/modules/axfs/src/lib.rs +++ b/modules/ruxfs/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) filesystem module. +//! [Ruxos](https://github.com/syswonder/ruxos) filesystem module. //! //! It provides unified filesystem operations for various filesystems. //! @@ -40,12 +40,15 @@ mod fs; mod mounts; mod root; +#[cfg(feature = "alloc")] +mod arch; + pub mod api; pub mod fops; use alloc::vec::Vec; -use axdriver::{prelude::*, AxDeviceContainer}; +use ruxdriver::{prelude::*, AxDeviceContainer}; cfg_if::cfg_if! { if #[cfg(feature = "myfs")] { @@ -104,6 +107,11 @@ pub fn prepare_commonfs(mount_points: &mut Vec) { #[cfg(feature = "sysfs")] let mount_point = MountPoint::new("/sys", mounts::sysfs().unwrap()); mount_points.push(mount_point); + + // Mount another ramfs as etcfs + #[cfg(feature = "etcfs")] + let mount_point = MountPoint::new("/etc", mounts::etcfs().unwrap()); + mount_points.push(mount_point); } /// Initializes root filesystems. diff --git a/modules/axfs/src/mounts.rs b/modules/ruxfs/src/mounts.rs similarity index 68% rename from modules/axfs/src/mounts.rs rename to modules/ruxfs/src/mounts.rs index bfd663947..c5664eff6 100644 --- a/modules/axfs/src/mounts.rs +++ b/modules/ruxfs/src/mounts.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,6 +10,8 @@ use alloc::sync::Arc; use axfs_vfs::{VfsNodeType, VfsOps, VfsResult}; +#[cfg(feature = "alloc")] +use crate::arch::{get_cpuinfo, get_meminfo}; use crate::fs; #[cfg(feature = "devfs")] @@ -17,10 +19,12 @@ pub(crate) fn devfs() -> Arc { let null = fs::devfs::NullDev; let zero = fs::devfs::ZeroDev; let bar = fs::devfs::ZeroDev; + let random = fs::devfs::RandomDev; let devfs = fs::devfs::DeviceFileSystem::new(); let foo_dir = devfs.mkdir("foo"); devfs.add("null", Arc::new(null)); devfs.add("zero", Arc::new(zero)); + devfs.add("random", Arc::new(random)); foo_dir.add("bar", Arc::new(bar)); Arc::new(devfs) } @@ -35,6 +39,19 @@ pub(crate) fn procfs() -> VfsResult> { let procfs = fs::ramfs::RamFileSystem::new(); let proc_root = procfs.root_dir(); + #[cfg(feature = "alloc")] + { + // Create /proc/cpuinfo + proc_root.create("cpuinfo", VfsNodeType::File)?; + let file_cpuinfo = proc_root.clone().lookup("./cpuinfo")?; + file_cpuinfo.write_at(0, get_cpuinfo().as_bytes())?; + + // Create /proc/meminfo + proc_root.create("meminfo", VfsNodeType::File)?; + let file_meminfo = proc_root.clone().lookup("./meminfo")?; + file_meminfo.write_at(0, get_meminfo().as_bytes())?; + } + // Create /proc/sys/net/core/somaxconn proc_root.create("sys", VfsNodeType::Dir)?; proc_root.create("sys/net", VfsNodeType::Dir)?; @@ -87,3 +104,31 @@ pub(crate) fn sysfs() -> VfsResult> { Ok(Arc::new(sysfs)) } + +#[cfg(feature = "etcfs")] +pub(crate) fn etcfs() -> VfsResult> { + let etcfs = fs::ramfs::RamFileSystem::new(); + let etc_root = etcfs.root_dir(); + + // Create /etc/passwd and /etc/hosts + etc_root.create("passwd", VfsNodeType::File)?; + let file_passwd = etc_root.clone().lookup("passwd")?; + + // format: username:password:uid:gid:allname:homedir:shell + file_passwd.write_at(0, b"root:x:0:0:root:/root:/bin/bash\n")?; + + etc_root.create("hosts", VfsNodeType::File)?; + let file_hosts = etc_root.clone().lookup("hosts")?; + file_hosts.write_at( + 0, + b"127.0.0.1 localhost\n\n\ + ::1 ip6-localhost ip6-loopback \n\ + fe00::0 ip6-localnet \n\ + ff00::0 ip6-mcastprefix \n\ + ff02::1 ip6-allnodes \n\ + ff02::2 ip6-allrouters \n\ + ff02::3 ip6-allhosts\n", + )?; + + Ok(Arc::new(etcfs)) +} diff --git a/modules/axfs/src/root.rs b/modules/ruxfs/src/root.rs similarity index 99% rename from modules/axfs/src/root.rs rename to modules/ruxfs/src/root.rs index b5ac09c7f..1eb3785b8 100644 --- a/modules/axfs/src/root.rs +++ b/modules/ruxfs/src/root.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axfs/tests/test_common/mod.rs b/modules/ruxfs/tests/test_common/mod.rs similarity index 99% rename from modules/axfs/tests/test_common/mod.rs rename to modules/ruxfs/tests/test_common/mod.rs index 50ae0b568..37a085f75 100644 --- a/modules/axfs/tests/test_common/mod.rs +++ b/modules/ruxfs/tests/test_common/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,8 +7,8 @@ * See the Mulan PSL v2 for more details. */ -use axfs::api as fs; use axio as io; +use ruxfs::api as fs; use fs::{File, FileType, OpenOptions}; use io::{prelude::*, Error, Result}; diff --git a/modules/axfs/tests/test_fatfs.rs b/modules/ruxfs/tests/test_fatfs.rs similarity index 71% rename from modules/axfs/tests/test_fatfs.rs rename to modules/ruxfs/tests/test_fatfs.rs index 3c987e8eb..da542c00a 100644 --- a/modules/axfs/tests/test_fatfs.rs +++ b/modules/ruxfs/tests/test_fatfs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,8 +11,8 @@ mod test_common; -use axdriver::AxDeviceContainer; use driver_block::ramdisk::RamDisk; +use ruxdriver::AxDeviceContainer; const IMG_PATH: &str = "resources/fat16.img"; @@ -29,15 +29,15 @@ fn test_fatfs() { println!("Testing fatfs with ramdisk ..."); let disk = make_disk().expect("failed to load disk image"); - axtask::init_scheduler(); // call this to use `axsync::Mutex`. - // By default, mount_points[0] will be rootfs - let mut mount_points: Vec = Vec::new(); + ruxtask::init_scheduler(); // call this to use `axsync::Mutex`. + // By default, mount_points[0] will be rootfs + let mut mount_points: Vec = Vec::new(); // setup and initialize blkfs as one mountpoint for rootfs - mount_points.push(axfs::init_blkfs(AxDeviceContainer::from_one(disk))); - axfs::prepare_commonfs(&mut mount_points); + mount_points.push(ruxfs::init_blkfs(AxDeviceContainer::from_one(disk))); + ruxfs::prepare_commonfs(&mut mount_points); // setup and initialize rootfs - axfs::init_filesystems(mount_points); + ruxfs::init_filesystems(mount_points); test_common::test_all(); } diff --git a/modules/axfs/tests/test_ramfs.rs b/modules/ruxfs/tests/test_ramfs.rs similarity index 77% rename from modules/axfs/tests/test_ramfs.rs rename to modules/ruxfs/tests/test_ramfs.rs index d98ab70bb..da93bff19 100644 --- a/modules/axfs/tests/test_ramfs.rs +++ b/modules/ruxfs/tests/test_ramfs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -13,13 +13,13 @@ mod test_common; use std::sync::Arc; -use axdriver::AxDeviceContainer; -use axfs::api::{self as fs, File}; -use axfs::fops::{Disk, MyFileSystemIf}; use axfs_ramfs::RamFileSystem; use axfs_vfs::VfsOps; use axio::{Result, Write}; use driver_block::ramdisk::RamDisk; +use ruxdriver::AxDeviceContainer; +use ruxfs::api::{self as fs, File}; +use ruxfs::fops::{Disk, MyFileSystemIf}; struct MyFileSystemIfImpl; @@ -54,17 +54,17 @@ fn create_init_files() -> Result<()> { fn test_ramfs() { println!("Testing ramfs ..."); - axtask::init_scheduler(); // call this to use `axsync::Mutex`. - // By default, mount_points[0] will be rootfs - let mut mount_points: Vec = Vec::new(); + ruxtask::init_scheduler(); // call this to use `axsync::Mutex`. + // By default, mount_points[0] will be rootfs + let mut mount_points: Vec = Vec::new(); // setup and initialize blkfs as one mountpoint for rootfs - mount_points.push(axfs::init_blkfs(AxDeviceContainer::from_one( + mount_points.push(ruxfs::init_blkfs(AxDeviceContainer::from_one( RamDisk::default(), ))); - axfs::prepare_commonfs(&mut mount_points); + ruxfs::prepare_commonfs(&mut mount_points); // setup and initialize rootfs - axfs::init_filesystems(mount_points); + ruxfs::init_filesystems(mount_points); if let Err(e) = create_init_files() { log::warn!("failed to create init files: {:?}", e); diff --git a/modules/axhal/.gitignore b/modules/ruxhal/.gitignore similarity index 100% rename from modules/axhal/.gitignore rename to modules/ruxhal/.gitignore diff --git a/modules/axhal/Cargo.toml b/modules/ruxhal/Cargo.toml similarity index 78% rename from modules/axhal/Cargo.toml rename to modules/ruxhal/Cargo.toml index e17a39b32..0e5186f1b 100644 --- a/modules/axhal/Cargo.toml +++ b/modules/ruxhal/Cargo.toml @@ -1,13 +1,15 @@ [package] -name = "axhal" +name = "ruxhal" version = "0.1.0" edition = "2021" -authors = ["Yuekai Jia "] -description = "ArceOS hardware abstraction layer, provides unified APIs for platform-specific operations" +authors = [ + "Yuekai Jia ", + "yanjuguang ", +] +description = "Ruxos hardware abstraction layer, provides unified APIs for platform-specific operations" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axhal" -documentation = "https://rcore-os.github.io/arceos/axhal/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxhal" [features] smp = [] @@ -27,7 +29,7 @@ bitflags = "2.2" static_assertions = "1.1.0" embedded-hal = "0.2.7" axlog = { path = "../axlog" } -axconfig = { path = "../axconfig" } +ruxconfig = { path = "../ruxconfig" } axalloc = { path = "../axalloc", optional = true } kernel_guard = { path = "../../crates/kernel_guard" } spinlock = { path = "../../crates/spinlock" } @@ -60,4 +62,4 @@ dw_apb_uart = { path = "../../crates/dw_apb_uart" } dtb = {path = "../../crates/dtb" } [build-dependencies] -axconfig = { path = "../axconfig" } +ruxconfig = { path = "../ruxconfig" } diff --git a/modules/axhal/build.rs b/modules/ruxhal/build.rs similarity index 85% rename from modules/axhal/build.rs rename to modules/ruxhal/build.rs index aa2a5eb72..8b99a60a5 100644 --- a/modules/axhal/build.rs +++ b/modules/ruxhal/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,13 +11,13 @@ use std::io::Result; fn main() { let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); - let platform = axconfig::PLATFORM; + let platform = ruxconfig::PLATFORM; if platform != "dummy" { gen_linker_script(&arch, platform).unwrap(); } println!("cargo:rustc-cfg=platform=\"{}\"", platform); - println!("cargo:rustc-cfg=platform_family=\"{}\"", axconfig::FAMILY); + println!("cargo:rustc-cfg=platform_family=\"{}\"", ruxconfig::FAMILY); } fn gen_linker_script(arch: &str, platform: &str) -> Result<()> { @@ -33,9 +33,9 @@ fn gen_linker_script(arch: &str, platform: &str) -> Result<()> { let ld_content = ld_content.replace("%ARCH%", output_arch); let ld_content = ld_content.replace( "%KERNEL_BASE%", - &format!("{:#x}", axconfig::KERNEL_BASE_VADDR), + &format!("{:#x}", ruxconfig::KERNEL_BASE_VADDR), ); - let ld_content = ld_content.replace("%SMP%", &format!("{}", axconfig::SMP)); + let ld_content = ld_content.replace("%SMP%", &format!("{}", ruxconfig::SMP)); std::fs::write(fname, ld_content)?; Ok(()) diff --git a/modules/axhal/linker.lds.S b/modules/ruxhal/linker.lds.S similarity index 100% rename from modules/axhal/linker.lds.S rename to modules/ruxhal/linker.lds.S diff --git a/modules/axhal/src/arch/aarch64/context.rs b/modules/ruxhal/src/arch/aarch64/context.rs similarity index 99% rename from modules/axhal/src/arch/aarch64/context.rs rename to modules/ruxhal/src/arch/aarch64/context.rs index 7502ea332..9571bc845 100644 --- a/modules/axhal/src/arch/aarch64/context.rs +++ b/modules/ruxhal/src/arch/aarch64/context.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/aarch64/mod.rs b/modules/ruxhal/src/arch/aarch64/mod.rs similarity index 98% rename from modules/axhal/src/arch/aarch64/mod.rs rename to modules/ruxhal/src/arch/aarch64/mod.rs index b0a13e240..090ad3387 100644 --- a/modules/axhal/src/arch/aarch64/mod.rs +++ b/modules/ruxhal/src/arch/aarch64/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/aarch64/trap.S b/modules/ruxhal/src/arch/aarch64/trap.S similarity index 100% rename from modules/axhal/src/arch/aarch64/trap.S rename to modules/ruxhal/src/arch/aarch64/trap.S diff --git a/modules/axhal/src/arch/aarch64/trap.rs b/modules/ruxhal/src/arch/aarch64/trap.rs similarity index 98% rename from modules/axhal/src/arch/aarch64/trap.rs rename to modules/ruxhal/src/arch/aarch64/trap.rs index c6fa44fef..b9a19ed5b 100644 --- a/modules/axhal/src/arch/aarch64/trap.rs +++ b/modules/ruxhal/src/arch/aarch64/trap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/mod.rs b/modules/ruxhal/src/arch/mod.rs similarity index 95% rename from modules/axhal/src/arch/mod.rs rename to modules/ruxhal/src/arch/mod.rs index c80ad1e86..954ce3208 100644 --- a/modules/axhal/src/arch/mod.rs +++ b/modules/ruxhal/src/arch/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/riscv/context.rs b/modules/ruxhal/src/arch/riscv/context.rs similarity index 99% rename from modules/axhal/src/arch/riscv/context.rs rename to modules/ruxhal/src/arch/riscv/context.rs index b27765691..ddcab7417 100644 --- a/modules/axhal/src/arch/riscv/context.rs +++ b/modules/ruxhal/src/arch/riscv/context.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/riscv/macros.rs b/modules/ruxhal/src/arch/riscv/macros.rs similarity index 98% rename from modules/axhal/src/arch/riscv/macros.rs rename to modules/ruxhal/src/arch/riscv/macros.rs index 48e7959bb..6cce0bcc8 100644 --- a/modules/axhal/src/arch/riscv/macros.rs +++ b/modules/ruxhal/src/arch/riscv/macros.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/riscv/mod.rs b/modules/ruxhal/src/arch/riscv/mod.rs similarity index 98% rename from modules/axhal/src/arch/riscv/mod.rs rename to modules/ruxhal/src/arch/riscv/mod.rs index f6245eda6..0026cfc12 100644 --- a/modules/axhal/src/arch/riscv/mod.rs +++ b/modules/ruxhal/src/arch/riscv/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/riscv/trap.S b/modules/ruxhal/src/arch/riscv/trap.S similarity index 100% rename from modules/axhal/src/arch/riscv/trap.S rename to modules/ruxhal/src/arch/riscv/trap.S diff --git a/modules/axhal/src/arch/riscv/trap.rs b/modules/ruxhal/src/arch/riscv/trap.rs similarity index 96% rename from modules/axhal/src/arch/riscv/trap.rs rename to modules/ruxhal/src/arch/riscv/trap.rs index 1aba93498..bbe60c223 100644 --- a/modules/axhal/src/arch/riscv/trap.rs +++ b/modules/ruxhal/src/arch/riscv/trap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/x86_64/context.rs b/modules/ruxhal/src/arch/x86_64/context.rs similarity index 99% rename from modules/axhal/src/arch/x86_64/context.rs rename to modules/ruxhal/src/arch/x86_64/context.rs index 08b12e382..110f15c5b 100644 --- a/modules/axhal/src/arch/x86_64/context.rs +++ b/modules/ruxhal/src/arch/x86_64/context.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/x86_64/gdt.rs b/modules/ruxhal/src/arch/x86_64/gdt.rs similarity index 98% rename from modules/axhal/src/arch/x86_64/gdt.rs rename to modules/ruxhal/src/arch/x86_64/gdt.rs index 4bc9fa80e..0ed69287a 100644 --- a/modules/axhal/src/arch/x86_64/gdt.rs +++ b/modules/ruxhal/src/arch/x86_64/gdt.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/x86_64/idt.rs b/modules/ruxhal/src/arch/x86_64/idt.rs similarity index 98% rename from modules/axhal/src/arch/x86_64/idt.rs rename to modules/ruxhal/src/arch/x86_64/idt.rs index ec590cace..37dba202f 100644 --- a/modules/axhal/src/arch/x86_64/idt.rs +++ b/modules/ruxhal/src/arch/x86_64/idt.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/x86_64/mod.rs b/modules/ruxhal/src/arch/x86_64/mod.rs similarity index 98% rename from modules/axhal/src/arch/x86_64/mod.rs rename to modules/ruxhal/src/arch/x86_64/mod.rs index 468a05403..f794bec23 100644 --- a/modules/axhal/src/arch/x86_64/mod.rs +++ b/modules/ruxhal/src/arch/x86_64/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/arch/x86_64/trap.S b/modules/ruxhal/src/arch/x86_64/trap.S similarity index 100% rename from modules/axhal/src/arch/x86_64/trap.S rename to modules/ruxhal/src/arch/x86_64/trap.S diff --git a/modules/axhal/src/arch/x86_64/trap.rs b/modules/ruxhal/src/arch/x86_64/trap.rs similarity index 97% rename from modules/axhal/src/arch/x86_64/trap.rs rename to modules/ruxhal/src/arch/x86_64/trap.rs index 3b8d91ecd..e21668f6a 100644 --- a/modules/axhal/src/arch/x86_64/trap.rs +++ b/modules/ruxhal/src/arch/x86_64/trap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/cpu.rs b/modules/ruxhal/src/cpu.rs similarity index 97% rename from modules/axhal/src/cpu.rs rename to modules/ruxhal/src/cpu.rs index 8de9446e6..1d25e8880 100644 --- a/modules/axhal/src/cpu.rs +++ b/modules/ruxhal/src/cpu.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -84,7 +84,7 @@ pub unsafe fn set_current_task_ptr(ptr: *const T) { #[allow(dead_code)] pub(crate) fn init_primary(cpu_id: usize) { - percpu::init(axconfig::SMP); + percpu::init(ruxconfig::SMP); percpu::set_local_thread_pointer(cpu_id); unsafe { CPU_ID.write_current_raw(cpu_id); diff --git a/modules/axhal/src/irq.rs b/modules/ruxhal/src/irq.rs similarity index 97% rename from modules/axhal/src/irq.rs rename to modules/ruxhal/src/irq.rs index f350df41f..a81bb0670 100644 --- a/modules/axhal/src/irq.rs +++ b/modules/ruxhal/src/irq.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/lib.rs b/modules/ruxhal/src/lib.rs similarity index 94% rename from modules/axhal/src/lib.rs rename to modules/ruxhal/src/lib.rs index 0fe6ee1ca..3785e3498 100644 --- a/modules/axhal/src/lib.rs +++ b/modules/ruxhal/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS] hardware abstraction layer, provides unified APIs for +//! [Ruxos] hardware abstraction layer, provides unified APIs for //! platform-specific operations. //! //! It does the bootstrapping and initialization process for the specified @@ -30,7 +30,7 @@ //! - `paging`: Enable page table manipulation. //! - `irq`: Enable interrupt handling support. //! -//! [ArceOS]: https://github.com/rcore-os/arceos +//! [Ruxos]: https://github.com/syswonder/ruxos //! [cargo test]: https://doc.rust-lang.org/cargo/guide/tests.html #![no_std] diff --git a/modules/axhal/src/mem.rs b/modules/ruxhal/src/mem.rs similarity index 91% rename from modules/axhal/src/mem.rs rename to modules/ruxhal/src/mem.rs index d4d76a92d..f98c6ad2e 100644 --- a/modules/axhal/src/mem.rs +++ b/modules/ruxhal/src/mem.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -60,10 +60,10 @@ pub struct MemRegion { /// space at the address plus the offset. So we have /// `paddr = vaddr - PHYS_VIRT_OFFSET`. /// -/// [`PHYS_VIRT_OFFSET`]: axconfig::PHYS_VIRT_OFFSET +/// [`PHYS_VIRT_OFFSET`]: ruxconfig::PHYS_VIRT_OFFSET #[inline] pub const fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr { - PhysAddr::from(vaddr.as_usize() - axconfig::PHYS_VIRT_OFFSET) + PhysAddr::from(vaddr.as_usize() - ruxconfig::PHYS_VIRT_OFFSET) } /// Converts a physical address to a virtual address. @@ -73,10 +73,10 @@ pub const fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr { /// space at the address plus the offset. So we have /// `vaddr = paddr + PHYS_VIRT_OFFSET`. /// -/// [`PHYS_VIRT_OFFSET`]: axconfig::PHYS_VIRT_OFFSET +/// [`PHYS_VIRT_OFFSET`]: ruxconfig::PHYS_VIRT_OFFSET #[inline] pub const fn phys_to_virt(paddr: PhysAddr) -> VirtAddr { - VirtAddr::from(paddr.as_usize() + axconfig::PHYS_VIRT_OFFSET) + VirtAddr::from(paddr.as_usize() + ruxconfig::PHYS_VIRT_OFFSET) } /// Returns an iterator over all physical memory regions. @@ -121,10 +121,10 @@ fn kernel_image_regions() -> impl Iterator { .into_iter() } -/// Returns the default MMIO memory regions (from [`axconfig::MMIO_REGIONS`]). +/// Returns the default MMIO memory regions (from [`ruxconfig::MMIO_REGIONS`]). #[allow(dead_code)] pub(crate) fn default_mmio_regions() -> impl Iterator { - axconfig::MMIO_REGIONS.iter().map(|reg| MemRegion { + ruxconfig::MMIO_REGIONS.iter().map(|reg| MemRegion { paddr: reg.0.into(), size: reg.1, flags: MemRegionFlags::RESERVED @@ -139,7 +139,7 @@ pub(crate) fn default_mmio_regions() -> impl Iterator { #[allow(dead_code)] pub(crate) fn default_free_regions() -> impl Iterator { let start = virt_to_phys((_ekernel as usize).into()).align_up_4k(); - let end = PhysAddr::from(axconfig::PHYS_MEMORY_END).align_down_4k(); + let end = PhysAddr::from(ruxconfig::PHYS_MEMORY_END).align_down_4k(); core::iter::once(MemRegion { paddr: start, size: end.as_usize() - start.as_usize(), diff --git a/modules/axhal/src/paging.rs b/modules/ruxhal/src/paging.rs similarity index 98% rename from modules/axhal/src/paging.rs rename to modules/ruxhal/src/paging.rs index 6289164e1..cd3faeabe 100644 --- a/modules/axhal/src/paging.rs +++ b/modules/ruxhal/src/paging.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/aarch64_common/boot.rs b/modules/ruxhal/src/platform/aarch64_common/boot.rs similarity index 96% rename from modules/axhal/src/platform/aarch64_common/boot.rs rename to modules/ruxhal/src/platform/aarch64_common/boot.rs index f36f43d64..af39895ae 100644 --- a/modules/axhal/src/platform/aarch64_common/boot.rs +++ b/modules/ruxhal/src/platform/aarch64_common/boot.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,7 +12,7 @@ use memory_addr::PhysAddr; use page_table_entry::aarch64::{MemAttr, A64PTE}; use tock_registers::interfaces::{ReadWriteable, Readable, Writeable}; -use axconfig::TASK_STACK_SIZE; +use ruxconfig::TASK_STACK_SIZE; #[link_section = ".bss.stack"] static mut BOOT_STACK: [u8; TASK_STACK_SIZE] = [0; TASK_STACK_SIZE]; @@ -144,7 +144,7 @@ unsafe extern "C" fn _start() -> ! { enable_fp = sym enable_fp, boot_stack = sym BOOT_STACK, boot_stack_size = const TASK_STACK_SIZE, - phys_virt_offset = const axconfig::PHYS_VIRT_OFFSET, + phys_virt_offset = const ruxconfig::PHYS_VIRT_OFFSET, entry = sym crate::platform::rust_entry, options(noreturn), ) @@ -175,7 +175,7 @@ unsafe extern "C" fn _start_secondary() -> ! { switch_to_el1 = sym switch_to_el1, init_mmu = sym init_mmu, enable_fp = sym enable_fp, - phys_virt_offset = const axconfig::PHYS_VIRT_OFFSET, + phys_virt_offset = const ruxconfig::PHYS_VIRT_OFFSET, entry = sym crate::platform::rust_entry_secondary, options(noreturn), ) diff --git a/modules/axhal/src/platform/aarch64_common/generic_timer.rs b/modules/ruxhal/src/platform/aarch64_common/generic_timer.rs similarity index 98% rename from modules/axhal/src/platform/aarch64_common/generic_timer.rs rename to modules/ruxhal/src/platform/aarch64_common/generic_timer.rs index b8f0ac047..81a4e421f 100644 --- a/modules/axhal/src/platform/aarch64_common/generic_timer.rs +++ b/modules/ruxhal/src/platform/aarch64_common/generic_timer.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/aarch64_common/gic.rs b/modules/ruxhal/src/platform/aarch64_common/gic.rs similarity index 89% rename from modules/axhal/src/platform/aarch64_common/gic.rs rename to modules/ruxhal/src/platform/aarch64_common/gic.rs index ff4403a8e..1df2ef11e 100644 --- a/modules/axhal/src/platform/aarch64_common/gic.rs +++ b/modules/ruxhal/src/platform/aarch64_common/gic.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -20,10 +20,10 @@ pub const MAX_IRQ_COUNT: usize = 1024; pub const TIMER_IRQ_NUM: usize = translate_irq(14, InterruptType::PPI).unwrap(); /// The UART IRQ number. -pub const UART_IRQ_NUM: usize = translate_irq(axconfig::UART_IRQ, InterruptType::SPI).unwrap(); +pub const UART_IRQ_NUM: usize = translate_irq(ruxconfig::UART_IRQ, InterruptType::SPI).unwrap(); -const GICD_BASE: PhysAddr = PhysAddr::from(axconfig::GICD_PADDR); -const GICC_BASE: PhysAddr = PhysAddr::from(axconfig::GICC_PADDR); +const GICD_BASE: PhysAddr = PhysAddr::from(ruxconfig::GICD_PADDR); +const GICC_BASE: PhysAddr = PhysAddr::from(ruxconfig::GICC_PADDR); static GICD: SpinNoIrq = SpinNoIrq::new(GicDistributor::new(phys_to_virt(GICD_BASE).as_mut_ptr())); diff --git a/modules/axhal/src/platform/aarch64_common/mod.rs b/modules/ruxhal/src/platform/aarch64_common/mod.rs similarity index 94% rename from modules/axhal/src/platform/aarch64_common/mod.rs rename to modules/ruxhal/src/platform/aarch64_common/mod.rs index 46cd23906..572642be6 100644 --- a/modules/axhal/src/platform/aarch64_common/mod.rs +++ b/modules/ruxhal/src/platform/aarch64_common/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/aarch64_common/pl011.rs b/modules/ruxhal/src/platform/aarch64_common/pl011.rs similarity index 93% rename from modules/axhal/src/platform/aarch64_common/pl011.rs rename to modules/ruxhal/src/platform/aarch64_common/pl011.rs index 6fedc92bc..170abcda8 100644 --- a/modules/axhal/src/platform/aarch64_common/pl011.rs +++ b/modules/ruxhal/src/platform/aarch64_common/pl011.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -15,7 +15,7 @@ use spinlock::SpinNoIrq; use crate::mem::phys_to_virt; -const UART_BASE: PhysAddr = PhysAddr::from(axconfig::UART_PADDR); +const UART_BASE: PhysAddr = PhysAddr::from(ruxconfig::UART_PADDR); static UART: SpinNoIrq = SpinNoIrq::new(Pl011Uart::new(phys_to_virt(UART_BASE).as_mut_ptr())); diff --git a/modules/axhal/src/platform/aarch64_common/pl031.rs b/modules/ruxhal/src/platform/aarch64_common/pl031.rs similarity index 95% rename from modules/axhal/src/platform/aarch64_common/pl031.rs rename to modules/ruxhal/src/platform/aarch64_common/pl031.rs index 89e38ef25..b8ddd9b62 100644 --- a/modules/axhal/src/platform/aarch64_common/pl031.rs +++ b/modules/ruxhal/src/platform/aarch64_common/pl031.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -15,7 +15,7 @@ static RTC_LR: u32 = 0x008; //Load Register static RTC_CR: u32 = 0x00c; //Control Register static RTC_IMSC: u32 = 0x010; //Interrupt Mask Set or Clear register -const PHYS_RTC: usize = axconfig::PHYS_VIRT_OFFSET + 0x09010000; +const PHYS_RTC: usize = ruxconfig::PHYS_VIRT_OFFSET + 0x09010000; static PL031_RTC: Pl031rtc = Pl031rtc { address: PHYS_RTC }; diff --git a/modules/axhal/src/platform/aarch64_common/psci.rs b/modules/ruxhal/src/platform/aarch64_common/psci.rs similarity index 96% rename from modules/axhal/src/platform/aarch64_common/psci.rs rename to modules/ruxhal/src/platform/aarch64_common/psci.rs index fdd440a34..12a5b7abe 100644 --- a/modules/axhal/src/platform/aarch64_common/psci.rs +++ b/modules/ruxhal/src/platform/aarch64_common/psci.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -88,10 +88,10 @@ fn psci_hvc_call(func: u32, arg0: usize, arg1: usize, arg2: usize) -> usize { } fn psci_call(func: u32, arg0: usize, arg1: usize, arg2: usize) -> Result<(), PsciError> { - let ret = match axconfig::PSCI_METHOD { + let ret = match ruxconfig::PSCI_METHOD { "smc" => arm_smccc_smc(func, arg0, arg1, arg2), "hvc" => psci_hvc_call(func, arg0, arg1, arg2), - _ => panic!("Unknown PSCI method: {}", axconfig::PSCI_METHOD), + _ => panic!("Unknown PSCI method: {}", ruxconfig::PSCI_METHOD), }; if ret == 0 { Ok(()) diff --git a/modules/axhal/src/platform/aarch64_qemu_virt/mem.rs b/modules/ruxhal/src/platform/aarch64_qemu_virt/mem.rs similarity index 98% rename from modules/axhal/src/platform/aarch64_qemu_virt/mem.rs rename to modules/ruxhal/src/platform/aarch64_qemu_virt/mem.rs index 385a7115a..9d7788717 100644 --- a/modules/axhal/src/platform/aarch64_qemu_virt/mem.rs +++ b/modules/ruxhal/src/platform/aarch64_qemu_virt/mem.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/aarch64_qemu_virt/mod.rs b/modules/ruxhal/src/platform/aarch64_qemu_virt/mod.rs similarity index 98% rename from modules/axhal/src/platform/aarch64_qemu_virt/mod.rs rename to modules/ruxhal/src/platform/aarch64_qemu_virt/mod.rs index cba38247d..34236fb04 100644 --- a/modules/axhal/src/platform/aarch64_qemu_virt/mod.rs +++ b/modules/ruxhal/src/platform/aarch64_qemu_virt/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/aarch64_qemu_virt/mp.rs b/modules/ruxhal/src/platform/aarch64_qemu_virt/mp.rs similarity index 95% rename from modules/axhal/src/platform/aarch64_qemu_virt/mp.rs rename to modules/ruxhal/src/platform/aarch64_qemu_virt/mp.rs index ba635f8c3..95c6a3bb9 100644 --- a/modules/axhal/src/platform/aarch64_qemu_virt/mp.rs +++ b/modules/ruxhal/src/platform/aarch64_qemu_virt/mp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/dummy/mod.rs b/modules/ruxhal/src/platform/dummy/mod.rs similarity index 93% rename from modules/axhal/src/platform/dummy/mod.rs rename to modules/ruxhal/src/platform/dummy/mod.rs index 6c1ef9702..9e627cd7d 100644 --- a/modules/axhal/src/platform/dummy/mod.rs +++ b/modules/ruxhal/src/platform/dummy/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -62,6 +62,14 @@ pub mod time { /// /// A timer interrupt will be triggered at the given deadline (in nanoseconds). pub fn set_oneshot_timer(deadline_ns: u64) {} + + #[cfg(feature = "rtc")] + pub fn rtc_read_time() -> u64 { + 0 + } + + #[cfg(feature = "rtc")] + pub fn rtc_write_time(seconds: u32) -> u64 {} } #[cfg(feature = "irq")] diff --git a/modules/axhal/src/platform/mod.rs b/modules/ruxhal/src/platform/mod.rs similarity index 76% rename from modules/axhal/src/platform/mod.rs rename to modules/ruxhal/src/platform/mod.rs index 9a90cc2b9..09f1b3e30 100644 --- a/modules/axhal/src/platform/mod.rs +++ b/modules/ruxhal/src/platform/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -25,12 +25,6 @@ cfg_if::cfg_if! { } else if #[cfg(all(target_arch = "aarch64", platform_family = "aarch64-qemu-virt"))] { mod aarch64_qemu_virt; pub use self::aarch64_qemu_virt::*; - } else if #[cfg(all(target_arch = "aarch64", platform_family = "aarch64-raspi"))] { - mod aarch64_raspi; - pub use self::aarch64_raspi::*; - } else if #[cfg(all(target_arch = "aarch64", platform_family = "aarch64-bsta1000b"))] { - mod aarch64_bsta1000b; - pub use self::aarch64_bsta1000b::*; } else { mod dummy; pub use self::dummy::*; diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/boot.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/boot.rs similarity index 97% rename from modules/axhal/src/platform/riscv64_qemu_virt/boot.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/boot.rs index ace0f252f..a32856f40 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/boot.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/boot.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,7 +9,7 @@ use riscv::register::satp; -use axconfig::{PHYS_VIRT_OFFSET, TASK_STACK_SIZE}; +use ruxconfig::{PHYS_VIRT_OFFSET, TASK_STACK_SIZE}; #[link_section = ".bss.stack"] static mut BOOT_STACK: [u8; TASK_STACK_SIZE] = [0; TASK_STACK_SIZE]; diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/console.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/console.rs similarity index 95% rename from modules/axhal/src/platform/riscv64_qemu_virt/console.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/console.rs index d13eadf4c..0449d2d24 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/console.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/console.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/irq.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/irq.rs similarity index 98% rename from modules/axhal/src/platform/riscv64_qemu_virt/irq.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/irq.rs index 451056683..5819a8422 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/irq.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/irq.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/mem.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/mem.rs similarity index 94% rename from modules/axhal/src/platform/riscv64_qemu_virt/mem.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/mem.rs index 727d0b171..1aaa408f2 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/mem.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/mem.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/misc.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/misc.rs similarity index 94% rename from modules/axhal/src/platform/riscv64_qemu_virt/misc.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/misc.rs index 680c7ebdd..91ad46b5c 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/misc.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/misc.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/mod.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/mod.rs similarity index 97% rename from modules/axhal/src/platform/riscv64_qemu_virt/mod.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/mod.rs index fcf95e504..d0ad8d791 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/mod.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/mp.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/mp.rs similarity index 95% rename from modules/axhal/src/platform/riscv64_qemu_virt/mp.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/mp.rs index 48c2da8c6..0f2a093ad 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/mp.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/mp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/riscv64_qemu_virt/time.rs b/modules/ruxhal/src/platform/riscv64_qemu_virt/time.rs similarity index 89% rename from modules/axhal/src/platform/riscv64_qemu_virt/time.rs rename to modules/ruxhal/src/platform/riscv64_qemu_virt/time.rs index 16fec4589..51a5903a7 100644 --- a/modules/axhal/src/platform/riscv64_qemu_virt/time.rs +++ b/modules/ruxhal/src/platform/riscv64_qemu_virt/time.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,7 +9,7 @@ use riscv::register::time; -const NANOS_PER_TICK: u64 = crate::time::NANOS_PER_SEC / axconfig::TIMER_FREQUENCY as u64; +const NANOS_PER_TICK: u64 = crate::time::NANOS_PER_SEC / ruxconfig::TIMER_FREQUENCY as u64; /// Returns the current clock time in hardware ticks. #[inline] diff --git a/modules/axhal/src/platform/x86_pc/ap_start.S b/modules/ruxhal/src/platform/x86_pc/ap_start.S similarity index 100% rename from modules/axhal/src/platform/x86_pc/ap_start.S rename to modules/ruxhal/src/platform/x86_pc/ap_start.S diff --git a/modules/axhal/src/platform/x86_pc/apic.rs b/modules/ruxhal/src/platform/x86_pc/apic.rs similarity index 98% rename from modules/axhal/src/platform/x86_pc/apic.rs rename to modules/ruxhal/src/platform/x86_pc/apic.rs index 790bd7691..d0b40fd86 100644 --- a/modules/axhal/src/platform/x86_pc/apic.rs +++ b/modules/ruxhal/src/platform/x86_pc/apic.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/boot.rs b/modules/ruxhal/src/platform/x86_pc/boot.rs similarity index 95% rename from modules/axhal/src/platform/x86_pc/boot.rs rename to modules/ruxhal/src/platform/x86_pc/boot.rs index 02df42659..fa03764bc 100644 --- a/modules/axhal/src/platform/x86_pc/boot.rs +++ b/modules/ruxhal/src/platform/x86_pc/boot.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,7 +12,7 @@ use core::arch::global_asm; use x86_64::registers::control::{Cr0Flags, Cr4Flags}; use x86_64::registers::model_specific::EferFlags; -use axconfig::{PHYS_VIRT_OFFSET, TASK_STACK_SIZE}; +use ruxconfig::{PHYS_VIRT_OFFSET, TASK_STACK_SIZE}; /// Flags set in the ’flags’ member of the multiboot header. /// diff --git a/modules/axhal/src/platform/x86_pc/dtables.rs b/modules/ruxhal/src/platform/x86_pc/dtables.rs similarity index 96% rename from modules/axhal/src/platform/x86_pc/dtables.rs rename to modules/ruxhal/src/platform/x86_pc/dtables.rs index d68e26ad6..a9f1bb443 100644 --- a/modules/axhal/src/platform/x86_pc/dtables.rs +++ b/modules/ruxhal/src/platform/x86_pc/dtables.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/mem.rs b/modules/ruxhal/src/platform/x86_pc/mem.rs similarity index 95% rename from modules/axhal/src/platform/x86_pc/mem.rs rename to modules/ruxhal/src/platform/x86_pc/mem.rs index fa8605dc3..11236c0b5 100644 --- a/modules/axhal/src/platform/x86_pc/mem.rs +++ b/modules/ruxhal/src/platform/x86_pc/mem.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/misc.rs b/modules/ruxhal/src/platform/x86_pc/misc.rs similarity index 96% rename from modules/axhal/src/platform/x86_pc/misc.rs rename to modules/ruxhal/src/platform/x86_pc/misc.rs index 191171a68..66b42ca05 100644 --- a/modules/axhal/src/platform/x86_pc/misc.rs +++ b/modules/ruxhal/src/platform/x86_pc/misc.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/mod.rs b/modules/ruxhal/src/platform/x86_pc/mod.rs similarity index 98% rename from modules/axhal/src/platform/x86_pc/mod.rs rename to modules/ruxhal/src/platform/x86_pc/mod.rs index 92d0ae12d..35ec081b1 100644 --- a/modules/axhal/src/platform/x86_pc/mod.rs +++ b/modules/ruxhal/src/platform/x86_pc/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/mp.rs b/modules/ruxhal/src/platform/x86_pc/mp.rs similarity index 97% rename from modules/axhal/src/platform/x86_pc/mp.rs rename to modules/ruxhal/src/platform/x86_pc/mp.rs index 8d69df95b..29b384624 100644 --- a/modules/axhal/src/platform/x86_pc/mp.rs +++ b/modules/ruxhal/src/platform/x86_pc/mp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/multiboot.S b/modules/ruxhal/src/platform/x86_pc/multiboot.S similarity index 100% rename from modules/axhal/src/platform/x86_pc/multiboot.S rename to modules/ruxhal/src/platform/x86_pc/multiboot.S diff --git a/modules/axhal/src/platform/x86_pc/rtc.rs b/modules/ruxhal/src/platform/x86_pc/rtc.rs similarity index 99% rename from modules/axhal/src/platform/x86_pc/rtc.rs rename to modules/ruxhal/src/platform/x86_pc/rtc.rs index 715cc8f80..6744bb7d1 100644 --- a/modules/axhal/src/platform/x86_pc/rtc.rs +++ b/modules/ruxhal/src/platform/x86_pc/rtc.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/platform/x86_pc/time.rs b/modules/ruxhal/src/platform/x86_pc/time.rs similarity index 95% rename from modules/axhal/src/platform/x86_pc/time.rs rename to modules/ruxhal/src/platform/x86_pc/time.rs index 0b351a485..9028cc2ac 100644 --- a/modules/axhal/src/platform/x86_pc/time.rs +++ b/modules/ruxhal/src/platform/x86_pc/time.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -19,7 +19,7 @@ static mut NANOS_TO_LAPIC_TICKS_RATIO: ratio::Ratio = ratio::Ratio::zero(); pub use crate::platform::x86_pc::rtc::*; static mut INIT_TICK: u64 = 0; -static mut CPU_FREQ_MHZ: u64 = axconfig::TIMER_FREQUENCY as u64 / 1_000_000; +static mut CPU_FREQ_MHZ: u64 = ruxconfig::TIMER_FREQUENCY as u64 / 1_000_000; /// Returns the current clock time in hardware ticks. pub fn current_ticks() -> u64 { diff --git a/modules/axhal/src/platform/x86_pc/uart16550.rs b/modules/ruxhal/src/platform/x86_pc/uart16550.rs similarity index 98% rename from modules/axhal/src/platform/x86_pc/uart16550.rs rename to modules/ruxhal/src/platform/x86_pc/uart16550.rs index 86531f9c6..84ec351c6 100644 --- a/modules/axhal/src/platform/x86_pc/uart16550.rs +++ b/modules/ruxhal/src/platform/x86_pc/uart16550.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/time.rs b/modules/ruxhal/src/time.rs similarity index 98% rename from modules/axhal/src/time.rs rename to modules/ruxhal/src/time.rs index 99cebaf7b..fa9395b85 100644 --- a/modules/axhal/src/time.rs +++ b/modules/ruxhal/src/time.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/tls.rs b/modules/ruxhal/src/tls.rs similarity index 99% rename from modules/axhal/src/tls.rs rename to modules/ruxhal/src/tls.rs index 23c96cab6..f1ee84ff5 100644 --- a/modules/axhal/src/tls.rs +++ b/modules/ruxhal/src/tls.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axhal/src/trap.rs b/modules/ruxhal/src/trap.rs similarity index 97% rename from modules/axhal/src/trap.rs rename to modules/ruxhal/src/trap.rs index dd03182dd..ea145654a 100644 --- a/modules/axhal/src/trap.rs +++ b/modules/ruxhal/src/trap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/ruxruntime/Cargo.toml b/modules/ruxruntime/Cargo.toml new file mode 100644 index 000000000..73273b90c --- /dev/null +++ b/modules/ruxruntime/Cargo.toml @@ -0,0 +1,54 @@ +[package] +name = "ruxruntime" +version = "0.1.0" +edition = "2021" +authors = [ + "Yuekai Jia ", + "yanjuguang ", + "Zheng Wu ", + "AuYang261 ", +] +description = "Runtime library of Ruxos" +license = "GPL-3.0-or-later OR Apache-2.0" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxruntime" + +[features] +default = [] + +smp = ["ruxhal/smp"] +irq = ["ruxhal/irq", "ruxtask?/irq", "percpu", "kernel_guard"] +tls = ["ruxhal/tls", "ruxtask?/tls"] +alloc = ["axalloc", "dtb"] +paging = ["ruxhal/paging", "lazy_init"] +rtc = ["ruxhal/rtc"] + +multitask = ["ruxtask/multitask"] +fs = ["ruxdriver", "ruxfs"] +blkfs = ["fs"] +virtio-9p = ["fs", "rux9p"] +net-9p = ["fs", "rux9p"] +net = ["ruxdriver", "axnet"] +display = ["ruxdriver", "ruxdisplay"] +signal = [] + +musl = [] + +[dependencies] +cfg-if = "1.0" +ruxhal = { path = "../ruxhal" } +axlog = { path = "../axlog" } +ruxconfig = { path = "../ruxconfig" } +axalloc = { path = "../axalloc", optional = true } +ruxdriver = { path = "../ruxdriver", optional = true } +ruxfs = { path = "../ruxfs", optional = true } +rux9p = { path = "../rux9p", optional = true } +axnet = { path = "../axnet", optional = true } +ruxdisplay = { path = "../ruxdisplay", optional = true } +ruxtask = { path = "../ruxtask", optional = true } + +crate_interface = { path = "../../crates/crate_interface" } +percpu = { path = "../../crates/percpu", optional = true } +kernel_guard = { path = "../../crates/kernel_guard", optional = true } +lazy_init = { path = "../../crates/lazy_init", optional = true } +dtb = { path = "../../crates/dtb", optional = true} diff --git a/modules/axruntime/src/env.rs b/modules/ruxruntime/src/env.rs similarity index 82% rename from modules/axruntime/src/env.rs rename to modules/ruxruntime/src/env.rs index 6e696caf9..be74823de 100644 --- a/modules/axruntime/src/env.rs +++ b/modules/ruxruntime/src/env.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,9 +8,9 @@ */ extern crate alloc; use alloc::vec::Vec; -use axhal::mem::PAGE_SIZE_4K; use core::ffi::c_char; use core::{ptr, usize}; +use ruxhal::mem::PAGE_SIZE_4K; pub const AT_PAGESIZE: usize = 6; @@ -19,15 +19,15 @@ pub const AT_PAGESIZE: usize = 6; pub static mut argv: *mut *mut c_char = ptr::null_mut(); /// Save cmdline argments -static mut RX_ARGV: Vec<*mut c_char> = Vec::new(); +static mut RUX_ARGV: Vec<*mut c_char> = Vec::new(); -/// A pointer pointing to RX_ENVIRON +/// A pointer pointing to RUX_ENVIRON #[allow(non_upper_case_globals)] #[no_mangle] pub static mut environ: *mut *mut c_char = ptr::null_mut(); /// Save environment variables -pub static mut RX_ENVIRON: Vec<*mut c_char> = Vec::new(); +pub static mut RUX_ENVIRON: Vec<*mut c_char> = Vec::new(); pub(crate) unsafe fn init_argv(args: Vec<&str>) { for arg in args { @@ -38,21 +38,21 @@ pub(crate) unsafe fn init_argv(args: Vec<&str>) { *buf.add(i) = *arg.add(i) as i8; } *buf.add(len) = 0; - RX_ARGV.push(buf); + RUX_ARGV.push(buf); } // end of argv - RX_ARGV.push(ptr::null_mut()); + RUX_ARGV.push(ptr::null_mut()); - for e in &RX_ENVIRON { - RX_ARGV.push(*e); + for e in &RUX_ENVIRON { + RUX_ARGV.push(*e); } - RX_ARGV.push(AT_PAGESIZE as *mut c_char); - RX_ARGV.push(PAGE_SIZE_4K as *mut c_char); + RUX_ARGV.push(AT_PAGESIZE as *mut c_char); + RUX_ARGV.push(PAGE_SIZE_4K as *mut c_char); // end of auxv - RX_ARGV.push(ptr::null_mut()); + RUX_ARGV.push(ptr::null_mut()); - argv = RX_ARGV.as_mut_ptr(); + argv = RUX_ARGV.as_mut_ptr(); } /// Generate an iterator for environment variables @@ -98,6 +98,6 @@ pub(crate) fn boot_add_environ(env: &str) { core::ptr::write(buf.add(i), *ptr.add(i)); } core::ptr::write(buf.add(size - 1), 0); - RX_ENVIRON.push(buf); + RUX_ENVIRON.push(buf); } } diff --git a/modules/axruntime/src/lang_items.rs b/modules/ruxruntime/src/lang_items.rs similarity index 88% rename from modules/axruntime/src/lang_items.rs rename to modules/ruxruntime/src/lang_items.rs index 22db2ad5a..d17bd762c 100644 --- a/modules/axruntime/src/lang_items.rs +++ b/modules/ruxruntime/src/lang_items.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,5 +12,5 @@ use core::panic::PanicInfo; #[panic_handler] fn panic(info: &PanicInfo) -> ! { error!("{}", info); - axhal::misc::terminate() + ruxhal::misc::terminate() } diff --git a/modules/axruntime/src/lib.rs b/modules/ruxruntime/src/lib.rs similarity index 74% rename from modules/axruntime/src/lib.rs rename to modules/ruxruntime/src/lib.rs index 88450c403..2c72d6729 100644 --- a/modules/axruntime/src/lib.rs +++ b/modules/ruxruntime/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,23 +7,27 @@ * See the Mulan PSL v2 for more details. */ -//! Runtime library of [ArceOS](https://github.com/rcore-os/arceos). +//! Runtime library of [Ruxos](https://github.com/syswonder/ruxos). //! -//! Any application uses ArceOS should link this library. It does some +//! Any application uses Ruxos should link this library. It does some //! initialization work before entering the application's `main` function. //! //! # Cargo Features //! //! - `alloc`: Enable global memory allocator. //! - `paging`: Enable page table manipulation support. +//! - `tls`: Enable thread local storage support. //! - `irq`: Enable interrupt handling support. //! - `multitask`: Enable multi-threading support. //! - `smp`: Enable SMP (symmetric multiprocessing) support. //! - `fs`: Enable filesystem support. +//! - `blkfs`: Enable disk filesystem. +//! - `signal`: Enable signal support //! - `net`: Enable networking support. //! - `display`: Enable graphics support. //! - `virtio-9p`: Enable virtio-based 9pfs support. //! - `net-9p`: Enable net-based 9pfs support. +//! - `musl`: Enable musl libc support. //! //! All the features are optional and disabled by default. @@ -55,20 +59,20 @@ extern crate alloc; #[cfg(feature = "alloc")] mod env; #[cfg(feature = "alloc")] -pub use self::env::{argv, environ, environ_iter, RX_ENVIRON}; +pub use self::env::{argv, environ, environ_iter, RUX_ENVIRON}; #[cfg(feature = "alloc")] use self::env::{boot_add_environ, init_argv}; use core::ffi::{c_char, c_int}; const LOGO: &str = r#" - d8888 .d88888b. .d8888b. - d88888 d88P" "Y88b d88P Y88b - d88P888 888 888 Y88b. - d88P 888 888d888 .d8888b .d88b. 888 888 "Y888b. - d88P 888 888P" d88P" d8P Y8b 888 888 "Y88b. - d88P 888 888 888 88888888 888 888 "888 - d8888888888 888 Y88b. Y8b. Y88b. .d88P Y88b d88P -d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P" +8888888b. .d88888b. .d8888b. +888 Y88b d88P" "Y88b d88P Y88b +888 888 888 888 Y88b. +888 d88P 888 888 888 888 888 888 "Y888b. +8888888P" 888 888 `Y8bd8P' 888 888 "Y88b. +888 T88b 888 888 X88K 888 888 "888 +888 T88b Y88b 888 .d8""8b. Y88b. .d88P Y88b d88P +888 T88b "Y88888 888 888 "Y88888P" "Y8888P" "#; #[no_mangle] @@ -97,17 +101,17 @@ struct LogIfImpl; #[crate_interface::impl_interface] impl axlog::LogIf for LogIfImpl { fn console_write_str(s: &str) { - axhal::console::write_bytes(s.as_bytes()); + ruxhal::console::write_bytes(s.as_bytes()); } fn current_time() -> core::time::Duration { - axhal::time::current_time() + ruxhal::time::current_time() } fn current_cpu_id() -> Option { #[cfg(feature = "smp")] if is_init_ok() { - Some(axhal::cpu::this_cpu_id()) + Some(ruxhal::cpu::this_cpu_id()) } else { None } @@ -119,7 +123,7 @@ impl axlog::LogIf for LogIfImpl { if is_init_ok() { #[cfg(feature = "multitask")] { - axtask::current_may_uninit().map(|curr| curr.id().as_u64()) + ruxtask::current_may_uninit().map(|curr| curr.id().as_u64()) } #[cfg(not(feature = "multitask"))] None @@ -134,12 +138,12 @@ use core::sync::atomic::{AtomicUsize, Ordering}; static INITED_CPUS: AtomicUsize = AtomicUsize::new(0); fn is_init_ok() -> bool { - INITED_CPUS.load(Ordering::Acquire) == axconfig::SMP + INITED_CPUS.load(Ordering::Acquire) == ruxconfig::SMP } -/// The main entry point of the ArceOS runtime. +/// The main entry point of the Ruxos runtime. /// -/// It is called from the bootstrapping code in [axhal]. `cpu_id` is the ID of +/// It is called from the bootstrapping code in [ruxhal]. `cpu_id` is the ID of /// the current CPU, and `dtb` is the address of the device tree blob. It /// finally calls the application's `main` function after all initialization /// work is done. @@ -158,21 +162,21 @@ pub extern "C" fn rust_main(cpu_id: usize, dtb: usize) -> ! { build_mode = {}\n\ log_level = {}\n\ ", - option_env!("AX_ARCH").unwrap_or(""), - option_env!("AX_PLATFORM").unwrap_or(""), - option_env!("AX_TARGET").unwrap_or(""), - option_env!("AX_SMP").unwrap_or(""), - option_env!("AX_MODE").unwrap_or(""), - option_env!("AX_LOG").unwrap_or(""), + option_env!("RUX_ARCH").unwrap_or(""), + option_env!("RUX_PLATFORM").unwrap_or(""), + option_env!("RUX_TARGET").unwrap_or(""), + option_env!("RUX_SMP").unwrap_or(""), + option_env!("RUX_MODE").unwrap_or(""), + option_env!("RUX_LOG").unwrap_or(""), ); axlog::init(); - axlog::set_max_level(option_env!("AX_LOG").unwrap_or("")); // no effect if set `log-level-*` features + axlog::set_max_level(option_env!("RUX_LOG").unwrap_or("")); // no effect if set `log-level-*` features info!("Logging is enabled."); info!("Primary CPU {} started, dtb = {:#x}.", cpu_id, dtb); info!("Found physcial memory regions:"); - for r in axhal::mem::memory_regions() { + for r in ruxhal::mem::memory_regions() { info!( " [{:x?}, {:x?}) {} ({:?})", r.paddr, @@ -192,15 +196,15 @@ pub extern "C" fn rust_main(cpu_id: usize, dtb: usize) -> ! { } info!("Initialize platform devices..."); - axhal::platform_init(); + ruxhal::platform_init(); #[cfg(feature = "multitask")] - axtask::init_scheduler(); + ruxtask::init_scheduler(); #[cfg(any(feature = "fs", feature = "net", feature = "display"))] { #[allow(unused_variables)] - let all_devices = axdriver::init_drivers(); + let all_devices = ruxdriver::init_drivers(); #[cfg(feature = "net")] axnet::init_network(all_devices.net); @@ -210,37 +214,37 @@ pub extern "C" fn rust_main(cpu_id: usize, dtb: usize) -> ! { extern crate alloc; use alloc::vec::Vec; // By default, mount_points[0] will be rootfs - let mut mount_points: Vec = Vec::new(); + let mut mount_points: Vec = Vec::new(); //setup ramfs as rootfs if no other filesystem can be mounted #[cfg(not(any(feature = "blkfs", feature = "virtio-9p", feature = "net-9p")))] - mount_points.push(axfs::init_tempfs()); + mount_points.push(ruxfs::init_tempfs()); // setup and initialize blkfs as one mountpoint for rootfs #[cfg(feature = "blkfs")] - mount_points.push(axfs::init_blkfs(all_devices.block)); + mount_points.push(ruxfs::init_blkfs(all_devices.block)); // setup and initialize 9pfs as mountpoint #[cfg(feature = "virtio-9p")] - mount_points.push(ax9p::init_virtio_9pfs( + mount_points.push(rux9p::init_virtio_9pfs( all_devices._9p, - option_env!("AX_ANAME_9P").unwrap_or(""), - option_env!("AX_PROTOCOL_9P").unwrap_or(""), + option_env!("RUX_ANAME_9P").unwrap_or(""), + option_env!("RUX_PROTOCOL_9P").unwrap_or(""), )); #[cfg(feature = "net-9p")] - mount_points.push(ax9p::init_net_9pfs( - option_env!("AX_9P_ADDR").unwrap_or(""), - option_env!("AX_ANAME_9P").unwrap_or(""), - option_env!("AX_PROTOCOL_9P").unwrap_or(""), + mount_points.push(rux9p::init_net_9pfs( + option_env!("RUX_9P_ADDR").unwrap_or(""), + option_env!("RUX_ANAME_9P").unwrap_or(""), + option_env!("RUX_PROTOCOL_9P").unwrap_or(""), )); - axfs::prepare_commonfs(&mut mount_points); + ruxfs::prepare_commonfs(&mut mount_points); // setup and initialize rootfs - axfs::init_filesystems(mount_points); + ruxfs::init_filesystems(mount_points); } #[cfg(feature = "display")] - axdisplay::init_display(all_devices.display); + ruxdisplay::init_display(all_devices.display); } #[cfg(feature = "smp")] @@ -265,14 +269,13 @@ pub extern "C" fn rust_main(cpu_id: usize, dtb: usize) -> ! { core::hint::spin_loop(); } - let mut argc: c_int = 0; // environ variables and Command line parameters initialization #[cfg(feature = "alloc")] unsafe { + let mut argc: c_int = 0; init_cmdline(&mut argc); #[cfg(not(feature = "musl"))] main(argc, argv); - #[cfg(feature = "musl")] __libc_start_main(main, argc, argv, init_dummy, fini_dummy, ldso_dummy); } @@ -294,11 +297,11 @@ pub extern "C" fn rust_main(cpu_id: usize, dtb: usize) -> ! { }; #[cfg(feature = "multitask")] - axtask::exit(0); + ruxtask::exit(0); #[cfg(not(feature = "multitask"))] { debug!("main task exited: exit_code={}", 0); - axhal::misc::terminate(); + ruxhal::misc::terminate(); } } @@ -306,7 +309,7 @@ pub extern "C" fn rust_main(cpu_id: usize, dtb: usize) -> ! { cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { fn get_boot_str() -> &'static str { - let cmdline_buf: &[u8] = unsafe { &axhal::COMLINE_BUF }; + let cmdline_buf: &[u8] = unsafe { &ruxhal::COMLINE_BUF }; let mut len = 0; for c in cmdline_buf.iter() { if *c == 0 { @@ -343,8 +346,8 @@ fn init_cmdline(argc: &mut c_int) { } // set args unsafe { - RX_ENVIRON.push(core::ptr::null_mut()); - environ = RX_ENVIRON.as_mut_ptr(); + RUX_ENVIRON.push(core::ptr::null_mut()); + environ = RUX_ENVIRON.as_mut_ptr(); let args: Vec<&str> = args.split(',').filter(|i| !i.is_empty()).collect(); *argc = args.len() as c_int; init_argv(args); @@ -353,7 +356,7 @@ fn init_cmdline(argc: &mut c_int) { #[cfg(feature = "alloc")] fn init_allocator() { - use axhal::mem::{memory_regions, phys_to_virt, MemRegionFlags}; + use ruxhal::mem::{memory_regions, phys_to_virt, MemRegionFlags}; info!("Initialize global memory allocator..."); info!(" use {} allocator.", axalloc::global_allocator().name()); @@ -381,14 +384,14 @@ fn init_allocator() { } #[cfg(feature = "paging")] -fn remap_kernel_memory() -> Result<(), axhal::paging::PagingError> { - use axhal::mem::{memory_regions, phys_to_virt}; - use axhal::paging::PageTable; +fn remap_kernel_memory() -> Result<(), ruxhal::paging::PagingError> { use lazy_init::LazyInit; + use ruxhal::mem::{memory_regions, phys_to_virt}; + use ruxhal::paging::PageTable; static KERNEL_PAGE_TABLE: LazyInit = LazyInit::new(); - if axhal::cpu::this_cpu_is_bsp() { + if ruxhal::cpu::this_cpu_is_bsp() { let mut kernel_page_table = PageTable::try_new()?; for r in memory_regions() { kernel_page_table.map_region( @@ -402,35 +405,35 @@ fn remap_kernel_memory() -> Result<(), axhal::paging::PagingError> { KERNEL_PAGE_TABLE.init_by(kernel_page_table); } - unsafe { axhal::arch::write_page_table_root(KERNEL_PAGE_TABLE.root_paddr()) }; + unsafe { ruxhal::arch::write_page_table_root(KERNEL_PAGE_TABLE.root_paddr()) }; Ok(()) } #[cfg(feature = "irq")] fn init_interrupt() { - use axhal::time::TIMER_IRQ_NUM; + use ruxhal::time::TIMER_IRQ_NUM; // Setup timer interrupt handler const PERIODIC_INTERVAL_NANOS: u64 = - axhal::time::NANOS_PER_SEC / axconfig::TICKS_PER_SEC as u64; + ruxhal::time::NANOS_PER_SEC / ruxconfig::TICKS_PER_SEC as u64; #[percpu::def_percpu] static NEXT_DEADLINE: u64 = 0; fn update_timer() { - let now_ns = axhal::time::current_time_nanos(); + let now_ns = ruxhal::time::current_time_nanos(); // Safety: we have disabled preemption in IRQ handler. let mut deadline = unsafe { NEXT_DEADLINE.read_current_raw() }; if now_ns >= deadline { deadline = now_ns + PERIODIC_INTERVAL_NANOS; } unsafe { NEXT_DEADLINE.write_current_raw(deadline + PERIODIC_INTERVAL_NANOS) }; - axhal::time::set_oneshot_timer(deadline); + ruxhal::time::set_oneshot_timer(deadline); } #[cfg(feature = "signal")] fn do_signal() { - let now_ns = axhal::time::current_time_nanos(); + let now_ns = ruxhal::time::current_time_nanos(); // timer signal num let timers = [14, 26, 27]; for (which, timer) in timers.iter().enumerate() { @@ -457,23 +460,23 @@ fn init_interrupt() { } } - axhal::irq::register_handler(TIMER_IRQ_NUM, || { + ruxhal::irq::register_handler(TIMER_IRQ_NUM, || { update_timer(); #[cfg(feature = "signal")] - if axhal::cpu::this_cpu_is_bsp() { + if ruxhal::cpu::this_cpu_is_bsp() { do_signal(); } #[cfg(feature = "multitask")] - axtask::on_timer_tick(); + ruxtask::on_timer_tick(); }); // Enable IRQs before starting app - axhal::arch::enable_irqs(); + ruxhal::arch::enable_irqs(); } #[cfg(all(feature = "tls", not(feature = "multitask")))] fn init_tls() { - let main_tls = axhal::tls::TlsArea::alloc(); - unsafe { axhal::arch::write_thread_pointer(main_tls.tls_ptr() as usize) }; + let main_tls = ruxhal::tls::TlsArea::alloc(); + unsafe { ruxhal::arch::write_thread_pointer(main_tls.tls_ptr() as usize) }; core::mem::forget(main_tls); } diff --git a/modules/axruntime/src/mp.rs b/modules/ruxruntime/src/mp.rs similarity index 79% rename from modules/axruntime/src/mp.rs rename to modules/ruxruntime/src/mp.rs index e05909968..9e3e6be29 100644 --- a/modules/axruntime/src/mp.rs +++ b/modules/ruxruntime/src/mp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,9 +7,9 @@ * See the Mulan PSL v2 for more details. */ -use axconfig::{SMP, TASK_STACK_SIZE}; -use axhal::mem::{virt_to_phys, VirtAddr}; use core::sync::atomic::{AtomicUsize, Ordering}; +use ruxconfig::{SMP, TASK_STACK_SIZE}; +use ruxhal::mem::{virt_to_phys, VirtAddr}; #[link_section = ".bss.stack"] static mut SECONDARY_BOOT_STACK: [[u8; TASK_STACK_SIZE]; SMP - 1] = [[0; TASK_STACK_SIZE]; SMP - 1]; @@ -25,7 +25,7 @@ pub fn start_secondary_cpus(primary_cpu_id: usize) { })); debug!("starting CPU {}...", i); - axhal::mp::start_secondary_cpu(i, stack_top); + ruxhal::mp::start_secondary_cpu(i, stack_top); logic_cpu_id += 1; while ENTERED_CPUS.load(Ordering::Acquire) <= logic_cpu_id { @@ -35,9 +35,9 @@ pub fn start_secondary_cpus(primary_cpu_id: usize) { } } -/// The main entry point of the ArceOS runtime for secondary CPUs. +/// The main entry point of the Ruxos runtime for secondary CPUs. /// -/// It is called from the bootstrapping code in [axhal]. +/// It is called from the bootstrapping code in [ruxhal]. #[no_mangle] pub extern "C" fn rust_main_secondary(cpu_id: usize) -> ! { ENTERED_CPUS.fetch_add(1, Ordering::Relaxed); @@ -46,10 +46,10 @@ pub extern "C" fn rust_main_secondary(cpu_id: usize) -> ! { #[cfg(feature = "paging")] super::remap_kernel_memory().unwrap(); - axhal::platform_init_secondary(); + ruxhal::platform_init_secondary(); #[cfg(feature = "multitask")] - axtask::init_scheduler_secondary(); + ruxtask::init_scheduler_secondary(); info!("Secondary CPU {:x} init OK.", cpu_id); super::INITED_CPUS.fetch_add(1, Ordering::Relaxed); @@ -59,15 +59,15 @@ pub extern "C" fn rust_main_secondary(cpu_id: usize) -> ! { } #[cfg(feature = "irq")] - axhal::arch::enable_irqs(); + ruxhal::arch::enable_irqs(); #[cfg(all(feature = "tls", not(feature = "multitask")))] super::init_tls(); #[cfg(feature = "multitask")] - axtask::run_idle(); + ruxtask::run_idle(); #[cfg(not(feature = "multitask"))] loop { - axhal::arch::wait_for_irqs(); + ruxhal::arch::wait_for_irqs(); } } diff --git a/modules/axruntime/src/signal.rs b/modules/ruxruntime/src/signal.rs similarity index 99% rename from modules/axruntime/src/signal.rs rename to modules/ruxruntime/src/signal.rs index e7866df2c..a979b9b40 100644 --- a/modules/axruntime/src/signal.rs +++ b/modules/ruxruntime/src/signal.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/modules/axruntime/src/trap.rs b/modules/ruxruntime/src/trap.rs similarity index 84% rename from modules/axruntime/src/trap.rs rename to modules/ruxruntime/src/trap.rs index b5584b495..d96fa7b2c 100644 --- a/modules/axruntime/src/trap.rs +++ b/modules/ruxruntime/src/trap.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,12 +10,12 @@ struct TrapHandlerImpl; #[crate_interface::impl_interface] -impl axhal::trap::TrapHandler for TrapHandlerImpl { +impl ruxhal::trap::TrapHandler for TrapHandlerImpl { fn handle_irq(_irq_num: usize) { #[cfg(feature = "irq")] { let guard = kernel_guard::NoPreempt::new(); - axhal::irq::dispatch_irq(_irq_num); + ruxhal::irq::dispatch_irq(_irq_num); drop(guard); // rescheduling may occur when preemption is re-enabled. } } diff --git a/modules/axtask/Cargo.toml b/modules/ruxtask/Cargo.toml similarity index 63% rename from modules/axtask/Cargo.toml rename to modules/ruxtask/Cargo.toml index 6c6109ebf..a2227c092 100644 --- a/modules/axtask/Cargo.toml +++ b/modules/ruxtask/Cargo.toml @@ -1,23 +1,25 @@ [package] -name = "axtask" +name = "ruxtask" version = "0.1.0" edition = "2021" -authors = ["Yuekai Jia "] -description = "ArceOS task management module" +authors = [ + "Yuekai Jia ", + "AuYang261 ", +] +description = "Ruxos task management module" license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/modules/axtask" -documentation = "https://rcore-os.github.io/arceos/axtask/index.html" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/modules/ruxtask" [features] default = [] multitask = [ - "dep:axconfig", "dep:percpu", "dep:spinlock", "dep:lazy_init", "dep:memory_addr", + "dep:ruxconfig", "dep:percpu", "dep:spinlock", "dep:lazy_init", "dep:memory_addr", "dep:scheduler", "dep:timer_list", "kernel_guard", "dep:crate_interface", ] irq = [] -tls = ["axhal/tls"] +tls = ["ruxhal/tls"] musl = [] preempt = ["irq", "percpu?/preempt", "kernel_guard/preempt"] @@ -30,8 +32,8 @@ test = ["percpu?/sp-naive"] [dependencies] cfg-if = "1.0" log = "0.4" -axhal = { path = "../axhal" } -axconfig = { path = "../axconfig", optional = true } +ruxhal = { path = "../ruxhal" } +ruxconfig = { path = "../ruxconfig", optional = true } percpu = { path = "../../crates/percpu", optional = true } spinlock = { path = "../../crates/spinlock", optional = true } lazy_init = { path = "../../crates/lazy_init", optional = true } @@ -43,5 +45,5 @@ crate_interface = { path = "../../crates/crate_interface", optional = true } [dev-dependencies] rand = "0.8" -axhal = { path = "../axhal", features = ["fp_simd"] } -axtask = { path = ".", features = ["test"] } +ruxhal = { path = "../ruxhal", features = ["fp_simd"] } +ruxtask = { path = ".", features = ["test"] } diff --git a/modules/axtask/src/api.rs b/modules/ruxtask/src/api.rs similarity index 93% rename from modules/axtask/src/api.rs rename to modules/ruxtask/src/api.rs index 208413e05..9011add5b 100644 --- a/modules/axtask/src/api.rs +++ b/modules/ruxtask/src/api.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -131,14 +131,14 @@ where /// Spawns a new task with the default parameters. /// /// The default task name is an empty string. The default task stack size is -/// [`axconfig::TASK_STACK_SIZE`]. +/// [`ruxconfig::TASK_STACK_SIZE`]. /// /// Returns the task reference. pub fn spawn(f: F) -> AxTaskRef where F: FnOnce() + Send + 'static, { - spawn_raw(f, "".into(), axconfig::TASK_STACK_SIZE) + spawn_raw(f, "".into(), ruxconfig::TASK_STACK_SIZE) } /// Used by musl @@ -152,7 +152,7 @@ pub fn pspawn( where F: FnOnce() + Send + 'static, { - pspawn_raw(f, "".into(), axconfig::TASK_STACK_SIZE, tls, set_tid, tl) + pspawn_raw(f, "".into(), ruxconfig::TASK_STACK_SIZE, tls, set_tid, tl) } /// Used by musl @@ -185,17 +185,17 @@ pub fn yield_now() { /// /// If the feature `irq` is not enabled, it uses busy-wait instead. pub fn sleep(dur: core::time::Duration) { - sleep_until(axhal::time::current_time() + dur); + sleep_until(ruxhal::time::current_time() + dur); } /// Current task is going to sleep, it will be woken up at the given deadline. /// /// If the feature `irq` is not enabled, it uses busy-wait instead. -pub fn sleep_until(deadline: axhal::time::TimeValue) { +pub fn sleep_until(deadline: ruxhal::time::TimeValue) { #[cfg(feature = "irq")] RUN_QUEUE.lock().sleep_until(deadline); #[cfg(not(feature = "irq"))] - axhal::time::busy_wait_until(deadline); + ruxhal::time::busy_wait_until(deadline); } /// Exits the current task. @@ -216,6 +216,6 @@ pub fn run_idle() -> ! { current().id().as_u64() ); #[cfg(feature = "irq")] - axhal::arch::wait_for_irqs(); + ruxhal::arch::wait_for_irqs(); } } diff --git a/modules/axtask/src/api_s.rs b/modules/ruxtask/src/api_s.rs similarity index 81% rename from modules/axtask/src/api_s.rs rename to modules/ruxtask/src/api_s.rs index ed1ee4199..646ccf2a2 100644 --- a/modules/axtask/src/api_s.rs +++ b/modules/ruxtask/src/api_s.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -13,7 +13,7 @@ /// interrupts. pub fn yield_now() { if cfg!(feature = "irq") { - axhal::arch::wait_for_irqs(); + ruxhal::arch::wait_for_irqs(); } else { core::hint::spin_loop(); } @@ -21,11 +21,11 @@ pub fn yield_now() { /// For single-task situation, we just busy wait for the given duration. pub fn sleep(dur: core::time::Duration) { - axhal::time::busy_wait(dur); + ruxhal::time::busy_wait(dur); } /// For single-task situation, we just busy wait until reaching the given /// deadline. -pub fn sleep_until(deadline: axhal::time::TimeValue) { - axhal::time::busy_wait_until(deadline); +pub fn sleep_until(deadline: ruxhal::time::TimeValue) { + ruxhal::time::busy_wait_until(deadline); } diff --git a/modules/axtask/src/lib.rs b/modules/ruxtask/src/lib.rs similarity index 96% rename from modules/axtask/src/lib.rs rename to modules/ruxtask/src/lib.rs index 28499c253..8993df9f0 100644 --- a/modules/axtask/src/lib.rs +++ b/modules/ruxtask/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS](https://github.com/rcore-os/arceos) task management module. +//! [Ruxos](https://github.com/syswonder/ruxos) task management module. //! //! This module provides primitives for task management, including task //! creation, scheduling, sleeping, termination, etc. The scheduler algorithm diff --git a/modules/axtask/src/loadavg.rs b/modules/ruxtask/src/loadavg.rs similarity index 93% rename from modules/axtask/src/loadavg.rs rename to modules/ruxtask/src/loadavg.rs index 870c222b3..88173308d 100644 --- a/modules/axtask/src/loadavg.rs +++ b/modules/ruxtask/src/loadavg.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -16,7 +16,7 @@ const FSHIFT: u64 = 16; /// fixed point const FIXED_1: u64 = 1 << FSHIFT; /// update AVENRUN per 5 seconds -const LOAD_FREQ: u64 = 5 * axhal::time::NANOS_PER_SEC + 1; +const LOAD_FREQ: u64 = 5 * ruxhal::time::NANOS_PER_SEC + 1; /* 1/exp(5sec/1min) as fixed-point */ /* 1/exp(5sec/5min) */ @@ -56,7 +56,7 @@ pub(crate) fn calc_load_tick(is_idle: bool) { ALL_CNT.fetch_add(1, Ordering::Relaxed); } - let curr = axhal::time::current_time_nanos(); + let curr = ruxhal::time::current_time_nanos(); if curr - unsafe { LAST_UPDATE.load(Ordering::Relaxed) } < LOAD_FREQ { return; diff --git a/modules/axtask/src/run_queue.rs b/modules/ruxtask/src/run_queue.rs similarity index 96% rename from modules/axtask/src/run_queue.rs rename to modules/ruxtask/src/run_queue.rs index e90c9c802..d4fa3613d 100644 --- a/modules/axtask/src/run_queue.rs +++ b/modules/ruxtask/src/run_queue.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -33,7 +33,7 @@ pub(crate) struct AxRunQueue { impl AxRunQueue { pub fn new() -> SpinNoIrq { - let gc_task = TaskInner::new(gc_entry, "gc".into(), axconfig::TASK_STACK_SIZE); + let gc_task = TaskInner::new(gc_entry, "gc".into(), ruxconfig::TASK_STACK_SIZE); let mut scheduler = Scheduler::new(); scheduler.add_task(gc_task); SpinNoIrq::new(Self { scheduler }) @@ -99,7 +99,7 @@ impl AxRunQueue { assert!(!curr.is_idle()); if curr.is_init() { EXITED_TASKS.lock().clear(); - axhal::misc::terminate(); + ruxhal::misc::terminate(); } else { curr.set_state(TaskState::Exited); curr.notify_exit(exit_code, self); @@ -141,13 +141,13 @@ impl AxRunQueue { } #[cfg(feature = "irq")] - pub fn sleep_until(&mut self, deadline: axhal::time::TimeValue) { + pub fn sleep_until(&mut self, deadline: ruxhal::time::TimeValue) { let curr = crate::current(); debug!("task sleep: {}, deadline={:?}", curr.id_name(), deadline); assert!(curr.is_running()); assert!(!curr.is_idle()); - let now = axhal::time::current_time(); + let now = ruxhal::time::current_time(); if now < deadline { crate::timers::set_alarm_wakeup(deadline, curr.clone()); curr.set_state(TaskState::Blocked); diff --git a/modules/axtask/src/task.rs b/modules/ruxtask/src/task.rs similarity index 97% rename from modules/axtask/src/task.rs rename to modules/ruxtask/src/task.rs index 422b94b21..92bee4ad0 100644 --- a/modules/axtask/src/task.rs +++ b/modules/ruxtask/src/task.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -16,10 +16,10 @@ use core::{alloc::Layout, cell::UnsafeCell, fmt, ptr::NonNull}; use core::sync::atomic::AtomicUsize; #[cfg(feature = "tls")] -use axhal::tls::TlsArea; +use ruxhal::tls::TlsArea; -use axhal::arch::TaskContext; use memory_addr::{align_up_4k, VirtAddr}; +use ruxhal::arch::TaskContext; #[cfg(not(feature = "musl"))] use crate::tsd::{DestrFunction, KEYS, TSD}; @@ -172,7 +172,7 @@ impl TaskInner { #[cfg(feature = "tls")] tls: TlsArea::alloc(), #[cfg(not(feature = "musl"))] - tsd: spinlock::SpinNoIrq::new([core::ptr::null_mut(); axconfig::PTHREAD_KEY_MAX]), + tsd: spinlock::SpinNoIrq::new([core::ptr::null_mut(); ruxconfig::PTHREAD_KEY_MAX]), #[cfg(feature = "musl")] set_tid: AtomicU64::new(0), #[cfg(feature = "musl")] @@ -483,7 +483,7 @@ pub struct CurrentTask(ManuallyDrop); impl CurrentTask { pub(crate) fn try_get() -> Option { - let ptr: *const super::AxTask = axhal::cpu::current_task_ptr(); + let ptr: *const super::AxTask = ruxhal::cpu::current_task_ptr(); if !ptr.is_null() { Some(Self(unsafe { ManuallyDrop::new(AxTaskRef::from_raw(ptr)) })) } else { @@ -510,16 +510,16 @@ impl CurrentTask { pub(crate) unsafe fn init_current(init_task: AxTaskRef) { #[cfg(feature = "tls")] - axhal::arch::write_thread_pointer(init_task.tls.tls_ptr() as usize); + ruxhal::arch::write_thread_pointer(init_task.tls.tls_ptr() as usize); let ptr = Arc::into_raw(init_task); - axhal::cpu::set_current_task_ptr(ptr); + ruxhal::cpu::set_current_task_ptr(ptr); } pub(crate) unsafe fn set_current(prev: Self, next: AxTaskRef) { let Self(arc) = prev; ManuallyDrop::into_inner(arc); // `call Arc::drop()` to decrease prev task reference count. let ptr = Arc::into_raw(next); - axhal::cpu::set_current_task_ptr(ptr); + ruxhal::cpu::set_current_task_ptr(ptr); } } @@ -534,7 +534,7 @@ extern "C" fn task_entry() -> ! { // release the lock that was implicitly held across the reschedule unsafe { crate::RUN_QUEUE.force_unlock() }; #[cfg(feature = "irq")] - axhal::arch::enable_irqs(); + ruxhal::arch::enable_irqs(); let task = crate::current(); if let Some(entry) = task.entry { unsafe { Box::from_raw(entry)() }; diff --git a/modules/axtask/src/tests.rs b/modules/ruxtask/src/tests.rs similarity index 85% rename from modules/axtask/src/tests.rs rename to modules/ruxtask/src/tests.rs index 1e3050675..a4f0270b0 100644 --- a/modules/axtask/src/tests.rs +++ b/modules/ruxtask/src/tests.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,7 +10,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Mutex, Once}; -use crate::{self as axtask, current, WaitQueue}; +use crate::{self as ruxtask, current, WaitQueue}; static INIT: Once = Once::new(); static SERIAL: Mutex<()> = Mutex::new(()); @@ -18,16 +18,16 @@ static SERIAL: Mutex<()> = Mutex::new(()); #[test] fn test_sched_fifo() { let _lock = SERIAL.lock(); - INIT.call_once(axtask::init_scheduler); + INIT.call_once(ruxtask::init_scheduler); const NUM_TASKS: usize = 10; static FINISHED_TASKS: AtomicUsize = AtomicUsize::new(0); for i in 0..NUM_TASKS { - axtask::spawn_raw( + ruxtask::spawn_raw( move || { println!("sched_fifo: Hello, task {}! ({})", i, current().id_name()); - axtask::yield_now(); + ruxtask::yield_now(); let order = FINISHED_TASKS.fetch_add(1, Ordering::Relaxed); assert_eq!(order, i); // FIFO scheduler }, @@ -37,14 +37,14 @@ fn test_sched_fifo() { } while FINISHED_TASKS.load(Ordering::Relaxed) < NUM_TASKS { - axtask::yield_now(); + ruxtask::yield_now(); } } #[test] fn test_fp_state_switch() { let _lock = SERIAL.lock(); - INIT.call_once(axtask::init_scheduler); + INIT.call_once(ruxtask::init_scheduler); const NUM_TASKS: usize = 5; const FLOATS: [f64; NUM_TASKS] = [ @@ -57,9 +57,9 @@ fn test_fp_state_switch() { static FINISHED_TASKS: AtomicUsize = AtomicUsize::new(0); for (i, float) in FLOATS.iter().enumerate() { - axtask::spawn(move || { + ruxtask::spawn(move || { let mut value = float + i as f64; - axtask::yield_now(); + ruxtask::yield_now(); value -= i as f64; println!("fp_state_switch: Float {} = {}", i, value); @@ -68,14 +68,14 @@ fn test_fp_state_switch() { }); } while FINISHED_TASKS.load(Ordering::Relaxed) < NUM_TASKS { - axtask::yield_now(); + ruxtask::yield_now(); } } #[test] fn test_wait_queue() { let _lock = SERIAL.lock(); - INIT.call_once(axtask::init_scheduler); + INIT.call_once(ruxtask::init_scheduler); const NUM_TASKS: usize = 10; @@ -84,7 +84,7 @@ fn test_wait_queue() { static COUNTER: AtomicUsize = AtomicUsize::new(0); for _ in 0..NUM_TASKS { - axtask::spawn(move || { + ruxtask::spawn(move || { COUNTER.fetch_add(1, Ordering::Relaxed); println!("wait_queue: task {:?} started", current().id()); WQ1.notify_one(true); // WQ1.wait_until() @@ -116,17 +116,17 @@ fn test_wait_queue() { #[test] fn test_task_join() { let _lock = SERIAL.lock(); - INIT.call_once(axtask::init_scheduler); + INIT.call_once(ruxtask::init_scheduler); const NUM_TASKS: usize = 10; let mut tasks = Vec::with_capacity(NUM_TASKS); for i in 0..NUM_TASKS { - tasks.push(axtask::spawn_raw( + tasks.push(ruxtask::spawn_raw( move || { println!("task_join: task {}! ({})", i, current().id_name()); - axtask::yield_now(); - axtask::exit(i as _); + ruxtask::yield_now(); + ruxtask::exit(i as _); }, format!("T{}", i), 0x1000, diff --git a/modules/axtask/src/timers.rs b/modules/ruxtask/src/timers.rs similarity index 95% rename from modules/axtask/src/timers.rs rename to modules/ruxtask/src/timers.rs index e273c5e87..8f992bc91 100644 --- a/modules/axtask/src/timers.rs +++ b/modules/ruxtask/src/timers.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,8 +8,8 @@ */ use alloc::sync::Arc; -use axhal::time::current_time; use lazy_init::LazyInit; +use ruxhal::time::current_time; use spinlock::SpinNoIrq; use timer_list::{TimeValue, TimerEvent, TimerList}; diff --git a/modules/axtask/src/tsd.rs b/modules/ruxtask/src/tsd.rs similarity index 91% rename from modules/axtask/src/tsd.rs rename to modules/ruxtask/src/tsd.rs index 970c7af86..5aa61bad5 100644 --- a/modules/axtask/src/tsd.rs +++ b/modules/ruxtask/src/tsd.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -18,7 +18,7 @@ use spinlock::SpinNoIrq; /// Destroy a specific key when a thread exits. pub type DestrFunction = unsafe extern "C" fn(*mut c_void); /// Thread-specific data set. -pub(crate) type TSD = SpinNoIrq<[*mut c_void; axconfig::PTHREAD_KEY_MAX]>; +pub(crate) type TSD = SpinNoIrq<[*mut c_void; ruxconfig::PTHREAD_KEY_MAX]>; /// A key for a process. #[derive(Default)] @@ -41,20 +41,20 @@ impl PthreadKey { /// A set of keys for a process. pub(crate) struct PthreadKeys { - keys: [PthreadKey; axconfig::PTHREAD_KEY_MAX], + keys: [PthreadKey; ruxconfig::PTHREAD_KEY_MAX], } impl PthreadKeys { /// Create a new key set. pub fn new() -> Self { - let mut arr: [MaybeUninit; axconfig::PTHREAD_KEY_MAX] = + let mut arr: [MaybeUninit; ruxconfig::PTHREAD_KEY_MAX] = unsafe { MaybeUninit::uninit().assume_init() }; for a in arr.iter_mut() { *a = MaybeUninit::new(PthreadKey::new()); } Self { keys: unsafe { - core::mem::transmute::<_, [PthreadKey; axconfig::PTHREAD_KEY_MAX]>(arr) + core::mem::transmute::<_, [PthreadKey; ruxconfig::PTHREAD_KEY_MAX]>(arr) }, } } diff --git a/modules/axtask/src/wait_queue.rs b/modules/ruxtask/src/wait_queue.rs similarity index 96% rename from modules/axtask/src/wait_queue.rs rename to modules/ruxtask/src/wait_queue.rs index 09c7b6fad..61072071a 100644 --- a/modules/axtask/src/wait_queue.rs +++ b/modules/ruxtask/src/wait_queue.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -18,15 +18,15 @@ use crate::{AxRunQueue, AxTaskRef, CurrentTask, RUN_QUEUE}; /// # Examples /// /// ``` -/// use axtask::WaitQueue; +/// use ruxtask::WaitQueue; /// use core::sync::atomic::{AtomicU32, Ordering}; /// /// static VALUE: AtomicU32 = AtomicU32::new(0); /// static WQ: WaitQueue = WaitQueue::new(); /// -/// axtask::init_scheduler(); +/// ruxtask::init_scheduler(); /// // spawn a new task that updates `VALUE` and notifies the main task -/// axtask::spawn(|| { +/// ruxtask::spawn(|| { /// assert_eq!(VALUE.load(Ordering::Relaxed), 0); /// VALUE.fetch_add(1, Ordering::Relaxed); /// WQ.notify_one(true); // wake up the main task @@ -107,7 +107,7 @@ impl WaitQueue { /// notify it, or the given duration has elapsed. #[cfg(feature = "irq")] pub fn wait_timeout(&self, dur: core::time::Duration) -> bool { - let deadline = dur + axhal::time::current_time(); + let deadline = dur + ruxhal::time::current_time(); self.wait_timeout_absolutely(deadline) } /// Blocks the current task and put it into the wait queue, until other tasks @@ -142,7 +142,7 @@ impl WaitQueue { F: Fn() -> bool, { let curr = crate::current(); - let deadline = axhal::time::current_time() + dur; + let deadline = ruxhal::time::current_time() + dur; debug!( "task wait_timeout: {}, deadline={:?}", curr.id_name(), @@ -151,7 +151,7 @@ impl WaitQueue { crate::timers::set_alarm_wakeup(deadline, curr.clone()); let mut timeout = true; - while axhal::time::current_time() < deadline { + while ruxhal::time::current_time() < deadline { let mut rq = RUN_QUEUE.lock(); if condition() { timeout = false; diff --git a/platforms/aarch64-bsta1000b.toml b/platforms/aarch64-bsta1000b.toml deleted file mode 100644 index 097556a9f..000000000 --- a/platforms/aarch64-bsta1000b.toml +++ /dev/null @@ -1,54 +0,0 @@ -# Architecture identifier. -arch = "aarch64" -# Platform identifier. -platform = "aarch64-bsta1000b" -# Platform family. -family = "aarch64-bsta1000b" - -# Base address of the whole physical memory. -phys-memory-base = "0x80000000" -# Size of the whole physical memory. -phys-memory-size = "0x70000000" -# Base physical address of the kernel image. -kernel-base-paddr = "0x81000000" -# Base virtual address of the kernel image. -kernel-base-vaddr = "0xffff_0000_8100_0000" -# Linear mapping offset, for quick conversions between physical and virtual -# addresses. -phys-virt-offset = "0xffff_0000_0000_0000" -# MMIO regions with format (`base_paddr`, `size`). -mmio-regions = [ - ["0x20008000", "0x1000"], # uart8250 UART0 - ["0x32000000", "0x8000"], # arm,gic-400 - ["0x32011000", "0x1000"], # CPU CSR - ["0x33002000", "0x1000"], # Top CRM - ["0x70035000", "0x1000"], # CRM reg - ["0x70038000", "0x1000"], # aon pinmux -] - -virtio-mmio-regions = [] - -# Base physical address of the PCIe ECAM space. -# pci-ecam-base = "0x40_1000_0000" -# End PCI bus number (`bus-range` property in device tree). -# pci-bus-end = "0xff" -# PCI device memory ranges (`ranges` property in device tree). -# pci-ranges = [] - -# UART Address -uart-paddr = "0x20008000" -# UART irq from device tree -uart-irq = "0xd5" -# GICD Address -gicd-paddr = "0x32001000" -# GICC Address -gicc-paddr = "0x32002000" - -# BST A1000B board registers -CPU_CSR_BASE = "0x32011000" -A1000BASE_TOPCRM = "0x33002000" -A1000BASE_SAFETYCRM = "0x70035000" -A1000BASE_AONCFG = "0x70038000" - -# PSCI -psci-method = "smc" diff --git a/platforms/aarch64-raspi4.toml b/platforms/aarch64-raspi4.toml deleted file mode 100644 index f204d1d1a..000000000 --- a/platforms/aarch64-raspi4.toml +++ /dev/null @@ -1,31 +0,0 @@ -# Architecture identifier. -arch = "aarch64" -# Platform identifier. -platform = "aarch64-raspi4" -# Platform family. -family = "aarch64-raspi" - -# Base address of the whole physical memory. -phys-memory-base = "0x0" -# Size of the whole physical memory. -phys-memory-size = "0xFC00_0000" # 3G 960M -# Base physical address of the kernel image. -kernel-base-paddr = "0x8_0000" -# Base virtual address of the kernel image. -kernel-base-vaddr = "0xffff_0000_0008_0000" -# Linear mapping offset, for quick conversions between physical and virtual -# addresses. -phys-virt-offset = "0xffff_0000_0000_0000" -# MMIO regions with format (`base_paddr`, `size`). -mmio-regions = [ - ["0xFE20_1000", "0x1000"], # PL011 UART - ["0xFF84_1000", "0x8000"], # GICv2 -] -virtio-mmio-regions = [] -# UART Address -uart-paddr = "0xFE20_1000" -uart-irq = "0x79" - -# GIC Address -gicc-paddr = "0xFF84_2000" -gicd-paddr = "0xFF84_1000" diff --git a/platforms/x86_64-pc-oslab.toml b/platforms/x86_64-pc-oslab.toml deleted file mode 100644 index 03363d962..000000000 --- a/platforms/x86_64-pc-oslab.toml +++ /dev/null @@ -1,37 +0,0 @@ -# Architecture identifier. -arch = "x86_64" -# Platform identifier. -platform = "x86_64-pc-oslab" -# Platform family. -family = "x86-pc" - -# Base address of the whole physical memory. -phys-memory-base = "0" -# Size of the whole physical memory. -phys-memory-size = "0x8000_0000" # 2G -# Base physical address of the kernel image. -kernel-base-paddr = "0x20_0000" -# Base virtual address of the kernel image. -kernel-base-vaddr = "0xffff_ff80_0020_0000" -# Linear mapping offset, for quick conversions between physical and virtual -# addresses. -phys-virt-offset = "0xffff_ff80_0000_0000" -# MMIO regions with format (`base_paddr`, `size`). -mmio-regions = [ - ["0xfec0_0000", "0x1000"], # IO APIC - ["0xfed0_0000", "0x1000"], # HPET - ["0xfee0_0000", "0x1000"], # Local APIC - ["0xf000_0000", "0x0800_0000"], # PCI config space - ["0xfcd8_0000", "0x0008_0000"], # Ixgbe BAR0 -] -# VirtIO MMIO regions with format (`base_paddr`, `size`). -virtio-mmio-regions = [] -# Base physical address of the PCIe ECAM space (should read from ACPI 'MCFG' table). -pci-ecam-base = "0xf000_0000" -# End PCI bus number. -pci-bus-end = "0x7f" -# PCI device memory ranges (not used on x86). -pci-ranges = [] - -# Timer interrupt frequencyin Hz. -timer-frequency = "4_000_000_000" # 4.0GHz diff --git a/scripts/make/build.mk b/scripts/make/build.mk index 529014c8a..6bdfa497d 100644 --- a/scripts/make/build.mk +++ b/scripts/make/build.mk @@ -23,7 +23,7 @@ else ifeq ($(filter $(MAKECMDGOALS),clippy unittest unittest_no_fail_fast),) # n $(info APP: "$(APP)") $(info APP_TYPE: "$(APP_TYPE)") $(info FEATURES: "$(FEATURES)") - $(info arceos features: "$(AX_FEAT)") + $(info ruxos features: "$(RUX_FEAT)") $(info lib features: "$(LIB_FEAT)") $(info app features: "$(APP_FEAT)") endif @@ -38,13 +38,13 @@ endif _cargo_build: @printf " $(GREEN_C)Building$(END_C) App: $(APP_NAME), Arch: $(ARCH), Platform: $(PLATFORM_NAME), App type: $(APP_TYPE)\n" ifeq ($(APP_TYPE), rust) - $(call cargo_build,--manifest-path $(APP)/Cargo.toml,$(AX_FEAT) $(LIB_FEAT) $(APP_FEAT)) + $(call cargo_build,--manifest-path $(APP)/Cargo.toml,$(RUX_FEAT) $(LIB_FEAT) $(APP_FEAT)) @cp $(rust_elf) $(OUT_ELF) else ifeq ($(APP_TYPE), c) ifeq ($(MUSL), y) - $(call cargo_build,-p axmusl,$(AX_FEAT) $(LIB_FEAT)) + $(call cargo_build,-p ruxmusl,$(RUX_FEAT) $(LIB_FEAT)) else - $(call cargo_build,-p axlibc,$(AX_FEAT) $(LIB_FEAT)) + $(call cargo_build,-p ruxlibc,$(RUX_FEAT) $(LIB_FEAT)) endif endif diff --git a/scripts/make/build_c.mk b/scripts/make/build_c.mk index cb92d1673..5a2cc6c70 100644 --- a/scripts/make/build_c.mk +++ b/scripts/make/build_c.mk @@ -1,7 +1,7 @@ -rust_lib_name := axlibc +rust_lib_name := ruxlibc rust_lib := target/$(TARGET)/$(MODE)/lib$(rust_lib_name).a -ulib_dir := ulib/axlibc +ulib_dir := ulib/ruxlibc src_dir := $(ulib_dir)/c obj_dir := $(ulib_dir)/build_$(ARCH) inc_dir := $(ulib_dir)/include @@ -14,8 +14,8 @@ ulib_src := $(wildcard $(src_dir)/*.c) ulib_hdr := $(wildcard $(inc_dir)/*.h) ulib_obj := $(patsubst $(src_dir)/%.c,$(obj_dir)/%.o,$(ulib_src)) -CFLAGS += $(addprefix -DAX_CONFIG_,$(shell echo $(lib_feat) | tr 'a-z' 'A-Z' | tr '-' '_')) -CFLAGS += -DAX_LOG_$(shell echo $(LOG) | tr 'a-z' 'A-Z') +CFLAGS += $(addprefix -DRUX_CONFIG_,$(shell echo $(lib_feat) | tr 'a-z' 'A-Z' | tr '-' '_')) +CFLAGS += -DRUX_LOG_$(shell echo $(LOG) | tr 'a-z' 'A-Z') CFLAGS += -nostdinc -fno-builtin -ffreestanding -Wall CFLAGS += -I$(CURDIR)/$(inc_dir) diff --git a/scripts/make/build_musl.mk b/scripts/make/build_musl.mk index 74ae50028..80fb61656 100644 --- a/scripts/make/build_musl.mk +++ b/scripts/make/build_musl.mk @@ -1,9 +1,9 @@ -rust_lib_name := axmusl +rust_lib_name := ruxmusl rust_lib := target/$(TARGET)/$(MODE)/lib$(rust_lib_name).a musl_version := 1.2.3 -muslibc_dir := ulib/axmusl +muslibc_dir := ulib/ruxmusl build_dir := $(muslibc_dir)/build_musl_$(ARCH) musl_dir := $(muslibc_dir)/musl-$(musl_version) inc_dir := $(muslibc_dir)/install/include @@ -45,7 +45,7 @@ ifeq ($(wildcard $(build_dir)),) tar -zxvf $(muslibc_dir)/musl-1.2.3.tar.gz -C $(muslibc_dir) && rm -f $(muslibc_dir)/musl-1.2.3.tar.gz endif mkdir -p $(build_dir) - cd $(build_dir) && ../musl-1.2.3/configure --prefix=../install --exec-prefix=../ --syslibdir=../install/lib --disable-shared ARCH=$(AX_ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) CFLAGS=$(CFLAGS) + cd $(build_dir) && ../musl-1.2.3/configure --prefix=../install --exec-prefix=../ --syslibdir=../install/lib --disable-shared ARCH=$(RUX_ARCH) CC=$(CC) CROSS_COMPILE=$(CROSS_COMPILE) CFLAGS=$(CFLAGS) cd $(build_dir) && $(MAKE) -j && $(MAKE) install endif diff --git a/scripts/make/cargo.mk b/scripts/make/cargo.mk index fc07ea2da..1b1bfa403 100644 --- a/scripts/make/cargo.mk +++ b/scripts/make/cargo.mk @@ -39,10 +39,10 @@ endef all_packages := \ $(shell ls $(CURDIR)/crates) \ $(shell ls $(CURDIR)/modules) \ - axfeat arceos_api axstd axlibc + ruxfeat arceos_api axstd ruxlibc ruxmusl define cargo_doc - $(call run_cmd,cargo doc,--no-deps --all-features --workspace --exclude "arceos-*" $(verbose)) + $(call run_cmd,cargo doc,--no-deps --all-features --workspace --exclude "arceos-*" --exclude "ruxos-*" --exclude "ruxos-*" $(verbose)) @# run twice to fix broken hyperlinks $(foreach p,$(all_packages), \ $(call run_cmd,cargo rustdoc,--all-features -p $(p) $(verbose)) diff --git a/scripts/make/features.mk b/scripts/make/features.mk index 69b5b84e9..8c5f63cff 100644 --- a/scripts/make/features.mk +++ b/scripts/make/features.mk @@ -2,25 +2,25 @@ # # Inputs: # - `FEATURES`: a list of features to be enabled split by spaces or commas. -# The features can be selected from the crate `axfeat` or the user library -# (crate `axstd` or `axlibc`). +# The features can be selected from the crate `ruxfeat` or the user library +# (crate `axstd` or `ruxlibc`). # - `APP_FEATURES`: a list of features to be enabled for the Rust app. # # Outputs: -# - `AX_FEAT`: features to be enabled for ArceOS modules (crate `axfeat`). -# - `LIB_FEAT`: features to be enabled for the user library (crate `axstd`, `axlibc`). +# - `RUX_FEAT`: features to be enabled for Ruxos modules (crate `ruxfeat`). +# - `LIB_FEAT`: features to be enabled for the user library (crate `axstd`, `ruxlibc`, `ruxmusl`). # - `APP_FEAT`: features to be enabled for the Rust app. ifeq ($(APP_TYPE),c) - ax_feat_prefix := axfeat/ + ax_feat_prefix := ruxfeat/ ifeq ($(MUSL), y) - lib_feat_prefix := axmusl/ + lib_feat_prefix := ruxmusl/ else - lib_feat_prefix := axlibc/ + lib_feat_prefix := ruxlibc/ endif lib_features := fp_simd alloc multitask fs net fd pipe select poll epoll random-hw signal else - # TODO: it's better to use `axfeat/` as `ax_feat_prefix`, but all apps need to have `axfeat` as a dependency + # TODO: it's better to use `ruxfeat/` as `ax_feat_prefix`, but all apps need to have `ruxfeat` as a dependency ax_feat_prefix := axstd/ lib_feat_prefix := axstd/ lib_features := @@ -40,7 +40,7 @@ ifeq ($(APP_TYPE), c) ifneq ($(filter fs net pipe select poll epoll,$(FEATURES)),) override FEATURES += fd endif - ifeq ($(AX_MUSL), y) + ifeq ($(RUX_MUSL), y) override FEATURES += musl override FEATURES += fp_simd override FEATURES += fd @@ -70,6 +70,6 @@ endif ax_feat += $(filter-out $(lib_features),$(FEATURES)) lib_feat += $(filter $(lib_features),$(FEATURES)) -AX_FEAT := $(strip $(addprefix $(ax_feat_prefix),$(ax_feat))) +RUX_FEAT := $(strip $(addprefix $(ax_feat_prefix),$(ax_feat))) LIB_FEAT := $(strip $(addprefix $(lib_feat_prefix),$(lib_feat))) APP_FEAT := $(strip $(shell echo $(APP_FEATURES) | tr ',' ' ')) diff --git a/scripts/make/raspi4.mk b/scripts/make/raspi4.mk deleted file mode 100644 index 66eea697b..000000000 --- a/scripts/make/raspi4.mk +++ /dev/null @@ -1,94 +0,0 @@ -include tools/raspi4/common/docker.mk -include tools/raspi4/common/format.mk -include tools/raspi4/common/operating_system.mk - -##-------------------------------------------------------------------------------------------------- -## Optional, user-provided configuration values -##-------------------------------------------------------------------------------------------------- - -# Default to the RPi4. -BSP ?= rpi4 - -# Default to a serial device name that is common in Linux. -DEV_SERIAL ?= /dev/ttyUSB0 - -##-------------------------------------------------------------------------------------------------- -## BSP-specific configuration values -##-------------------------------------------------------------------------------------------------- -QEMU_MISSING_STRING = "This board is not yet supported for QEMU." - -ifeq ($(BSP),rpi4) - TARGET = aarch64-unknown-none-softfloat - KERNEL_BIN := $(OUT_BIN) - OBJDUMP_BINARY = aarch64-none-elf-objdump - NM_BINARY = aarch64-none-elf-nm - READELF_BINARY = aarch64-none-elf-readelf - OPENOCD_ARG = -f /openocd/tcl/interface/ftdi/olimex-arm-usb-tiny-h.cfg -f /openocd/rpi4.cfg - JTAG_BOOT_IMAGE = tools/raspi4/X1_JTAG_boot/jtag_boot_rpi4.img - RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 -endif - -EXEC_MINIPUSH = ruby tools/raspi4/common/serial/minipush.rb - -##------------------------------------------------------------------------------ -## Dockerization -##------------------------------------------------------------------------------ -DOCKER_CMD = docker run -t --rm -v $(shell pwd):/work/tutorial -w /work/tutorial -DOCKER_CMD_INTERACT = $(DOCKER_CMD) -i -DOCKER_ARG_DIR_COMMON = -v $(shell pwd)/tools/raspi4/common:/work/common -DOCKER_ARG_DIR_JTAG = -v $(shell pwd)/tools/raspi4/X1_JTAG_boot:/work/X1_JTAG_boot -DOCKER_ARG_DEV = --privileged -v /dev:/dev -DOCKER_ARG_NET = --network host - -# DOCKER_IMAGE defined in include file (see top of this file). -DOCKER_GDB = $(DOCKER_CMD_INTERACT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) - -# Dockerize commands, which require USB device passthrough, only on Linux. -ifeq ($(shell uname -s),Linux) - DOCKER_CMD_DEV = $(DOCKER_CMD_INTERACT) $(DOCKER_ARG_DEV) - DOCKER_CHAINBOOT = $(DOCKER_CMD_DEV) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_IMAGE) - DOCKER_JTAGBOOT = $(DOCKER_CMD_DEV) $(DOCKER_ARG_DIR_COMMON) $(DOCKER_ARG_DIR_JTAG) $(DOCKER_IMAGE) - DOCKER_OPENOCD = $(DOCKER_CMD_DEV) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) -else - DOCKER_OPENOCD = echo "Not yet supported on non-Linux systems."; \# -endif - -##-------------------------------------------------------------------------------------------------- -## Targets -##-------------------------------------------------------------------------------------------------- -.PHONY: all chainboot - -all: $(KERNEL_BIN) - -##------------------------------------------------------------------------------ -## Push the kernel to the real HW target -##------------------------------------------------------------------------------ -chainboot: $(KERNEL_BIN) - @$(DOCKER_CHAINBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(KERNEL_BIN) - - -##-------------------------------------------------------------------------------------------------- -## Debugging targets -##-------------------------------------------------------------------------------------------------- -.PHONY: jtagboot openocd gdb gdb-opt0 - -##------------------------------------------------------------------------------ -## Push the JTAG boot image to the real HW target -##------------------------------------------------------------------------------ -jtagboot: $(KERNEL_BIN) - @$(DOCKER_JTAGBOOT) $(EXEC_MINIPUSH) $(DEV_SERIAL) $(JTAG_BOOT_IMAGE) - -##------------------------------------------------------------------------------ -## Start OpenOCD session -##------------------------------------------------------------------------------ -openocd: - $(call color_header, "Launching OpenOCD") - @$(DOCKER_OPENOCD) openocd $(OPENOCD_ARG) - -##------------------------------------------------------------------------------ -## Start GDB session -##------------------------------------------------------------------------------ -gdb: RUSTC_MISC_ARGS += -C debuginfo=2 -gdb: $(KERNEL_ELF) - $(call color_header, "Launching GDB") - @$(DOCKER_GDB) gdb-multiarch -q $(KERNEL_ELF) diff --git a/scripts/make/test.mk b/scripts/make/test.mk index a29d670b8..c49273405 100644 --- a/scripts/make/test.mk +++ b/scripts/make/test.mk @@ -2,8 +2,8 @@ define unit_test $(call run_cmd,cargo test,-p percpu $(1) -- --nocapture) - $(call run_cmd,cargo test,-p axfs $(1) --features "myfs" -- --nocapture) - $(call run_cmd,cargo test,--workspace --exclude "arceos-*" $(1) -- --nocapture) + $(call run_cmd,cargo test,-p ruxfs $(1) --features "myfs" -- --nocapture) + $(call run_cmd,cargo test,--workspace --exclude "arceos-*" --exclude "ruxos-*" $(1) -- --nocapture) endef test_app := diff --git a/scripts/net/qemu-tap-ifdown.sh b/scripts/net/qemu-tap-ifdown.sh deleted file mode 100755 index 12622a36b..000000000 --- a/scripts/net/qemu-tap-ifdown.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -HOST_IF=$1 - -if [ -z "$HOST_IF" ]; then - echo "Usage: $0 " - exit 1 -fi - -echo "Deleting tap interface for QEMU" - -ip link del tap0 -sysctl -w net.ipv4.ip_forward=0 -iptables -t nat -D POSTROUTING -s 10.0.2.0/24 -o ${HOST_IF} -j MASQUERADE diff --git a/scripts/net/qemu-tap-ifup.sh b/scripts/net/qemu-tap-ifup.sh deleted file mode 100755 index 1adabc9b8..000000000 --- a/scripts/net/qemu-tap-ifup.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -HOST_IF=$1 - -if [ -z "$HOST_IF" ]; then - echo "Usage: $0 " - exit 1 -fi - -echo "Setting up tap interface for QEMU" - -ip tuntap add tap0 mode tap -ip addr add 10.0.2.2/24 dev tap0 -ip link set up dev tap0 - -sysctl -w net.ipv4.ip_forward=1 -iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o ${HOST_IF} -j MASQUERADE diff --git a/scripts/test/app_test.sh b/scripts/test/app_test.sh index 48a163c1a..b81ae0885 100755 --- a/scripts/test/app_test.sh +++ b/scripts/test/app_test.sh @@ -106,15 +106,6 @@ function test_one() { if [ -z "$1" ]; then test_list=( - "apps/helloworld" - "apps/memtest" - "apps/exception" - "apps/task/yield" - "apps/task/parallel" - "apps/task/sleep" - "apps/task/priority" - "apps/task/tls" - "apps/net/httpclient" "apps/c/helloworld" "apps/c/memtest" "apps/c/sqlite3" diff --git a/tools/.gitignore b/tools/.gitignore deleted file mode 100644 index 632baf2a0..000000000 --- a/tools/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -deptool/Cargo.lock -deptool/target -deptool/output.txt -bwbench_client/target -bwbench_client/Cargo.lock \ No newline at end of file diff --git a/tools/bsta1000b/bsta1000b-fada-arceos.its b/tools/bsta1000b/bsta1000b-fada-arceos.its deleted file mode 100755 index 8062b6354..000000000 --- a/tools/bsta1000b/bsta1000b-fada-arceos.its +++ /dev/null @@ -1,50 +0,0 @@ -/* - * U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs - */ - -/dts-v1/; - -/ { - description = "Various kernels, ramdisks and FDT blobs"; - #address-cells = <1>; - - images { - kernel { - description = "ArceOS for BST A1000B"; - data = /incbin/("../../arceos-fada.bin.gz"); - type = "kernel"; - arch = "arm64"; - os = "linux"; - compression = "gzip"; - load = <0x81000000>; - entry = <0x81000000>; - hash-1 { - algo = "md5"; - }; - hash-2 { - algo = "sha1"; - }; - }; - - fdt-fada { - description = "bsta1000b-fada fdt"; - data = /incbin/("./bsta1000b-fada.dtb"); - type = "flat_dt"; - arch = "arm64"; - compression = "none"; - hash-1 { - algo = "crc32"; - }; - }; - }; - - configurations { - default = "config-fada"; - - config-fada { - description = "bsta1000b fada configuration"; - kernel = "kernel"; - fdt = "fdt-fada"; - }; - }; -}; diff --git a/tools/bsta1000b/bsta1000b-fada.dtb b/tools/bsta1000b/bsta1000b-fada.dtb deleted file mode 100644 index ff0ea9a42..000000000 Binary files a/tools/bsta1000b/bsta1000b-fada.dtb and /dev/null differ diff --git a/tools/bwbench_client/Cargo.toml b/tools/bwbench_client/Cargo.toml deleted file mode 100644 index 5f20be709..000000000 --- a/tools/bwbench_client/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "bwbench-client" -version = "0.1.0" -edition = "2021" -authors = ["ChengXiang Qi "] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -chrono = "0.4" -libc = "0.2.18" - -[workspace] \ No newline at end of file diff --git a/tools/bwbench_client/README.md b/tools/bwbench_client/README.md deleted file mode 100644 index 0d447ccc0..000000000 --- a/tools/bwbench_client/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Benchmark BandWidth Client - -Benchmark BandWidth Client is a performance testing tool for measuring the network card's ability to send Ethernet packets. It can test both the transmission throughput and the reception throughput. - -## Usage -In client: -```shell -cargo build --release -sudo ./target/release/bwbench_client [sender|receiver] [interface] -``` - -By reading the source code, you can control the behavior of the benchmark by modifying constants such as `MAX_BYTES`. - -In arceos: - -```shell -make A=apps/net/bwbench LOG=info NET=y run -``` - -By default, arceos `bebench` uses `bench_transmit`. You can uncomment the line and add `bench_receive`, but please note that currently only one of either `bench_transmit` or `bench_receive` is allowed to be enabled. - - -## Example: benchmark bandwidth of QEMU tap netdev - -In client: - -```shell -cargo build --release -sudo ./scripts/net/qemu-tap-ifup.sh enp8s0 -sudo ./target/release/bwbench_client [sender|receiver] tap0 -``` - -In arceos: - -```shell -make A=apps/net/bwbench LOG=info NET=y NET_DEV=tap run -``` diff --git a/tools/bwbench_client/src/device.rs b/tools/bwbench_client/src/device.rs deleted file mode 100644 index 5345c8a25..000000000 --- a/tools/bwbench_client/src/device.rs +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use std::os::unix::io::AsRawFd; - -const ETH_P_ALL: libc::c_short = 0x0003; -const SIOCGIFINDEX: libc::c_ulong = 0x8933; -const SIOCGIFMTU: libc::c_ulong = 0x8921; -const SIOCSIFMTU: libc::c_ulong = 0x8922; -const SIOCGIFHWADDR: libc::c_ulong = 0x8927; - -#[repr(C)] -#[derive(Clone, Copy)] -#[allow(non_camel_case_types)] -union ifreq_data { - ifr_mtu: libc::c_int, - mac_addr: libc::sockaddr, -} - -#[repr(C)] -#[allow(non_camel_case_types)] -struct ifreq { - ifr_name: [libc::c_char; libc::IF_NAMESIZE], - ifr_data: ifreq_data, -} - -impl ifreq { - #[cfg(target_os = "linux")] - fn ifreq_for(interface: &str) -> ifreq { - let mut ifreq = ifreq { - ifr_name: [0; libc::IF_NAMESIZE], - ifr_data: ifreq_data { ifr_mtu: 0 }, - }; - for (i, byte) in interface.as_bytes().iter().enumerate() { - ifreq.ifr_name[i] = *byte as libc::c_char - } - ifreq - } - - #[cfg(target_os = "linux")] - fn ioctl(&mut self, lower: libc::c_int, cmd: libc::c_ulong) -> std::io::Result { - unsafe { - if libc::ioctl(lower, cmd as _, self as *mut Self) < 0 { - return Err(std::io::Error::last_os_error()); - } - } - Ok(self.ifr_data) - } -} - -pub struct NetDevice { - fd: libc::c_int, - ifreq: ifreq, - mac_addr: [u8; 6], -} - -impl AsRawFd for NetDevice { - fn as_raw_fd(&self) -> std::os::unix::io::RawFd { - self.fd - } -} - -impl NetDevice { - pub fn new(interface: &str) -> std::io::Result { - #[cfg(target_os = "linux")] - { - let lower = unsafe { - let lower = libc::socket( - libc::AF_PACKET, - libc::SOCK_RAW | libc::SOCK_NONBLOCK, - ETH_P_ALL.to_be() as i32, - ); - if lower == -1 { - return Err(std::io::Error::last_os_error()); - } - lower - }; - - let mut ifreq = ifreq::ifreq_for(interface); - - let ifreq_mac_addr = unsafe { ifreq.ioctl(lower, SIOCGIFHWADDR)?.mac_addr }; - let mut mac_addr = [0u8; 6]; - for i in 0..6 { - mac_addr[i] = ifreq_mac_addr.sa_data[i] as u8; - } - - println!( - "Device MAC: {:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", - mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5] - ); - - let mut dev = Self { - fd: lower, - ifreq, - mac_addr, - }; - - dev.bind_interface()?; - - let mtu = dev.interface_mtu()?; - println!("DEVICE MTU: {}", mtu); - - Ok(dev) - } - #[cfg(not(target_os = "linux"))] - { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "Not supported", - )) - } - } - - pub fn mac_addr(&self) -> [u8; 6] { - self.mac_addr - } - - pub fn bind_interface(&mut self) -> std::io::Result<()> { - #[cfg(target_os = "linux")] - { - let sockaddr = libc::sockaddr_ll { - sll_family: libc::AF_PACKET as u16, - sll_protocol: ETH_P_ALL.to_be() as u16, - sll_ifindex: unsafe { - self.ifreq.ioctl(self.fd, SIOCGIFINDEX)?.ifr_mtu as libc::c_int - }, - sll_hatype: 1, - sll_pkttype: 0, - sll_halen: 6, - sll_addr: [0; 8], - }; - - unsafe { - let res = libc::bind( - self.fd, - &sockaddr as *const libc::sockaddr_ll as *const libc::sockaddr, - std::mem::size_of::() as libc::socklen_t, - ); - if res == -1 { - return Err(std::io::Error::last_os_error()); - } - } - - Ok(()) - } - #[cfg(not(target_os = "linux"))] - { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "Not supported", - )) - } - } - - pub fn interface_mtu(&mut self) -> std::io::Result { - #[cfg(target_os = "linux")] - { - self.ifreq - .ioctl(self.fd, SIOCGIFMTU) - .map(|mtu| unsafe { mtu.ifr_mtu as usize }) - } - #[cfg(not(target_os = "linux"))] - { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "Not supported", - )) - } - } - - pub fn recv(&mut self, buffer: &mut [u8]) -> std::io::Result { - let len = unsafe { - libc::recv( - self.fd, - buffer.as_mut_ptr() as *mut libc::c_void, - buffer.len(), - 0, - ) - }; - - if len == -1 { - let err = std::io::Error::last_os_error(); - if err.kind() == std::io::ErrorKind::WouldBlock { - return Err(err); - } else { - panic!("err: {:?}", err); - } - } - Ok(len as usize) - } - - pub fn send(&mut self, buffer: &[u8]) -> std::io::Result { - let len = unsafe { - libc::send( - self.fd, - buffer.as_ptr() as *const libc::c_void, - buffer.len(), - 0, - ) - }; - - if len == -1 { - let err = std::io::Error::last_os_error(); - if err.kind() == std::io::ErrorKind::WouldBlock { - return Err(err); - } else { - panic!("err: {:?}", err); - } - } - Ok(len as usize) - } -} - -impl Drop for NetDevice { - fn drop(&mut self) { - unsafe { - libc::close(self.fd); - } - } -} diff --git a/tools/bwbench_client/src/main.rs b/tools/bwbench_client/src/main.rs deleted file mode 100644 index c09b6c8f5..000000000 --- a/tools/bwbench_client/src/main.rs +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -//! A raw socket benchmark client. - -#![deny(warnings)] -#![deny(missing_docs)] -#![allow(dead_code, unused_variables)] - -use crate::device::NetDevice; -use chrono::Local; -use std::env; -use std::fmt::Display; - -mod device; - -const STANDARD_MTU: usize = 1500; - -const MAX_BYTES: usize = 10 * GB; -const MB: usize = 1000 * 1000; -const GB: usize = 1000 * MB; - -struct EthernetMacAddress([u8; 6]); - -impl Display for EthernetMacAddress { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mac = self.0; - write!( - f, - "{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] - ) - } -} - -enum Client { - Sender, - Receiver, -} - -fn transmit_benchmark(interface: &str) { - println!("Sender Mode!"); - let mut dev = NetDevice::new(interface).unwrap(); - - let mut tx_buf = [1u8; STANDARD_MTU]; - // ether type: IPv4 - tx_buf[12..14].copy_from_slice(&[0x08, 0x00]); - - let mut send_bytes = 0; - let mut past_send_bytes = 0; - let mut past_time = Local::now(); - - loop { - if let Ok(len) = dev.send(&tx_buf[..]) { - send_bytes += len; - let current_time = Local::now(); - if current_time.signed_duration_since(past_time).num_seconds() == 1 { - let gb = ((send_bytes - past_send_bytes) * 8) / GB; - let mb = (((send_bytes - past_send_bytes) * 8) % GB) / MB; - let gib = (send_bytes - past_send_bytes) / GB; - let mib = ((send_bytes - past_send_bytes) % GB) / MB; - println!( - "Transfer: {}.{:03}GBytes, Bandwidth: {}.{:03}Gbits/sec.", - gib, mib, gb, mb - ); - past_send_bytes = send_bytes; - past_time = current_time; - } - } - - if send_bytes >= MAX_BYTES { - break; - } - } -} - -fn receive_benchmark(interface: &str) { - println!("Receiver Mode!"); - let mut dev = NetDevice::new(interface).unwrap(); - - let mut receive_bytes = 0; - let mut past_receive_bytes = 0; - let mut past_time = Local::now(); - - let mut rx_buffer = [0; STANDARD_MTU]; - - loop { - if let Ok(len) = dev.recv(&mut rx_buffer) { - receive_bytes += len; - } - - let current_time = Local::now(); - if current_time.signed_duration_since(past_time).num_seconds() == 1 { - let gb = ((receive_bytes - past_receive_bytes) * 8) / GB; - let mb = (((receive_bytes - past_receive_bytes) * 8) % GB) / MB; - let gib = (receive_bytes - past_receive_bytes) / GB; - let mib = ((receive_bytes - past_receive_bytes) % GB) / MB; - println!( - "Receive: {}.{:03}GBytes, Bandwidth: {}.{:03}Gbits/sec.", - gib, mib, gb, mb - ); - past_receive_bytes = receive_bytes; - past_time = current_time; - } - - if receive_bytes >= MAX_BYTES { - break; - } - } -} - -fn benchmark_bandwidth(client: Client, interface: &str) { - match client { - Client::Sender => transmit_benchmark(interface), - Client::Receiver => receive_benchmark(interface), - } -} - -fn main() { - let args: Vec = env::args().collect(); - - if args.len() < 3 { - panic!("Usage: cargo run --release [send|receive] "); - } - - let kind = args[1].as_str(); - let client = match kind.chars().next().unwrap() { - 's' => Client::Sender, - 'r' => Client::Receiver, - _ => panic!("Unknown Mode!"), - }; - - let interface = args[2].as_str(); - - benchmark_bandwidth(client, interface); -} diff --git a/tools/deptool/Cargo.toml b/tools/deptool/Cargo.toml deleted file mode 100644 index 3a2e95435..000000000 --- a/tools/deptool/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "deptool" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - clap = {version = "4.3.5"} -[workspace] diff --git a/tools/deptool/Makefile b/tools/deptool/Makefile deleted file mode 100644 index e046bbeb9..000000000 --- a/tools/deptool/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -FEATURES ?= default -DEFAULT ?= y -FORMAT ?= mermaid -TARGET ?= helloworld -SAVE_PATH ?= output.txt -_DEFAULT_OPT = -_FEATURES_OPT = -BUILD_DIR = ./target - -ifeq ($(DEFAULT), y) - _DEFAULT_OPT = --no-default -endif - -ifneq ($(FEATURES), default) - _FEATURES_OPT = --name $(FEATURES) -endif - -ifeq ($(TARGET),) - $(error must specify a target using TARGET=... which should be a valid module, crate or app path) -endif - -clean: - cargo clean - rm $(SAVE_PATH) - -run: - @cargo build - @./target/debug/deptool $(_DEFAULT_OPT) \ - $(_FEATURES_OPT) \ - --format $(FORMAT) \ - --target $(TARGET) \ - --save-path $(SAVE_PATH) - -.PHONY: build run clean diff --git a/tools/deptool/README.md b/tools/deptool/README.md deleted file mode 100644 index 0d43a5718..000000000 --- a/tools/deptool/README.md +++ /dev/null @@ -1,17 +0,0 @@ -## Usage of this tool - -``` -make run FORMAT=mermaid FEATURES=f1,f2,f3 DEFAULT=n -``` - -the `FORMAT` can be either **mermaid** or **d2** (default is mermaid), it will out put the result under the deptool directory. - -the `TARGET` should be any existed crate or module name, or the path under app directory: eg helloworld, net/httpserver - -the `FEATURES` should be the features you want to use, this should be separated by "," - -the `DEFAULT` is used to control enable default features or not **n** for no and **y** for yes - -the first time you run this tool to analyze a crate/module/app will be slow or blocked for downloading the needed crates for the target - -if you think this makefile too naive, you can just run `cargo build`, and then use `./target/debug/deptool -h` to see the available options to use diff --git a/tools/deptool/src/cmd_builder.rs b/tools/deptool/src/cmd_builder.rs deleted file mode 100644 index aa01b2625..000000000 --- a/tools/deptool/src/cmd_builder.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::Config; - -pub fn build_cargo_tree_cmd(cfg: &Config) -> String { - let default_opt = match cfg.no_default { - true => "", - false => "--no-default-features" - }; - - let features_opt = match cfg.features.len() { - 0 => "".to_string(), - _ => "-F ".to_string() + cfg.features.join(" ").as_str() - }; - let path = &cfg.loc; - let cmd_str = format!( - "cd {path} && cargo tree -e normal,build {default_opt} {features_opt} --format {{p}} --prefix depth", - ); - cmd_str.to_string() -} diff --git a/tools/deptool/src/cmd_parser.rs b/tools/deptool/src/cmd_parser.rs deleted file mode 100644 index c679cb456..000000000 --- a/tools/deptool/src/cmd_parser.rs +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use std::{fs, path::Path}; -use clap::{Arg, ArgAction, Command}; -use crate::{Config, GraphFormat}; - -static APP_ROOT: &str = "../../apps/"; -static CRATE_ROOT: &str = "../../crates/"; -static MODULE_ROOT: &str = "../../modules/"; -static ULIB_ROOT: &str = "../../ulib/"; - - -/// Ex: exe --default=false --format=mermaid --features=f1 f2 f3 -pub fn parse_cmd() -> Result { - let matches = Command::new("Dependency analysis tool for Arceos") - .version("1.0") - .author("ctr") - .about("Generate d2 or mermaid dependency graph for Arceos based on cargo tree") - .arg( - Arg::new("no-default").short('d').long("no-default").action(ArgAction::SetFalse) - ) - .arg( - Arg::new("features").short('f').long("name").action(ArgAction::Append) - ) - .arg( - Arg::new("format").short('o').long("format").default_value("mermaid") - ) - .arg( - Arg::new("target").short('t').long("target").required(true) - ) - .arg( - Arg::new("save-path").short('s').long("save-path").default_value("out.txt") - ) - .get_matches(); - - let is_default = matches.get_flag("no-default"); - let features = matches.get_many::("features").unwrap_or_default() - .map(|f| f.to_string()) - .collect(); - let format = match matches.get_one::("format").unwrap().as_str() { - "d2" => GraphFormat::D2, - _ => GraphFormat::Mermaid - }; - let target = matches.get_one::("target").unwrap().to_string(); - if !is_arceos_crate(&target) { - return Err("target not exist, should be valid arceos crate, module or app"); - } - - let loc; - if check_crate_name(&target) { - loc = CRATE_ROOT.to_string() + ⌖ - } else if check_module_name(&target) { - loc = MODULE_ROOT.to_string() + ⌖ - } else { - loc = APP_ROOT.to_string() + ⌖ - } - let output_loc = matches.get_one::("save-path").unwrap().to_string(); - Ok(gen_config(is_default, features, format, loc, output_loc)) -} - -fn gen_config(is_default: bool, features: Vec::, format: GraphFormat, loc: String, output_loc: String) -> Config { - Config::build(is_default, features, format, loc, output_loc) -} - -pub fn check_crate_name(name: &String) -> bool { - let crates = fs::read_dir(CRATE_ROOT).unwrap(); - crates.into_iter().map(|p| p.unwrap().file_name()).any(|n| n.to_str().unwrap() == name) -} - -pub fn check_module_name(name: &String) -> bool { - let crates = fs::read_dir(MODULE_ROOT).unwrap(); - crates.into_iter().map(|p| p.unwrap().file_name()).any(|n| n.to_str().unwrap() == name) -} - -pub fn check_app_name(name: &String) -> bool { - Path::new(&(APP_ROOT.to_string() + name)).exists() -} - -pub fn check_lib_name(name: &String) -> bool { - Path::new(&(ULIB_ROOT.to_string() + name)).exists() -} - -pub fn is_arceos_crate(name: &String) -> bool { - check_crate_name(&name) || check_module_name(&name) || check_app_name(name) || check_lib_name(name) -} - -pub fn build_loc(name: &String) -> String { - if check_module_name(name) { - MODULE_ROOT.to_string() + name - } else { - CRATE_ROOT.to_string() + name - } -} diff --git a/tools/deptool/src/d2_generator.rs b/tools/deptool/src/d2_generator.rs deleted file mode 100644 index cec86669e..000000000 --- a/tools/deptool/src/d2_generator.rs +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use std::collections::HashMap; - -use crate::{parse_deps, cmd_parser::is_arceos_crate}; - -/// without further exploiting the feature of d2 graph, this is almost the same syntax with mermaid -/// except that d2 use " -> ", instead of "-->" -pub fn gen_d2_script(deps: &String, result: &mut String) { - let deps_parsed = parse_deps(&deps); - let dep_root = &deps_parsed[0]; - - let mut parsed_crates: Vec<&String> = Vec::new(); - let mut lastest_dep_map: HashMap = HashMap::new(); - let mut idx: usize = 1; - - lastest_dep_map.insert(0, &dep_root.1); - while idx < deps_parsed.len() { - let (level, name) = deps_parsed.get(idx).unwrap(); - if !is_arceos_crate(&name) { - idx += 1; - continue; - } - *result += &format!("{} -> {}\n", lastest_dep_map[&(level - 1)], name); - if parsed_crates.contains(&name) { - let mut skip_idx: usize = idx + 1; - if skip_idx >= deps_parsed.len() { - break; - } - while deps_parsed.get(skip_idx).unwrap().0 > *level { - idx += 1; - skip_idx += 1; - } - idx += 1; - } else { - parsed_crates.push(&name); - lastest_dep_map.insert(*level, name); - idx += 1; - } - } -} diff --git a/tools/deptool/src/lib.rs b/tools/deptool/src/lib.rs deleted file mode 100644 index 7adc5aad0..000000000 --- a/tools/deptool/src/lib.rs +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -mod cmd_parser; -mod cmd_builder; -mod mermaid_generator; -mod d2_generator; - -use std::process::Command; -use std::fs::File; -use std::io::Write; - -use cmd_builder::build_cargo_tree_cmd; -pub use cmd_parser::{parse_cmd, build_loc}; -use d2_generator::gen_d2_script; -use mermaid_generator::gen_mermaid_script; - -#[derive(Clone, Copy, Debug)] -pub enum GraphFormat { - Mermaid, - D2, -} - -#[derive(Debug)] -pub struct Config { - pub no_default: bool, - pub format: GraphFormat, - pub features: Vec::, - loc: String, - output_loc: String -} - -impl Config { - pub fn build(no_default: bool, features: Vec::, format: GraphFormat, loc: String, output_loc: String) -> Config { - Config { no_default, format, features, loc, output_loc } - } -} - -fn get_deps_by_crate_name(cfg: &Config) -> String { - let cmd_ct = build_cargo_tree_cmd(&cfg); - let cmds = ["-c", &cmd_ct]; - let output = if cfg!(target_os = "windows") { - Command::new("cmd") - .args(cmds) - .output() - .expect("failed to execute process") - } else { - Command::new("sh") - .args(cmds) - .output() - .expect("failed to execute process") - }; - - let deps = output.stdout; - String::from_utf8(deps).unwrap() -} - -fn parse_deps(deps: &String) -> Vec<(i32, String)> { - let mut rst = vec!(); - for line in deps.lines() { - let level_name = line.split_whitespace().next().unwrap(); - let level = level_name.get(0..1).unwrap().parse().unwrap(); - let name = level_name.get(1..).unwrap(); - rst.push((level, name.to_string())); - } - rst -} - -fn generate_mermaid(config: &Config) -> String { - let mut result = String::from(""); - let deps = get_deps_by_crate_name(config); - gen_mermaid_script(&deps, &mut result); - "graph TD;\n".to_string() + &result -} - -fn generate_d2(config: &Config) -> String { - let mut result = String::from(""); - let deps = get_deps_by_crate_name(config); - gen_d2_script(&deps, &mut result); - result -} - -fn generate_deps_graph(config: &Config) -> String { - match config.format { - GraphFormat::D2 => generate_d2(config), - _ => generate_mermaid(config) - } -} - -fn output_deps_graph(rst: &String) -> std::io::Result<()> { - let mut file = File::create("output.txt")?; - file.write_all(rst.as_bytes())?; - Ok(()) -} - -pub fn run(config: &Config) { - let rst = generate_deps_graph(config); - print!("{}", rst); - match output_deps_graph(&rst) { - Ok(()) => {}, - Err(error) => println!("Error during writing file {}, {}", config.output_loc, error) - } -} diff --git a/tools/deptool/src/main.rs b/tools/deptool/src/main.rs deleted file mode 100644 index 67ed5f243..000000000 --- a/tools/deptool/src/main.rs +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use deptool::{run, parse_cmd}; -use std::process; - -fn main() { - let config = parse_cmd().unwrap_or_else(|err| { - eprintln!("problem parsinig arguments: {err}"); - process::exit(1); - }); - - run(&config); -} diff --git a/tools/deptool/src/mermaid_generator.rs b/tools/deptool/src/mermaid_generator.rs deleted file mode 100644 index b569fda69..000000000 --- a/tools/deptool/src/mermaid_generator.rs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use std::collections::HashMap; - -use crate::{parse_deps, cmd_parser::is_arceos_crate}; - -pub fn gen_mermaid_script(deps: &String, result: &mut String) { - let deps_parsed = parse_deps(&deps); - let dep_root = &deps_parsed[0]; - - let mut parsed_crates: Vec<&String> = Vec::new(); - let mut lastest_dep_map: HashMap = HashMap::new(); - let mut idx: usize = 1; - - lastest_dep_map.insert(0, &dep_root.1); - while idx < deps_parsed.len() { - let (level, name) = deps_parsed.get(idx).unwrap(); - if !is_arceos_crate(&name) { - idx += 1; - continue; - } - *result += &format!("{}-->{}\n", lastest_dep_map[&(level - 1)], name); - if parsed_crates.contains(&name) { - let mut skip_idx: usize = idx + 1; - if skip_idx >= deps_parsed.len() { - break; - } - while deps_parsed.get(skip_idx).unwrap().0 > *level { - idx += 1; - skip_idx += 1; - } - idx += 1; - } else { - parsed_crates.push(&name); - lastest_dep_map.insert(*level, name); - idx += 1; - } - } -} diff --git a/tools/raspi4/common/docker.mk b/tools/raspi4/common/docker.mk deleted file mode 100644 index 61355768f..000000000 --- a/tools/raspi4/common/docker.mk +++ /dev/null @@ -1 +0,0 @@ -DOCKER_IMAGE := rustembedded/osdev-utils:2021.12 diff --git a/tools/raspi4/common/format.mk b/tools/raspi4/common/format.mk deleted file mode 100644 index e392304ad..000000000 --- a/tools/raspi4/common/format.mk +++ /dev/null @@ -1,12 +0,0 @@ -define color_header - @tput setaf 6 2> /dev/null || true - @printf '\n%s\n' $(1) - @tput sgr0 2> /dev/null || true -endef - -define color_progress_prefix - @tput setaf 2 2> /dev/null || true - @tput bold 2 2> /dev/null || true - @printf '%12s ' $(1) - @tput sgr0 2> /dev/null || true -endef diff --git a/tools/raspi4/common/operating_system.mk b/tools/raspi4/common/operating_system.mk deleted file mode 100644 index 90172f775..000000000 --- a/tools/raspi4/common/operating_system.mk +++ /dev/null @@ -1,9 +0,0 @@ -ifeq ($(shell uname -s),Linux) - DU_ARGUMENTS = --block-size=1024 --apparent-size -else ifeq ($(shell uname -s),Darwin) - DU_ARGUMENTS = -k -A -endif - -define disk_usage_KiB - @printf '%s KiB\n' `du $(DU_ARGUMENTS) $(1) | cut -f1` -endef diff --git a/tools/raspi4/common/serial/minipush.rb b/tools/raspi4/common/serial/minipush.rb deleted file mode 100755 index 262ce20a0..000000000 --- a/tools/raspi4/common/serial/minipush.rb +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# SPDX-License-Identifier: MIT OR Apache-2.0 -# -# Copyright (c) 2020-2022 Andre Richter - -require_relative 'miniterm' -require 'ruby-progressbar' -require_relative 'minipush/progressbar_patch' -require 'timeout' - -class ProtocolError < StandardError; end - -# The main class -class MiniPush < MiniTerm - def initialize(serial_name, payload_path) - super(serial_name) - - @name_short = 'MP' # override - @payload_path = payload_path - @payload_size = nil - @payload_data = nil - end - - private - - # The three characters signaling the request token form the consecutive sequence "\x03\x03\x03". - def wait_for_payload_request - puts "[#{@name_short}] 🔌 Please power the target now" - - # Timeout for the request token starts after the first sign of life was received. - received = @target_serial.readpartial(4096) - Timeout.timeout(10) do - count = 0 - - loop do - raise ProtocolError if received.nil? - - received.chars.each do |c| - if c == "\u{3}" - count += 1 - return true if count == 3 - else - # A normal character resets token counting. - count = 0 - - print c - end - end - - received = @target_serial.readpartial(4096) - end - end - end - - def load_payload - @payload_size = File.size(@payload_path) - @payload_data = File.binread(@payload_path) - end - - def send_size - @target_serial.print([@payload_size].pack('L<')) - raise ProtocolError if @target_serial.read(2) != 'OK' - end - - def send_payload - pb = ProgressBar.create( - total: @payload_size, - format: "[#{@name_short}] ⏩ Pushing %k KiB %b🦀%i %p%% %r KiB/s %a", - rate_scale: ->(rate) { rate / 1024 }, - length: 92, - output: $stdout - ) - - # Send in 512 byte chunks. - while pb.progress < pb.total - part = @payload_data.slice(pb.progress, 512) - pb.progress += @target_serial.write(part) - end - end - - # override - def handle_reconnect(_error) - connection_reset - - puts - puts "[#{@name_short}] ⚡ " \ - "#{'Connection or protocol Error: '.light_red}" \ - "#{'Remove power and USB serial. Reinsert serial first, then power'.light_red}" - sleep(1) while serial_connected? - end - - public - - # override - def run - open_serial - wait_for_payload_request - load_payload - send_size - send_payload - terminal - rescue ConnectionError, EOFError, Errno::EIO, ProtocolError, Timeout::Error => e - handle_reconnect(e) - retry - rescue StandardError => e - handle_unexpected(e) - ensure - connection_reset - puts - puts "[#{@name_short}] Bye 👋" - end -end - -##-------------------------------------------------------------------------------------------------- -## Execution starts here -##-------------------------------------------------------------------------------------------------- -if __FILE__ == $PROGRAM_NAME - puts - puts 'Minipush 1.0'.cyan - puts - - # CTRL + C handler. Only here to suppress Ruby's default exception print. - trap('INT') do - # The `ensure` block from `MiniPush::run` will run after exit, restoring console state. - exit - end - - MiniPush.new(ARGV[0], ARGV[1]).run -end diff --git a/tools/raspi4/common/serial/minipush/progressbar_patch.rb b/tools/raspi4/common/serial/minipush/progressbar_patch.rb deleted file mode 100644 index 1862a234c..000000000 --- a/tools/raspi4/common/serial/minipush/progressbar_patch.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -# SPDX-License-Identifier: MIT OR Apache-2.0 -# -# Copyright (c) 2020-2022 Andre Richter - -# Monkey-patch ruby-progressbar so that it supports reporting the progress in KiB instead of Byte. - -class ProgressBar - # Add kibi version of progress - class Progress - def progress_kibi - @progress / 1024 - end - end - - module Format - # Add new formatting option - class Molecule - MOLECULES_EXTENDED = MOLECULES.dup - MOLECULES_EXTENDED[:k] = %i[progressable progress_kibi] - - def initialize(letter) - self.key = letter - self.method_name = MOLECULES_EXTENDED.fetch(key.to_sym) - end - end - end -end diff --git a/tools/raspi4/common/serial/miniterm.rb b/tools/raspi4/common/serial/miniterm.rb deleted file mode 100755 index 038ed978f..000000000 --- a/tools/raspi4/common/serial/miniterm.rb +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# SPDX-License-Identifier: MIT OR Apache-2.0 -# -# Copyright (c) 2020-2022 Andre Richter - -require 'rubygems' -require 'bundler/setup' - -require 'colorize' -require 'io/console' -require 'serialport' - -SERIAL_BAUD = 921_600 - -class ConnectionError < StandardError; end - -# The main class -class MiniTerm - def initialize(serial_name) - @name_short = 'MT' - @target_serial_name = serial_name - @target_serial = nil - @host_console = IO.console - end - - private - - def serial_connected? - File.exist?(@target_serial_name) - end - - def wait_for_serial - return if serial_connected? - - puts "[#{@name_short}] ⏳ Waiting for #{@target_serial_name}" - loop do - sleep(1) - break if serial_connected? - end - end - - def open_serial - wait_for_serial - - @target_serial = SerialPort.new(@target_serial_name, SERIAL_BAUD, 8, 1, SerialPort::NONE) - - # Ensure all output is immediately flushed to the device. - @target_serial.sync = true - rescue Errno::EACCES => e - puts "[#{@name_short}] 🚫 #{e.message} - Maybe try with 'sudo'" - exit - else - puts "[#{@name_short}] ✅ Serial connected" - end - - def terminal - @host_console.raw! - - Thread.abort_on_exception = true - Thread.report_on_exception = false - - # Receive from target and print on host console. - target_to_host = Thread.new do - loop do - char = @target_serial.getc - - raise ConnectionError if char.nil? - - # Translate incoming newline to newline + carriage return. - @host_console.putc("\r") if char == "\n" - @host_console.putc(char) - end - end - - # Transmit host console input to target. - loop do - c = @host_console.getc - - # CTRL + C in raw mode was pressed. - if c == "\u{3}" - target_to_host.kill - break - end - - @target_serial.putc(c) - end - end - - def connection_reset - @target_serial&.close - @target_serial = nil - @host_console.cooked! - end - - # When the serial lost power or was removed during R/W operation. - def handle_reconnect(_error) - connection_reset - - puts - puts "[#{@name_short}] ⚡ #{'Connection Error: Reinsert the USB serial again'.light_red}" - end - - def handle_unexpected(error) - connection_reset - - puts - puts "[#{@name_short}] ⚡ #{"Unexpected Error: #{error.inspect}".light_red}" - end - - public - - def run - open_serial - terminal - rescue ConnectionError, EOFError, Errno::EIO => e - handle_reconnect(e) - retry - rescue StandardError => e - handle_unexpected(e) - ensure - connection_reset - puts - puts "[#{@name_short}] Bye 👋" - end -end - -##-------------------------------------------------------------------------------------------------- -## Execution starts here -##-------------------------------------------------------------------------------------------------- -if __FILE__ == $PROGRAM_NAME - puts - puts 'Miniterm 1.0'.cyan - puts - - # CTRL + C handler. Only here to suppress Ruby's default exception print. - trap('INT') do - # The `ensure` block from `MiniTerm::run` will run after exit, restoring console state. - exit - end - - MiniTerm.new(ARGV[0]).run -end diff --git a/ulib/axlibc/Cargo.toml b/ulib/axlibc/Cargo.toml deleted file mode 100644 index e52584de2..000000000 --- a/ulib/axlibc/Cargo.toml +++ /dev/null @@ -1,62 +0,0 @@ -[package] -name = "axlibc" -version = "0.1.0" -edition = "2021" -authors = [ - "Yuekai Jia ", - "yanjuguang ", - "wudashuai ", - "yfblock <321353225@qq.com>", - "scPointer ", - "Shiping Yuan ", -] -description = "ArceOS user program library for C apps" -license = "GPL-3.0-or-later OR Apache-2.0" -homepage = "https://github.com/rcore-os/arceos" -repository = "https://github.com/rcore-os/arceos/tree/main/ulib/axlibc" -documentation = "https://rcore-os.github.io/arceos/axlibc/index.html" - -[lib] -crate-type = ["staticlib"] - -[features] -default = [] - -# Multicore -smp = ["arceos_posix_api/smp"] - -# Floating point/SIMD -fp_simd = ["axfeat/fp_simd"] - -# Memory -alloc = ["arceos_posix_api/alloc"] -tls = ["alloc", "axfeat/tls"] - -# Multi-task -multitask = ["arceos_posix_api/multitask"] - -# File system -fs = ["arceos_posix_api/fs", "fd"] - -# Networking -net = ["arceos_posix_api/net", "fd"] - -# Signal -signal = ["arceos_posix_api/signal"] - -# Libc features -fd = [] -pipe = ["arceos_posix_api/pipe"] -select = ["arceos_posix_api/select"] -poll = ["arceos_posix_api/poll"] -epoll = ["arceos_posix_api/epoll"] -random-hw = [] - -[dependencies] -axfeat = { path = "../../api/axfeat" } -arceos_posix_api = { path = "../../api/arceos_posix_api" } -axio = { path = "../../crates/axio" } -axerrno = { path = "../../crates/axerrno" } - -[build-dependencies] -bindgen ={ version = "0.66" } diff --git a/ulib/axmusl/Cargo.toml b/ulib/axmusl/Cargo.toml deleted file mode 100644 index 12367fd67..000000000 --- a/ulib/axmusl/Cargo.toml +++ /dev/null @@ -1,55 +0,0 @@ -[package] -name = "axmusl" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["staticlib"] - -[features] -default = [] - -# Multicore -smp = ["arceos_posix_api/smp"] - -# Floating point/SIMD -fp_simd = ["axfeat/fp_simd"] - -# Memory -alloc = ["arceos_posix_api/alloc"] -tls = ["alloc", "axfeat/tls"] - -# Multi-task -multitask = ["arceos_posix_api/multitask"] - -# File system -fs = ["arceos_posix_api/fs", "fd"] - -# Networking -net = ["arceos_posix_api/net", "fd"] - -# Libc features -fd = ["arceos_posix_api/fd"] -pipe = ["arceos_posix_api/pipe"] -select = ["arceos_posix_api/select"] -epoll = ["arceos_posix_api/epoll"] -poll = ["arceos_posix_api/poll"] -rtc = ["axfeat/rtc"] - -musl = ["axfeat/musl", "arceos_posix_api/musl", "tls"] - -# Interrupts -irq = ["arceos_posix_api/irq", "axfeat/irq"] - -sched_rr = ["irq", "axfeat/sched_rr"] - -[dependencies] -axfeat = { path = "../../api/axfeat" } -arceos_posix_api = { path = "../../api/arceos_posix_api" } -num_enum = { version = "0.5.11", default-features = false } -axhal = { path = "../../modules/axhal" } -axlog = { path = "../../modules/axlog" } -kernel_guard = { path = "../../crates/kernel_guard" } -crate_interface = { path = "../../crates/crate_interface" } diff --git a/ulib/axmusl/src/lib.rs b/ulib/axmusl/src/lib.rs deleted file mode 100644 index fece1560e..000000000 --- a/ulib/axmusl/src/lib.rs +++ /dev/null @@ -1,32 +0,0 @@ -//! Syscall dispatch crate -//! -//! Dispatch musl syscall instruction to Rukos posix-api -//! -//! Only support AARCH64 right now - -#![cfg_attr(all(not(test), not(doc)), no_std)] - -#[macro_use] -extern crate axlog; - -#[cfg(feature = "alloc")] -extern crate alloc; - -mod syscall; - -#[cfg(feature = "net")] -mod net; -mod trap; - -use core::ffi::c_int; - -/// parse error number for `getaddr` and `freeaddr` -/// -/// TODO: remove this -pub fn e(ret: c_int) -> c_int { - if ret < 0 { - -1 - } else { - ret as _ - } -} diff --git a/ulib/axmusl/src/net.rs b/ulib/axmusl/src/net.rs deleted file mode 100644 index ef9486d56..000000000 --- a/ulib/axmusl/src/net.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. - * 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. - */ - -use crate::e; -use arceos_posix_api::ctypes; -use arceos_posix_api::{sys_freeaddrinfo, sys_getaddrinfo}; -use core::ffi::{c_char, c_int}; - -/// Query addresses for a domain name. -/// -/// Return address number if success. -#[no_mangle] -pub unsafe extern "C" fn getaddrinfo( - nodename: *const c_char, - servname: *const c_char, - hints: *const ctypes::addrinfo, - res: *mut *mut ctypes::addrinfo, -) -> c_int { - let ret = e(sys_getaddrinfo(nodename, servname, hints, res)); - match ret { - r if r < 0 => ctypes::EAI_FAIL, - 0 => ctypes::EAI_NONAME, - _ => 0, - } -} - -/// Free queried `addrinfo` struct -#[no_mangle] -pub unsafe extern "C" fn freeaddrinfo(res: *mut ctypes::addrinfo) { - sys_freeaddrinfo(res); -} diff --git a/ulib/axstd/Cargo.toml b/ulib/axstd/Cargo.toml index d1a4498cf..8f57a458c 100644 --- a/ulib/axstd/Cargo.toml +++ b/ulib/axstd/Cargo.toml @@ -20,62 +20,62 @@ documentation = "https://rcore-os.github.io/arceos/axstd/index.html" default = [] # Multicore -smp = ["axfeat/smp", "spinlock/smp"] +smp = ["ruxfeat/smp", "spinlock/smp"] # Floating point/SIMD -fp_simd = ["axfeat/fp_simd"] +fp_simd = ["ruxfeat/fp_simd"] # Interrupts -irq = ["arceos_api/irq", "axfeat/irq"] +irq = ["arceos_api/irq", "ruxfeat/irq"] # real time clock -rtc = ["arceos_api/rtc", "axfeat/rtc"] +rtc = ["arceos_api/rtc", "ruxfeat/rtc"] # Memory -alloc = ["arceos_api/alloc", "axfeat/alloc", "axio/alloc"] -alloc-tlsf = ["axfeat/alloc-tlsf"] -alloc-slab = ["axfeat/alloc-slab"] -alloc-buddy = ["axfeat/alloc-buddy"] -paging = ["axfeat/paging"] -tls = ["axfeat/tls"] +alloc = ["arceos_api/alloc", "ruxfeat/alloc", "axio/alloc"] +alloc-tlsf = ["ruxfeat/alloc-tlsf"] +alloc-slab = ["ruxfeat/alloc-slab"] +alloc-buddy = ["ruxfeat/alloc-buddy"] +paging = ["ruxfeat/paging"] +tls = ["ruxfeat/tls"] # Multi-threading and scheduler -multitask = ["arceos_api/multitask", "axfeat/multitask"] -sched_fifo = ["axfeat/sched_fifo"] -sched_rr = ["axfeat/sched_rr"] -sched_cfs = ["axfeat/sched_cfs"] +multitask = ["arceos_api/multitask", "ruxfeat/multitask"] +sched_fifo = ["ruxfeat/sched_fifo"] +sched_rr = ["ruxfeat/sched_rr"] +sched_cfs = ["ruxfeat/sched_cfs"] # File system -fs = ["arceos_api/fs", "axfeat/fs"] -myfs = ["arceos_api/myfs", "axfeat/myfs"] -blkfs = ["axfeat/blkfs"] -virtio-9p = ["axfeat/virtio-9p"] -net-9p = ["axfeat/net-9p"] +fs = ["arceos_api/fs", "ruxfeat/fs"] +myfs = ["arceos_api/myfs", "ruxfeat/myfs"] +blkfs = ["ruxfeat/blkfs"] +virtio-9p = ["ruxfeat/virtio-9p"] +net-9p = ["ruxfeat/net-9p"] # Networking -net = ["arceos_api/net", "axfeat/net"] +net = ["arceos_api/net", "ruxfeat/net"] dns = [] # Display -display = ["arceos_api/display", "axfeat/display"] +display = ["arceos_api/display", "ruxfeat/display"] # Device drivers -bus-mmio = ["axfeat/bus-mmio"] -bus-pci = ["axfeat/bus-pci"] -driver-ramdisk = ["axfeat/driver-ramdisk"] -driver-ixgbe = ["axfeat/driver-ixgbe"] -driver-bcm2835-sdhci = ["axfeat/driver-bcm2835-sdhci"] +bus-mmio = ["ruxfeat/bus-mmio"] +bus-pci = ["ruxfeat/bus-pci"] +driver-ramdisk = ["ruxfeat/driver-ramdisk"] +driver-ixgbe = ["ruxfeat/driver-ixgbe"] +driver-bcm2835-sdhci = ["ruxfeat/driver-bcm2835-sdhci"] # Logging -log-level-off = ["axfeat/log-level-off"] -log-level-error = ["axfeat/log-level-error"] -log-level-warn = ["axfeat/log-level-warn"] -log-level-info = ["axfeat/log-level-info"] -log-level-debug = ["axfeat/log-level-debug"] -log-level-trace = ["axfeat/log-level-trace"] +log-level-off = ["ruxfeat/log-level-off"] +log-level-error = ["ruxfeat/log-level-error"] +log-level-warn = ["ruxfeat/log-level-warn"] +log-level-info = ["ruxfeat/log-level-info"] +log-level-debug = ["ruxfeat/log-level-debug"] +log-level-trace = ["ruxfeat/log-level-trace"] [dependencies] -axfeat = { path = "../../api/axfeat" } +ruxfeat = { path = "../../api/ruxfeat" } arceos_api = { path = "../../api/arceos_api" } axio = { path = "../../crates/axio" } axerrno = { path = "../../crates/axerrno" } diff --git a/ulib/axstd/src/env.rs b/ulib/axstd/src/env.rs index 97411ac71..ddd9da94e 100644 --- a/ulib/axstd/src/env.rs +++ b/ulib/axstd/src/env.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/fs/dir.rs b/ulib/axstd/src/fs/dir.rs index 99532acd1..271010fd8 100644 --- a/ulib/axstd/src/fs/dir.rs +++ b/ulib/axstd/src/fs/dir.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/fs/file.rs b/ulib/axstd/src/fs/file.rs index cdd697a87..e29832da9 100644 --- a/ulib/axstd/src/fs/file.rs +++ b/ulib/axstd/src/fs/file.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/fs/mod.rs b/ulib/axstd/src/fs/mod.rs index b5a9be7d4..b3f8fcad5 100644 --- a/ulib/axstd/src/fs/mod.rs +++ b/ulib/axstd/src/fs/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/io/mod.rs b/ulib/axstd/src/io/mod.rs index 411ae5025..201d5b067 100644 --- a/ulib/axstd/src/io/mod.rs +++ b/ulib/axstd/src/io/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/io/stdio.rs b/ulib/axstd/src/io/stdio.rs index 625d5dc48..51113beef 100644 --- a/ulib/axstd/src/io/stdio.rs +++ b/ulib/axstd/src/io/stdio.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/lib.rs b/ulib/axstd/src/lib.rs index bf0021277..1d24dc793 100644 --- a/ulib/axstd/src/lib.rs +++ b/ulib/axstd/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -13,9 +13,9 @@ //! to rust [std], but calling the functions directly in ArceOS modules, instead //! of using libc and system calls. //! -//! These features are exactly the same as those in [axfeat], they are used to -//! provide users with the selection of features in axfeat, without import -//! [axfeat] additionally: +//! These features are exactly the same as those in [ruxfeat], they are used to +//! provide users with the selection of features in ruxfeat, without import +//! [ruxfeat] additionally: //! //! ## Cargo Features //! diff --git a/ulib/axstd/src/macros.rs b/ulib/axstd/src/macros.rs index 02cd3d09a..6eaa8292e 100644 --- a/ulib/axstd/src/macros.rs +++ b/ulib/axstd/src/macros.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/net/mod.rs b/ulib/axstd/src/net/mod.rs index 9d519f8af..41d024aef 100644 --- a/ulib/axstd/src/net/mod.rs +++ b/ulib/axstd/src/net/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/net/socket_addr.rs b/ulib/axstd/src/net/socket_addr.rs index 1193203cf..829c4e12a 100644 --- a/ulib/axstd/src/net/socket_addr.rs +++ b/ulib/axstd/src/net/socket_addr.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/net/tcp.rs b/ulib/axstd/src/net/tcp.rs index 16ce3d98f..a1663f05b 100644 --- a/ulib/axstd/src/net/tcp.rs +++ b/ulib/axstd/src/net/tcp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/net/udp.rs b/ulib/axstd/src/net/udp.rs index 5c2bc160e..6cc348f90 100644 --- a/ulib/axstd/src/net/udp.rs +++ b/ulib/axstd/src/net/udp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/os.rs b/ulib/axstd/src/os.rs index 88a47fe3c..a2ac2eb74 100644 --- a/ulib/axstd/src/os.rs +++ b/ulib/axstd/src/os.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/process.rs b/ulib/axstd/src/process.rs index aa6433224..f7c9d9f10 100644 --- a/ulib/axstd/src/process.rs +++ b/ulib/axstd/src/process.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/sync/mod.rs b/ulib/axstd/src/sync/mod.rs index 06882e232..9c62b1039 100644 --- a/ulib/axstd/src/sync/mod.rs +++ b/ulib/axstd/src/sync/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/sync/mutex.rs b/ulib/axstd/src/sync/mutex.rs index 4d5f14f21..2cfc701d1 100644 --- a/ulib/axstd/src/sync/mutex.rs +++ b/ulib/axstd/src/sync/mutex.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/thread/mod.rs b/ulib/axstd/src/thread/mod.rs index 631517e18..51353a022 100644 --- a/ulib/axstd/src/thread/mod.rs +++ b/ulib/axstd/src/thread/mod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/thread/multi.rs b/ulib/axstd/src/thread/multi.rs index 0cfd22eb5..6da1b472a 100644 --- a/ulib/axstd/src/thread/multi.rs +++ b/ulib/axstd/src/thread/multi.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axstd/src/time.rs b/ulib/axstd/src/time.rs index f1153b268..50ab21c4a 100644 --- a/ulib/axstd/src/time.rs +++ b/ulib/axstd/src/time.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/.gitignore b/ulib/ruxlibc/.gitignore similarity index 100% rename from ulib/axlibc/.gitignore rename to ulib/ruxlibc/.gitignore diff --git a/ulib/ruxlibc/Cargo.toml b/ulib/ruxlibc/Cargo.toml new file mode 100644 index 000000000..e32edb2cd --- /dev/null +++ b/ulib/ruxlibc/Cargo.toml @@ -0,0 +1,61 @@ +[package] +name = "ruxlibc" +version = "0.1.0" +edition = "2021" +authors = [ + "Yuekai Jia ", + "yanjuguang ", + "wudashuai ", + "yfblock <321353225@qq.com>", + "scPointer ", + "Shiping Yuan ", +] +description = "Ruxos user program library for C apps" +license = "GPL-3.0-or-later OR Apache-2.0" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/ulib/ruxlibc" + +[lib] +crate-type = ["staticlib"] + +[features] +default = [] + +# Multicore +smp = ["ruxos_posix_api/smp"] + +# Floating point/SIMD +fp_simd = ["ruxfeat/fp_simd"] + +# Memory +alloc = ["ruxos_posix_api/alloc"] +tls = ["alloc", "ruxfeat/tls"] + +# Multi-task +multitask = ["ruxos_posix_api/multitask"] + +# File system +fs = ["ruxos_posix_api/fs", "fd"] + +# Networking +net = ["ruxos_posix_api/net", "fd"] + +# Signal +signal = ["ruxos_posix_api/signal"] + +# Libc features +fd = [] +pipe = ["ruxos_posix_api/pipe"] +select = ["ruxos_posix_api/select"] +poll = ["ruxos_posix_api/poll"] +epoll = ["ruxos_posix_api/epoll"] +random-hw = [] + +[dependencies] +ruxfeat = { path = "../../api/ruxfeat" } +ruxos_posix_api = { path = "../../api/ruxos_posix_api" } +axio = { path = "../../crates/axio" } +axerrno = { path = "../../crates/axerrno" } + +[build-dependencies] +bindgen ={ version = "0.66" } diff --git a/ulib/axlibc/build.rs b/ulib/ruxlibc/build.rs similarity index 96% rename from ulib/axlibc/build.rs rename to ulib/ruxlibc/build.rs index e91bb6264..9755e7ee2 100644 --- a/ulib/axlibc/build.rs +++ b/ulib/ruxlibc/build.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/assert.c b/ulib/ruxlibc/c/assert.c similarity index 94% rename from ulib/axlibc/c/assert.c rename to ulib/ruxlibc/c/assert.c index 76499459e..4d9060c17 100644 --- a/ulib/axlibc/c/assert.c +++ b/ulib/ruxlibc/c/assert.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/ctype.c b/ulib/ruxlibc/c/ctype.c similarity index 94% rename from ulib/axlibc/c/ctype.c rename to ulib/ruxlibc/c/ctype.c index d7e7e821a..3ec36db30 100644 --- a/ulib/axlibc/c/ctype.c +++ b/ulib/ruxlibc/c/ctype.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/dirent.c b/ulib/ruxlibc/c/dirent.c similarity index 95% rename from ulib/axlibc/c/dirent.c rename to ulib/ruxlibc/c/dirent.c index a7df1473a..da9fc05e8 100644 --- a/ulib/axlibc/c/dirent.c +++ b/ulib/ruxlibc/c/dirent.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_FS +#ifdef RUX_CONFIG_FS #include #include @@ -104,4 +104,4 @@ void rewinddir(DIR *dir) // UNLOCK(dir->lock); } -#endif // AX_CONFIG_FS +#endif // RUX_CONFIG_FS diff --git a/ulib/axlibc/c/dlfcn.c b/ulib/ruxlibc/c/dlfcn.c similarity index 95% rename from ulib/axlibc/c/dlfcn.c rename to ulib/ruxlibc/c/dlfcn.c index f8518f915..5fc088d02 100644 --- a/ulib/axlibc/c/dlfcn.c +++ b/ulib/ruxlibc/c/dlfcn.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/fcntl.c b/ulib/ruxlibc/c/fcntl.c similarity index 86% rename from ulib/axlibc/c/fcntl.c rename to ulib/ruxlibc/c/fcntl.c index 61f8e979b..1c2aeedad 100644 --- a/ulib/axlibc/c/fcntl.c +++ b/ulib/ruxlibc/c/fcntl.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,7 +11,7 @@ #include #include -#ifdef AX_CONFIG_FD +#ifdef RUX_CONFIG_FD // TODO: remove this function in future work int ax_fcntl(int fd, int cmd, size_t arg); @@ -27,9 +27,9 @@ int fcntl(int fd, int cmd, ... /* arg */) return ax_fcntl(fd, cmd, arg); } -#endif // AX_CONFIG_FD +#endif // RUX_CONFIG_FD -#ifdef AX_CONFIG_FS +#ifdef RUX_CONFIG_FS // TODO: remove this function in future work int ax_open(const char *filename, int flags, mode_t mode); @@ -62,4 +62,10 @@ int sync_file_range(int fd, off_t pos, off_t len, unsigned flags) return 0; } -#endif // AX_CONFIG_FS +int openat(int dirfd, const char *pathname, int flags, ...) +{ + unimplemented(); + return 0; +} + +#endif // RUX_CONFIG_FS diff --git a/ulib/axlibc/c/flock.c b/ulib/ruxlibc/c/flock.c similarity index 93% rename from ulib/axlibc/c/flock.c rename to ulib/ruxlibc/c/flock.c index 631a3935f..36859d25c 100644 --- a/ulib/axlibc/c/flock.c +++ b/ulib/ruxlibc/c/flock.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/fnmatch.c b/ulib/ruxlibc/c/fnmatch.c similarity index 99% rename from ulib/axlibc/c/fnmatch.c rename to ulib/ruxlibc/c/fnmatch.c index dd6ce3e26..7e88e5970 100644 --- a/ulib/axlibc/c/fnmatch.c +++ b/ulib/ruxlibc/c/fnmatch.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/glob.c b/ulib/ruxlibc/c/glob.c similarity index 99% rename from ulib/axlibc/c/glob.c rename to ulib/ruxlibc/c/glob.c index 28b0923ab..6b6137424 100644 --- a/ulib/axlibc/c/glob.c +++ b/ulib/ruxlibc/c/glob.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_FS +#ifdef RUX_CONFIG_FS #include #include @@ -335,4 +335,4 @@ void globfree(glob_t *g) g->gl_pathv = NULL; } -#endif // AX_CONFIG_FS +#endif // RUX_CONFIG_FS diff --git a/ulib/ruxlibc/c/grp.c b/ulib/ruxlibc/c/grp.c new file mode 100644 index 000000000..eb858607c --- /dev/null +++ b/ulib/ruxlibc/c/grp.c @@ -0,0 +1,46 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include +#include +#include +#include +#include + +/* Group members */ +static char *g_members__[] = { RUX_DEFAULT_USER, NULL }; + +/* Default group */ +static struct group g__ = { + .gr_name = RUX_DEFAULT_GROUP, + .gr_passwd = RUX_DEFAULT_PASS, + .gr_gid = RUX_DEFAULT_GID, + .gr_mem = g_members__, +}; + +// TODO +int initgroups(const char *user, gid_t group) +{ + unimplemented(); + return 0; +} + +struct group *getgrnam(const char *name) +{ + struct group *res; + + if (name && !strcmp(name, g__.gr_name)) + res = &g__; + else { + res = NULL; + errno = ENOENT; + } + + return res; +} diff --git a/ulib/ruxlibc/c/ioctl.c b/ulib/ruxlibc/c/ioctl.c new file mode 100644 index 000000000..578622a46 --- /dev/null +++ b/ulib/ruxlibc/c/ioctl.c @@ -0,0 +1,27 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include +#include +#include + +int rux_ioctl(int fd, int cmd, size_t arg); + +// TODO +int ioctl(int fd, int request, ...) +{ + unsigned long arg; + va_list ap; + va_start(ap, request); + arg = va_arg(ap, unsigned long); + va_end(ap); + + return rux_ioctl(fd, request, arg); +} diff --git a/ulib/axlibc/c/libgen.c b/ulib/ruxlibc/c/libgen.c similarity index 96% rename from ulib/axlibc/c/libgen.c rename to ulib/ruxlibc/c/libgen.c index acfbca4cb..d0ffcdced 100644 --- a/ulib/axlibc/c/libgen.c +++ b/ulib/ruxlibc/c/libgen.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/libm.c b/ulib/ruxlibc/c/libm.c similarity index 87% rename from ulib/axlibc/c/libm.c rename to ulib/ruxlibc/c/libm.c index 7e98b71e3..26269c3ed 100644 --- a/ulib/axlibc/c/libm.c +++ b/ulib/ruxlibc/c/libm.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD #include @@ -23,4 +23,4 @@ double __math_invalid(double x) return (x - x) / (x - x); } -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD diff --git a/ulib/axlibc/c/libm.h b/ulib/ruxlibc/c/libm.h similarity index 98% rename from ulib/axlibc/c/libm.h rename to ulib/ruxlibc/c/libm.h index 1df1a0e5a..51046ba8c 100644 --- a/ulib/axlibc/c/libm.h +++ b/ulib/ruxlibc/c/libm.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,7 +10,7 @@ #ifndef _LIBM_H #define _LIBM_H -#if AX_CONFIG_FP_SIMD +#if RUX_CONFIG_FP_SIMD #include #include @@ -237,6 +237,6 @@ double __math_invalid(double); long double __math_invalidl(long double); #endif -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD #endif // _LIBM_H diff --git a/ulib/axlibc/c/locale.c b/ulib/ruxlibc/c/locale.c similarity index 97% rename from ulib/axlibc/c/locale.c rename to ulib/ruxlibc/c/locale.c index 8def82e7c..5cbc619ea 100644 --- a/ulib/axlibc/c/locale.c +++ b/ulib/ruxlibc/c/locale.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/log.c b/ulib/ruxlibc/c/log.c similarity index 99% rename from ulib/axlibc/c/log.c rename to ulib/ruxlibc/c/log.c index 61492c035..2dc35dad5 100644 --- a/ulib/axlibc/c/log.c +++ b/ulib/ruxlibc/c/log.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD #include #include @@ -401,4 +401,4 @@ double log(double x) return eval_as_double(y); } -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD diff --git a/ulib/axlibc/c/math.c b/ulib/ruxlibc/c/math.c similarity index 99% rename from ulib/axlibc/c/math.c rename to ulib/ruxlibc/c/math.c index 3364a7348..1f5266dfd 100644 --- a/ulib/axlibc/c/math.c +++ b/ulib/ruxlibc/c/math.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD #include #include @@ -577,4 +577,4 @@ long double fabsl(long double x) } #endif -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD diff --git a/ulib/axlibc/c/mmap.c b/ulib/ruxlibc/c/mmap.c similarity index 68% rename from ulib/axlibc/c/mmap.c rename to ulib/ruxlibc/c/mmap.c index a9786dba9..c106e2a62 100644 --- a/ulib/axlibc/c/mmap.c +++ b/ulib/ruxlibc/c/mmap.c @@ -1,27 +1,34 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 #include +#include #include // TODO: void *mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) { - unimplemented(); - return MAP_FAILED; + if (fildes != -1) { + unimplemented(); + return MAP_FAILED; + } + return malloc(len); } // TODO: int munmap(void *addr, size_t length) { - unimplemented(); + if (addr == NULL) + return 0; + free(addr); return 0; } diff --git a/ulib/axlibc/c/network.c b/ulib/ruxlibc/c/network.c similarity index 94% rename from ulib/axlibc/c/network.c rename to ulib/ruxlibc/c/network.c index 8f3192101..0cd8c1bd2 100644 --- a/ulib/axlibc/c/network.c +++ b/ulib/ruxlibc/c/network.c @@ -1,13 +1,14 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ -#ifdef AX_CONFIG_NET +#ifdef RUX_CONFIG_NET #include #include @@ -232,4 +233,11 @@ const char *inet_ntop(int af, const void *__restrict a0, char *__restrict s, soc return 0; } -#endif // AX_CONFIG_NET +// TODO +struct hostent *gethostbyname(const char *name) +{ + unimplemented(); + return 0; +} + +#endif // RUX_CONFIG_NET diff --git a/ulib/ruxlibc/c/nscd_query.c b/ulib/ruxlibc/c/nscd_query.c new file mode 100644 index 000000000..8e7f85aaf --- /dev/null +++ b/ulib/ruxlibc/c/nscd_query.c @@ -0,0 +1,103 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include "nscd.h" +#include +#include +#include +#include +#include +#include +#include +#include + +static const struct { + short sun_family; + char sun_path[21]; +} addr = {AF_UNIX, "/var/run/nscd/socket"}; + +FILE *__nscd_query(int32_t req, const char *key, int32_t *buf, size_t len, int *swap) +{ + size_t i; + int fd; + FILE *f = 0; + int32_t req_buf[REQ_LEN] = {NSCDVERSION, req, strnlen(key, LOGIN_NAME_MAX) + 1}; + struct msghdr msg = { + .msg_iov = (struct iovec[]){{&req_buf, sizeof(req_buf)}, {(char *)key, strlen(key) + 1}}, + .msg_iovlen = 2}; + int errno_save = errno; + + *swap = 0; +retry: + memset(buf, 0, len); + buf[0] = NSCDVERSION; + + fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); + if (fd < 0) { + if (errno == EAFNOSUPPORT) { + f = fopen("/dev/null", "re"); + if (f) + errno = errno_save; + return f; + } + return 0; + } + + if (!(f = fdopen(fd, "r"))) { + close(fd); + return 0; + } + + if (req_buf[2] > LOGIN_NAME_MAX) + return f; + + if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { + if (errno == EACCES || errno == ECONNREFUSED || errno == ENOENT) { + errno = errno_save; + return f; + } + goto error; + } + + if (sendmsg(fd, &msg, MSG_NOSIGNAL) < 0) + goto error; + + if (!fread(buf, len, 1, f)) { + if (ferror(f)) + goto error; + if (!*swap) { + fclose(f); + for (i = 0; i < sizeof(req_buf) / sizeof(req_buf[0]); i++) { + req_buf[i] = bswap_32(req_buf[i]); + } + *swap = 1; + goto retry; + } else { + errno = EIO; + goto error; + } + } + + if (*swap) { + for (i = 0; i < len / sizeof(buf[0]); i++) { + buf[i] = bswap_32(buf[i]); + } + } + + if (buf[0] != NSCDVERSION) { + errno = EIO; + goto error; + } + + return f; +error: + fclose(f); + return 0; +} diff --git a/ulib/axlibc/c/pow.c b/ulib/ruxlibc/c/pow.c similarity index 99% rename from ulib/axlibc/c/pow.c rename to ulib/ruxlibc/c/pow.c index aa4ccc158..7e5da7055 100644 --- a/ulib/axlibc/c/pow.c +++ b/ulib/ruxlibc/c/pow.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#if defined(AX_CONFIG_FP_SIMD) +#if defined(RUX_CONFIG_FP_SIMD) #include #include diff --git a/ulib/ruxlibc/c/prctl.c b/ulib/ruxlibc/c/prctl.c new file mode 100644 index 000000000..7f0f1ee2c --- /dev/null +++ b/ulib/ruxlibc/c/prctl.c @@ -0,0 +1,19 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include +#include + +// TODO +int prctl(int option, ...) +{ + unimplemented(); + return 0; +} diff --git a/ulib/axlibc/c/printf.c b/ulib/ruxlibc/c/printf.c similarity index 99% rename from ulib/axlibc/c/printf.c rename to ulib/ruxlibc/c/printf.c index f5b91d77d..128cfdb66 100644 --- a/ulib/axlibc/c/printf.c +++ b/ulib/ruxlibc/c/printf.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/printf.h b/ulib/ruxlibc/c/printf.h similarity index 99% rename from ulib/axlibc/c/printf.h rename to ulib/ruxlibc/c/printf.h index 4ee461703..45a0750b0 100644 --- a/ulib/axlibc/c/printf.h +++ b/ulib/ruxlibc/c/printf.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/printf_config.h b/ulib/ruxlibc/c/printf_config.h similarity index 87% rename from ulib/axlibc/c/printf_config.h rename to ulib/ruxlibc/c/printf_config.h index 64466ea4f..2086f9276 100644 --- a/ulib/axlibc/c/printf_config.h +++ b/ulib/ruxlibc/c/printf_config.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,12 +12,12 @@ #define PRINTF_ALIAS_STANDARD_FUNCTION_NAMES 1 -#ifndef AX_CONFIG_FP_SIMD +#ifndef RUX_CONFIG_FP_SIMD #define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 0 #define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 0 -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD #endif // PRINTF_CONFIG_H diff --git a/ulib/axlibc/c/pthread.c b/ulib/ruxlibc/c/pthread.c similarity index 94% rename from ulib/axlibc/c/pthread.c rename to ulib/ruxlibc/c/pthread.c index 8a4ec354a..363f02d99 100644 --- a/ulib/axlibc/c/pthread.c +++ b/ulib/ruxlibc/c/pthread.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_MULTITASK +#ifdef RUX_CONFIG_MULTITASK #include #include @@ -77,4 +77,4 @@ int pthread_attr_setstacksize(pthread_attr_t *a, size_t size) return 0; } -#endif // AX_CONFIG_MULTITASK +#endif // RUX_CONFIG_MULTITASK diff --git a/ulib/ruxlibc/c/pwd.c b/ulib/ruxlibc/c/pwd.c new file mode 100644 index 000000000..0b0df0e1a --- /dev/null +++ b/ulib/ruxlibc/c/pwd.c @@ -0,0 +1,52 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include +#include +#include +#include +#include +#include + +static struct passwd pw__ = { + .pw_name = RUX_DEFAULT_USER, + .pw_passwd = RUX_DEFAULT_PASS, + .pw_uid = RUX_DEFAULT_UID, + .pw_gid = RUX_DEFAULT_GID, + .pw_gecos = RUX_DEFAULT_USER, + .pw_dir = "/", + .pw_shell = "", +}; + +int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t size, struct passwd **res) +{ + unimplemented(); + return 0; +} + +int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res) +{ + unimplemented(); + return 0; +} + +struct passwd *getpwnam(const char *name) +{ + struct passwd *pwd; + + if (name && !strcmp(name, pw__.pw_name)) + pwd = &pw__; + else { + pwd = NULL; + errno = ENOENT; + } + + return pwd; +} diff --git a/ulib/ruxlibc/c/resource.c b/ulib/ruxlibc/c/resource.c new file mode 100644 index 000000000..a50b640e2 --- /dev/null +++ b/ulib/ruxlibc/c/resource.c @@ -0,0 +1,27 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include +#include +#include + +// TODO +int getrusage(int __who, struct rusage *__usage) +{ + unimplemented(); + return 0; +} + +int setpriority(int which, id_t who, int prio) +{ + unimplemented(); + return 0; +} + diff --git a/ulib/axlibc/c/sched.c b/ulib/ruxlibc/c/sched.c similarity index 86% rename from ulib/axlibc/c/sched.c rename to ulib/ruxlibc/c/sched.c index 7910af645..ad24fa270 100644 --- a/ulib/axlibc/c/sched.c +++ b/ulib/ruxlibc/c/sched.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -16,3 +16,9 @@ int sched_setaffinity(pid_t __pid, size_t __cpusetsize, const cpu_set_t *__cpuse unimplemented(); return 0; } + +int sched_yield(void) +{ + unimplemented(); + return 0; +} diff --git a/ulib/axlibc/c/select.c b/ulib/ruxlibc/c/select.c similarity index 90% rename from ulib/axlibc/c/select.c rename to ulib/ruxlibc/c/select.c index b8103434e..555b21739 100644 --- a/ulib/axlibc/c/select.c +++ b/ulib/ruxlibc/c/select.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_SELECT +#ifdef RUX_CONFIG_SELECT #include #include @@ -23,4 +23,4 @@ int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restric return 0; } -#endif // AX_CONFIG_SELECT +#endif // RUX_CONFIG_SELECT diff --git a/ulib/axlibc/c/pwd.c b/ulib/ruxlibc/c/semaphore.c similarity index 65% rename from ulib/axlibc/c/pwd.c rename to ulib/ruxlibc/c/semaphore.c index 3beb91cb3..970ea656a 100644 --- a/ulib/axlibc/c/pwd.c +++ b/ulib/ruxlibc/c/semaphore.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,16 +7,32 @@ * See the Mulan PSL v2 for more details. */ -#include #include +#include -int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t size, struct passwd **res) +// TODO +int sem_destroy(sem_t *sem) { unimplemented(); return 0; } -int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res) +// TODO +int sem_init(sem_t *sem, int pshared, unsigned int value) +{ + unimplemented(); + return 0; +} + +// TODO +int sem_post(sem_t *sem) +{ + unimplemented(); + return 0; +} + +// TODO +int sem_wait(sem_t *sem) { unimplemented(); return 0; diff --git a/ulib/axlibc/c/resource.c b/ulib/ruxlibc/c/sendfile.c similarity index 78% rename from ulib/axlibc/c/resource.c rename to ulib/ruxlibc/c/sendfile.c index c008a7200..1a7f1f2ed 100644 --- a/ulib/axlibc/c/resource.c +++ b/ulib/ruxlibc/c/sendfile.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,13 +7,10 @@ * See the Mulan PSL v2 for more details. */ -#include #include -#include +#include -// TODO -int getrusage(int __who, struct rusage *__usage) -{ +ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count){ unimplemented(); return 0; } diff --git a/ulib/axlibc/c/signal.c b/ulib/ruxlibc/c/signal.c similarity index 79% rename from ulib/axlibc/c/signal.c rename to ulib/ruxlibc/c/signal.c index 961ad99f8..6c94a5da5 100644 --- a/ulib/axlibc/c/signal.c +++ b/ulib/ruxlibc/c/signal.c @@ -1,10 +1,11 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -76,7 +77,21 @@ int pthread_sigmask(int __how, const sigset_t *restrict __newmask, sigset_t *res return 0; } -#ifdef AX_CONFIG_MULTITASK +// TODO +int sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict oldset) +{ + unimplemented(); + return 0; +} + +// TODO +int sigsuspend(const sigset_t *mask) +{ + unimplemented(); + return 0; +} + +#ifdef RUX_CONFIG_MULTITASK // TODO int pthread_kill(pthread_t t, int sig) { diff --git a/ulib/axlibc/c/socket.c b/ulib/ruxlibc/c/socket.c similarity index 88% rename from ulib/axlibc/c/socket.c rename to ulib/ruxlibc/c/socket.c index b2b4d10e1..9b60da7d3 100644 --- a/ulib/axlibc/c/socket.c +++ b/ulib/ruxlibc/c/socket.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -#ifdef AX_CONFIG_NET +#ifdef RUX_CONFIG_NET #include #include @@ -77,4 +77,18 @@ ssize_t sendmsg(int fd, const struct msghdr *msg, int flags) return ax_sendmsg(fd, msg, flags); } -#endif // AX_CONFIG_NET +// TODO +ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags) +{ + unimplemented(); + return 0; +} + +// TODO +int socketpair(int domain, int type, int protocol, int sv[2]) +{ + unimplemented(); + return 0; +} + +#endif // RUX_CONFIG_NET diff --git a/ulib/axlibc/c/stat.c b/ulib/ruxlibc/c/stat.c similarity index 95% rename from ulib/axlibc/c/stat.c rename to ulib/ruxlibc/c/stat.c index aebb0bb88..9b93f816b 100644 --- a/ulib/axlibc/c/stat.c +++ b/ulib/ruxlibc/c/stat.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/ioctl.c b/ulib/ruxlibc/c/statfs.c similarity index 82% rename from ulib/axlibc/c/ioctl.c rename to ulib/ruxlibc/c/statfs.c index 9c961bb76..84d773818 100644 --- a/ulib/axlibc/c/ioctl.c +++ b/ulib/ruxlibc/c/statfs.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,10 +8,10 @@ */ #include -#include +#include // TODO -int ioctl(int __fd, int __request, ...) +int statfs(const char *path, struct statfs *buf) { unimplemented(); return 0; diff --git a/ulib/axlibc/c/stdio.c b/ulib/ruxlibc/c/stdio.c similarity index 98% rename from ulib/axlibc/c/stdio.c rename to ulib/ruxlibc/c/stdio.c index 86e057460..5122b9b85 100644 --- a/ulib/axlibc/c/stdio.c +++ b/ulib/ruxlibc/c/stdio.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -21,7 +21,7 @@ #include // LOCK used by `puts()` -#ifdef AX_CONFIG_MULTITASK +#ifdef RUX_CONFIG_MULTITASK #include static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; #endif @@ -116,7 +116,7 @@ int putchar(int c) int puts(const char *s) { -#ifdef AX_CONFIG_MULTITASK +#ifdef RUX_CONFIG_MULTITASK pthread_mutex_lock(&lock); #endif @@ -124,7 +124,7 @@ int puts(const char *s) char brk[1] = {'\n'}; write(1, (const void *)brk, 1); -#ifdef AX_CONFIG_MULTITASK +#ifdef RUX_CONFIG_MULTITASK pthread_mutex_unlock(&lock); #endif @@ -181,7 +181,7 @@ int sscanf(const char *restrict __s, const char *restrict __format, ...) return 0; } -#ifdef AX_CONFIG_FS +#ifdef RUX_CONFIG_FS int __fmodeflags(const char *mode) { @@ -466,4 +466,4 @@ FILE *fdopen(int fd, const char *mode) return f; } -#endif // AX_CONFIG_FS +#endif // RUX_CONFIG_FS diff --git a/ulib/axlibc/c/stdlib.c b/ulib/ruxlibc/c/stdlib.c similarity index 56% rename from ulib/axlibc/c/stdlib.c rename to ulib/ruxlibc/c/stdlib.c index 7a98cb34c..ea14d5772 100644 --- a/ulib/axlibc/c/stdlib.c +++ b/ulib/ruxlibc/c/stdlib.c @@ -1,10 +1,11 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -26,7 +27,7 @@ void srandom(unsigned int s) srand(s); } -#ifdef AX_CONFIG_ALLOC +#ifdef RUX_CONFIG_ALLOC void *calloc(size_t m, size_t n) { @@ -51,7 +52,7 @@ void *realloc(void *memblock, size_t size) return mem; } -#endif // AX_CONFIG_ALLOC +#endif // RUX_CONFIG_ALLOC long long llabs(long long a) { @@ -353,7 +354,7 @@ unsigned long long strtoull(const char *nptr, char **endptr, int base) return acc; } -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD // TODO: precision may not be enough long double strtold(const char *restrict s, char **restrict p) @@ -361,238 +362,239 @@ long double strtold(const char *restrict s, char **restrict p) return (long double)strtod(s, p); } -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD typedef int (*cmpfun_)(const void *, const void *); static int wrapper_cmp(const void *v1, const void *v2, void *cmp) { - return ((cmpfun_)cmp)(v1, v2); + return ((cmpfun_)cmp)(v1, v2); } typedef int (*cmpfun)(const void *, const void *, void *); -static inline int a_ctz_32(uint32_t x){ - static const char debruijn32[32] = { - 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, - 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14 - }; - return debruijn32[(x&-x)*0x076be629 >> 27]; +static inline int a_ctz_32(uint32_t x) +{ + static const char debruijn32[32] = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, + 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, + 7, 12, 21, 17, 9, 6, 16, 5, 15, 14}; + return debruijn32[(x & -x) * 0x076be629 >> 27]; } -static inline int a_ctz_64(uint64_t x){ +static inline int a_ctz_64(uint64_t x) +{ static const char debruijn64[64] = { - 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, - 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, - 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10, - 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12 - }; - if (sizeof(long) < 8) { - uint32_t y = x; - if (!y) { - y = x>>32; - return 32 + a_ctz_32(y); - } - return a_ctz_32(y); - } - return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58]; + 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28, 62, 5, 39, 46, 44, 42, + 22, 9, 24, 35, 59, 56, 49, 18, 29, 11, 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, + 23, 58, 17, 10, 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12}; + if (sizeof(long) < 8) { + uint32_t y = x; + if (!y) { + y = x >> 32; + return 32 + a_ctz_32(y); + } + return a_ctz_32(y); + } + return debruijn64[(x & -x) * 0x022fdd63cc95386dull >> 58]; } static inline int a_ctz_l(unsigned long x) { - return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x); + return (sizeof(long) < 8) ? a_ctz_32(x) : a_ctz_64(x); } #define ntz(x) a_ctz_l((x)) - -static inline int pntz(size_t p[2]) { - int r = ntz(p[0] - 1); - if(r != 0 || (r = 8*sizeof(size_t) + ntz(p[1])) != 8*sizeof(size_t)) { - return r; - } - return 0; +static inline int pntz(size_t p[2]) +{ + int r = ntz(p[0] - 1); + if (r != 0 || (r = 8 * sizeof(size_t) + ntz(p[1])) != 8 * sizeof(size_t)) { + return r; + } + return 0; } -static void cycle(size_t width, unsigned char* ar[], int n) +static void cycle(size_t width, unsigned char *ar[], int n) { - unsigned char tmp[256]; - size_t l; - int i; - - if(n < 2) { - return; - } - - ar[n] = tmp; - while(width) { - l = sizeof(tmp) < width ? sizeof(tmp) : width; - memcpy(ar[n], ar[0], l); - for(i = 0; i < n; i++) { - memcpy(ar[i], ar[i + 1], l); - ar[i] += l; - } - width -= l; - } + unsigned char tmp[256]; + size_t l; + int i; + + if (n < 2) { + return; + } + + ar[n] = tmp; + while (width) { + l = sizeof(tmp) < width ? sizeof(tmp) : width; + memcpy(ar[n], ar[0], l); + for (i = 0; i < n; i++) { + memcpy(ar[i], ar[i + 1], l); + ar[i] += l; + } + width -= l; + } } /* shl() and shr() need n > 0 */ static inline void shl(size_t p[2], int n) { - if(n >= 8 * sizeof(size_t)) { - n -= 8 * sizeof(size_t); - p[1] = p[0]; - p[0] = 0; - } - p[1] <<= n; - p[1] |= p[0] >> (sizeof(size_t) * 8 - n); - p[0] <<= n; + if (n >= 8 * sizeof(size_t)) { + n -= 8 * sizeof(size_t); + p[1] = p[0]; + p[0] = 0; + } + p[1] <<= n; + p[1] |= p[0] >> (sizeof(size_t) * 8 - n); + p[0] <<= n; } static inline void shr(size_t p[2], int n) { - if(n >= 8 * sizeof(size_t)) { - n -= 8 * sizeof(size_t); - p[0] = p[1]; - p[1] = 0; - } - p[0] >>= n; - p[0] |= p[1] << (sizeof(size_t) * 8 - n); - p[1] >>= n; + if (n >= 8 * sizeof(size_t)) { + n -= 8 * sizeof(size_t); + p[0] = p[1]; + p[1] = 0; + } + p[0] >>= n; + p[0] |= p[1] << (sizeof(size_t) * 8 - n); + p[1] >>= n; } static void sift(unsigned char *head, size_t width, cmpfun cmp, void *arg, int pshift, size_t lp[]) { - unsigned char *rt, *lf; - unsigned char *ar[14 * sizeof(size_t) + 1]; - int i = 1; - - ar[0] = head; - while(pshift > 1) { - rt = head - width; - lf = head - width - lp[pshift - 2]; - - if(cmp(ar[0], lf, arg) >= 0 && cmp(ar[0], rt, arg) >= 0) { - break; - } - if(cmp(lf, rt, arg) >= 0) { - ar[i++] = lf; - head = lf; - pshift -= 1; - } else { - ar[i++] = rt; - head = rt; - pshift -= 2; - } - } - cycle(width, ar, i); + unsigned char *rt, *lf; + unsigned char *ar[14 * sizeof(size_t) + 1]; + int i = 1; + + ar[0] = head; + while (pshift > 1) { + rt = head - width; + lf = head - width - lp[pshift - 2]; + + if (cmp(ar[0], lf, arg) >= 0 && cmp(ar[0], rt, arg) >= 0) { + break; + } + if (cmp(lf, rt, arg) >= 0) { + ar[i++] = lf; + head = lf; + pshift -= 1; + } else { + ar[i++] = rt; + head = rt; + pshift -= 2; + } + } + cycle(width, ar, i); } -static void trinkle(unsigned char *head, size_t width, cmpfun cmp, void *arg, size_t pp[2], int pshift, int trusty, size_t lp[]) +static void trinkle(unsigned char *head, size_t width, cmpfun cmp, void *arg, size_t pp[2], + int pshift, int trusty, size_t lp[]) { - unsigned char *stepson, - *rt, *lf; - size_t p[2]; - unsigned char *ar[14 * sizeof(size_t) + 1]; - int i = 1; - int trail; - - p[0] = pp[0]; - p[1] = pp[1]; - - ar[0] = head; - while(p[0] != 1 || p[1] != 0) { - stepson = head - lp[pshift]; - if(cmp(stepson, ar[0], arg) <= 0) { - break; - } - if(!trusty && pshift > 1) { - rt = head - width; - lf = head - width - lp[pshift - 2]; - if(cmp(rt, stepson, arg) >= 0 || cmp(lf, stepson, arg) >= 0) { - break; - } - } - - ar[i++] = stepson; - head = stepson; - trail = pntz(p); - shr(p, trail); - pshift += trail; - trusty = 0; - } - if(!trusty) { - cycle(width, ar, i); - sift(head, width, cmp, arg, pshift, lp); - } + unsigned char *stepson, *rt, *lf; + size_t p[2]; + unsigned char *ar[14 * sizeof(size_t) + 1]; + int i = 1; + int trail; + + p[0] = pp[0]; + p[1] = pp[1]; + + ar[0] = head; + while (p[0] != 1 || p[1] != 0) { + stepson = head - lp[pshift]; + if (cmp(stepson, ar[0], arg) <= 0) { + break; + } + if (!trusty && pshift > 1) { + rt = head - width; + lf = head - width - lp[pshift - 2]; + if (cmp(rt, stepson, arg) >= 0 || cmp(lf, stepson, arg) >= 0) { + break; + } + } + + ar[i++] = stepson; + head = stepson; + trail = pntz(p); + shr(p, trail); + pshift += trail; + trusty = 0; + } + if (!trusty) { + cycle(width, ar, i); + sift(head, width, cmp, arg, pshift, lp); + } } void __qsort_r(void *base, size_t nel, size_t width, cmpfun cmp, void *arg) { - size_t lp[12*sizeof(size_t)]; - size_t i, size = width * nel; - unsigned char *head, *high; - size_t p[2] = {1, 0}; - int pshift = 1; - int trail; - - if (!size) return; - - head = base; - high = head + size - width; - - /* Precompute Leonardo numbers, scaled by element width */ - for(lp[0]=lp[1]=width, i=2; (lp[i]=lp[i-2]+lp[i-1]+width) < size; i++); - - while(head < high) { - if((p[0] & 3) == 3) { - sift(head, width, cmp, arg, pshift, lp); - shr(p, 2); - pshift += 2; - } else { - if(lp[pshift - 1] >= high - head) { - trinkle(head, width, cmp, arg, p, pshift, 0, lp); - } else { - sift(head, width, cmp, arg, pshift, lp); - } - - if(pshift == 1) { - shl(p, 1); - pshift = 0; - } else { - shl(p, pshift - 1); - pshift = 1; - } - } - - p[0] |= 1; - head += width; - } - - trinkle(head, width, cmp, arg, p, pshift, 0, lp); - - while(pshift != 1 || p[0] != 1 || p[1] != 0) { - if(pshift <= 1) { - trail = pntz(p); - shr(p, trail); - pshift += trail; - } else { - shl(p, 2); - pshift -= 2; - p[0] ^= 7; - shr(p, 1); - trinkle(head - lp[pshift] - width, width, cmp, arg, p, pshift + 1, 1, lp); - shl(p, 1); - p[0] |= 1; - trinkle(head - width, width, cmp, arg, p, pshift, 1, lp); - } - head -= width; - } + size_t lp[12 * sizeof(size_t)]; + size_t i, size = width * nel; + unsigned char *head, *high; + size_t p[2] = {1, 0}; + int pshift = 1; + int trail; + + if (!size) + return; + + head = base; + high = head + size - width; + + /* Precompute Leonardo numbers, scaled by element width */ + for (lp[0] = lp[1] = width, i = 2; (lp[i] = lp[i - 2] + lp[i - 1] + width) < size; i++) + ; + + while (head < high) { + if ((p[0] & 3) == 3) { + sift(head, width, cmp, arg, pshift, lp); + shr(p, 2); + pshift += 2; + } else { + if (lp[pshift - 1] >= high - head) { + trinkle(head, width, cmp, arg, p, pshift, 0, lp); + } else { + sift(head, width, cmp, arg, pshift, lp); + } + + if (pshift == 1) { + shl(p, 1); + pshift = 0; + } else { + shl(p, pshift - 1); + pshift = 1; + } + } + + p[0] |= 1; + head += width; + } + + trinkle(head, width, cmp, arg, p, pshift, 0, lp); + + while (pshift != 1 || p[0] != 1 || p[1] != 0) { + if (pshift <= 1) { + trail = pntz(p); + shr(p, trail); + pshift += trail; + } else { + shl(p, 2); + pshift -= 2; + p[0] ^= 7; + shr(p, 1); + trinkle(head - lp[pshift] - width, width, cmp, arg, p, pshift + 1, 1, lp); + shl(p, 1); + p[0] |= 1; + trinkle(head - width, width, cmp, arg, p, pshift, 1, lp); + } + head -= width; + } } void qsort(void *base, size_t nel, size_t width, cmpfun_ cmp) { - __qsort_r(base, nel, width, wrapper_cmp, (void *)cmp); + __qsort_r(base, nel, width, wrapper_cmp, (void *)cmp); } // TODO @@ -615,3 +617,75 @@ int system(const char *cmd) unimplemented(); return 0; } + +// TODO +char *realpath(const char *restrict path, char *restrict resolved_path) +{ + unimplemented(); + return 0; +} + +struct chunk { + size_t psize, csize; + struct chunk *next, *prev; +}; + +void __bin_chunk(struct chunk *) +{ + unimplemented(); + return; +} + +void *aligned_alloc(size_t align, size_t len) +{ + unsigned char *mem, *new; + + if ((align & -align) != align) { + errno = EINVAL; + return 0; + } + + if (len > SIZE_MAX - align) { + errno = ENOMEM; + return 0; + } + + if (align <= SIZE_ALIGN) + return malloc(len); + + if (!(mem = malloc(len + align - 1))) + return 0; + + new = (void *)((uintptr_t)mem + align - 1 & -align); + if (new == mem) + return mem; + + struct chunk *c = MEM_TO_CHUNK(mem); + struct chunk *n = MEM_TO_CHUNK(new); + + if (IS_MMAPPED(c)) { + n->psize = c->psize + (new - mem); + n->csize = c->csize - (new - mem); + return new; + } + + struct chunk *t = NEXT_CHUNK(c); + + n->psize = c->csize = C_INUSE | (new - mem); + n->csize = t->psize -= new - mem; + + __bin_chunk(c); + return new; +} + +// TODO +int posix_memalign(void **res, size_t align, size_t len) +{ + if (align < sizeof(void *)) + return EINVAL; + void *mem = aligned_alloc(align, len); + if (!mem) + return errno; + *res = mem; + return 0; +} diff --git a/ulib/axlibc/c/string.c b/ulib/ruxlibc/c/string.c similarity index 99% rename from ulib/axlibc/c/string.c rename to ulib/ruxlibc/c/string.c index a59a56df7..d712cc90c 100644 --- a/ulib/axlibc/c/string.c +++ b/ulib/ruxlibc/c/string.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -458,7 +458,7 @@ char *strstr(const char *h, const char *n) return twoway_strstr((void *)h, (void *)n); } -#ifdef AX_CONFIG_ALLOC +#ifdef RUX_CONFIG_ALLOC #include char *strdup(const char *s) @@ -470,4 +470,4 @@ char *strdup(const char *s) return memcpy(d, s, l + 1); } -#endif // AX_CONFIG_ALLOC +#endif // RUX_CONFIG_ALLOC diff --git a/ulib/axlibc/c/syslog.c b/ulib/ruxlibc/c/syslog.c similarity index 94% rename from ulib/axlibc/c/syslog.c rename to ulib/ruxlibc/c/syslog.c index 7b70bf942..d47afadeb 100644 --- a/ulib/axlibc/c/syslog.c +++ b/ulib/ruxlibc/c/syslog.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/time.c b/ulib/ruxlibc/c/time.c similarity index 98% rename from ulib/axlibc/c/time.c rename to ulib/ruxlibc/c/time.c index 896ec5161..b3e05a13f 100644 --- a/ulib/axlibc/c/time.c +++ b/ulib/ruxlibc/c/time.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -208,7 +208,7 @@ clock_t clock(void) return 0; } -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD double difftime(time_t t1, time_t t0) { return t1 - t0; diff --git a/ulib/ruxlibc/c/uio.c b/ulib/ruxlibc/c/uio.c new file mode 100644 index 000000000..a1e597b3c --- /dev/null +++ b/ulib/ruxlibc/c/uio.c @@ -0,0 +1,32 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#include +#include + +// TODO +ssize_t readv(int fd, const struct iovec *iov, int iovcnt) +{ + unimplemented(); + return 0; +} + +// TODO +ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset) +{ + unimplemented(); + return 0; +} + +// TODO +ssize_t pwritev(int fd, const struct iovec *iov, int iovcnt, off_t offset) +{ + unimplemented(); + return 0; +} diff --git a/ulib/axlibc/c/unistd.c b/ulib/ruxlibc/c/unistd.c similarity index 66% rename from ulib/axlibc/c/unistd.c rename to ulib/ruxlibc/c/unistd.c index 2bf7ea047..a559144c9 100644 --- a/ulib/axlibc/c/unistd.c +++ b/ulib/ruxlibc/c/unistd.c @@ -1,10 +1,11 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,9 +13,17 @@ #include #include #include +#include #include #include +// TODO: +pid_t getppid(void) +{ + unimplemented(); + return 0; +} + // TODO: uid_t geteuid(void) { @@ -29,6 +38,13 @@ uid_t getuid(void) return 0; } +// TODO +int setuid(uid_t __uid) +{ + unimplemented(); + return 0; +} + // TODO pid_t setsid(void) { @@ -36,6 +52,13 @@ pid_t setsid(void) return 0; } +// TODO +int setgid(gid_t gid) +{ + unimplemented(); + return 0; +} + // TODO int isatty(int fd) { @@ -43,6 +66,50 @@ int isatty(int fd) return 0; } +// TODO +int getpagesize(void) +{ + unimplemented(); + return 0; +} + +// TODO +ssize_t pread(int fd, void *buf, size_t count, off_t offset) +{ + unimplemented(); + return 0; +} + +// TODO +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + unimplemented(); + return 0; +} + +// TODO +int gethostname(char *name, size_t len) +{ + size_t i; + struct utsname uts; + if (uname(&uts)) + return -1; + if (len > sizeof uts.nodename) + len = sizeof uts.nodename; + for (i = 0; i < len && (name[i] = uts.nodename[i]); i++) + ; + if (i && i == len) + name[i - 1] = 0; + return 0; +} + +// TODO +int chown(const char *path, uid_t owner, gid_t group) +{ + unimplemented(); + return 0; +} + unsigned int sleep(unsigned int seconds) { struct timespec ts; @@ -61,7 +128,7 @@ int usleep(unsigned useconds) return nanosleep(&tv, &tv); } -#ifdef AX_CONFIG_FS +#ifdef RUX_CONFIG_FS // TODO: int access(const char *pathname, int mode) @@ -119,9 +186,9 @@ int truncate(const char *path, off_t length) return 0; } -#endif // AX_CONFIG_FS +#endif // RUX_CONFIG_FS -#ifdef AX_CONFIG_PIPE +#ifdef RUX_CONFIG_PIPE int pipe2(int fd[2], int flag) { @@ -146,7 +213,7 @@ int pipe2(int fd[2], int flag) return 0; } -#endif // AX_CONFIG_PIPE +#endif // RUX_CONFIG_PIPE // TODO _Noreturn void _exit(int status) diff --git a/ulib/axlibc/c/utsname.c b/ulib/ruxlibc/c/utsname.c similarity index 93% rename from ulib/axlibc/c/utsname.c rename to ulib/ruxlibc/c/utsname.c index 18b6dd7a8..7aeecd9e6 100644 --- a/ulib/axlibc/c/utsname.c +++ b/ulib/ruxlibc/c/utsname.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/c/wait.c b/ulib/ruxlibc/c/wait.c similarity index 94% rename from ulib/axlibc/c/wait.c rename to ulib/ruxlibc/c/wait.c index a40ddb1cc..90add3e59 100644 --- a/ulib/axlibc/c/wait.c +++ b/ulib/ruxlibc/c/wait.c @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/ctypes.h b/ulib/ruxlibc/ctypes.h similarity index 92% rename from ulib/axlibc/ctypes.h rename to ulib/ruxlibc/ctypes.h index 8cda0b833..f1c1cc8b1 100644 --- a/ulib/axlibc/ctypes.h +++ b/ulib/ruxlibc/ctypes.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/arpa/inet.h b/ulib/ruxlibc/include/arpa/inet.h similarity index 94% rename from ulib/axlibc/include/arpa/inet.h rename to ulib/ruxlibc/include/arpa/inet.h index 032413548..d87cb6635 100644 --- a/ulib/axlibc/include/arpa/inet.h +++ b/ulib/ruxlibc/include/arpa/inet.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/assert.h b/ulib/ruxlibc/include/assert.h similarity index 94% rename from ulib/axlibc/include/assert.h rename to ulib/ruxlibc/include/assert.h index 4d210ba82..b71b4c829 100644 --- a/ulib/axlibc/include/assert.h +++ b/ulib/ruxlibc/include/assert.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/ruxlibc/include/byteswap.h b/ulib/ruxlibc/include/byteswap.h new file mode 100644 index 000000000..2c2f44818 --- /dev/null +++ b/ulib/ruxlibc/include/byteswap.h @@ -0,0 +1,7 @@ +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +#include +#include + +#endif diff --git a/ulib/ruxlibc/include/crypt.h b/ulib/ruxlibc/include/crypt.h new file mode 100644 index 000000000..d67e14b21 --- /dev/null +++ b/ulib/ruxlibc/include/crypt.h @@ -0,0 +1,4 @@ +#ifndef _CRYPT_H +#define _CRYPT_H + +#endif diff --git a/ulib/axlibc/include/ctype.h b/ulib/ruxlibc/include/ctype.h similarity index 96% rename from ulib/axlibc/include/ctype.h rename to ulib/ruxlibc/include/ctype.h index 7e4e5b895..cbf315bbc 100644 --- a/ulib/axlibc/include/ctype.h +++ b/ulib/ruxlibc/include/ctype.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/dirent.h b/ulib/ruxlibc/include/dirent.h similarity index 96% rename from ulib/axlibc/include/dirent.h rename to ulib/ruxlibc/include/dirent.h index 57b137af3..ac8942ac2 100644 --- a/ulib/axlibc/include/dirent.h +++ b/ulib/ruxlibc/include/dirent.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/dlfcn.h b/ulib/ruxlibc/include/dlfcn.h similarity index 96% rename from ulib/axlibc/include/dlfcn.h rename to ulib/ruxlibc/include/dlfcn.h index 2f5124ba0..d61d2a2b3 100644 --- a/ulib/axlibc/include/dlfcn.h +++ b/ulib/ruxlibc/include/dlfcn.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/endian.h b/ulib/ruxlibc/include/endian.h similarity index 97% rename from ulib/axlibc/include/endian.h rename to ulib/ruxlibc/include/endian.h index 7be379458..311cc0f78 100644 --- a/ulib/axlibc/include/endian.h +++ b/ulib/ruxlibc/include/endian.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/errno.h b/ulib/ruxlibc/include/errno.h similarity index 99% rename from ulib/axlibc/include/errno.h rename to ulib/ruxlibc/include/errno.h index 64989a642..a73a8ec1c 100644 --- a/ulib/axlibc/include/errno.h +++ b/ulib/ruxlibc/include/errno.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/fcntl.h b/ulib/ruxlibc/include/fcntl.h similarity index 95% rename from ulib/axlibc/include/fcntl.h rename to ulib/ruxlibc/include/fcntl.h index 2f693d004..01e73b223 100644 --- a/ulib/axlibc/include/fcntl.h +++ b/ulib/ruxlibc/include/fcntl.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,7 +11,9 @@ #define __FCNTL_H__ #include +//#include +#define AT_SYMLINK_NOFOLLOW 0x100 #define O_CREAT 0100 #define O_EXCL 0200 #define O_NOCTTY 0400 @@ -129,5 +131,6 @@ int posix_fadvise(int __fd, unsigned long __offset, unsigned long __len, int __a int sync_file_range(int, off_t, off_t, unsigned); int open(const char *filename, int flags, ...); +int openat(int, const char *, int, ...); #endif diff --git a/ulib/axlibc/include/features.h b/ulib/ruxlibc/include/features.h similarity index 93% rename from ulib/axlibc/include/features.h rename to ulib/ruxlibc/include/features.h index a9907595c..dab3ac060 100644 --- a/ulib/axlibc/include/features.h +++ b/ulib/ruxlibc/include/features.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/float.h b/ulib/ruxlibc/include/float.h similarity index 98% rename from ulib/axlibc/include/float.h rename to ulib/ruxlibc/include/float.h index a52548520..34c8c498e 100644 --- a/ulib/axlibc/include/float.h +++ b/ulib/ruxlibc/include/float.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/fnmatch.h b/ulib/ruxlibc/include/fnmatch.h similarity index 87% rename from ulib/axlibc/include/fnmatch.h rename to ulib/ruxlibc/include/fnmatch.h index 70f730a3d..80958add4 100644 --- a/ulib/axlibc/include/fnmatch.h +++ b/ulib/ruxlibc/include/fnmatch.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,9 +10,6 @@ #ifndef _FNMATCH_H #define _FNMATCH_H -#ifdef __cplusplus -extern "C" { -#endif #define FNM_PATHNAME 0x1 #define FNM_NOESCAPE 0x2 @@ -26,8 +23,5 @@ extern "C" { int fnmatch(const char *, const char *, int); -#ifdef __cplusplus -} -#endif #endif diff --git a/ulib/axlibc/include/glob.h b/ulib/ruxlibc/include/glob.h similarity index 96% rename from ulib/axlibc/include/glob.h rename to ulib/ruxlibc/include/glob.h index 3e94f072d..710eec9f3 100644 --- a/ulib/axlibc/include/glob.h +++ b/ulib/ruxlibc/include/glob.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/ruxlibc/include/grp.h b/ulib/ruxlibc/include/grp.h new file mode 100644 index 000000000..df92a49b5 --- /dev/null +++ b/ulib/ruxlibc/include/grp.h @@ -0,0 +1,27 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#ifndef _GRP_H +#define _GRP_H + +#include +#include + +struct group { + char *gr_name; + char *gr_passwd; + gid_t gr_gid; + char **gr_mem; +}; + +struct group *getgrgid(gid_t); +struct group *getgrnam(const char *); + +#endif diff --git a/ulib/axlibc/include/inttypes.h b/ulib/ruxlibc/include/inttypes.h similarity index 93% rename from ulib/axlibc/include/inttypes.h rename to ulib/ruxlibc/include/inttypes.h index 554356012..b137560d5 100644 --- a/ulib/axlibc/include/inttypes.h +++ b/ulib/ruxlibc/include/inttypes.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/ksigaction.h b/ulib/ruxlibc/include/ksigaction.h similarity index 86% rename from ulib/axlibc/include/ksigaction.h rename to ulib/ruxlibc/include/ksigaction.h index 0e4b74fc8..0937f164a 100644 --- a/ulib/axlibc/include/ksigaction.h +++ b/ulib/ruxlibc/include/ksigaction.h @@ -1,12 +1,13 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ - +#ifndef _KSIGACTION_H +#define _KSIGACTION_H struct k_sigaction { void (*handler)(int); @@ -14,3 +15,4 @@ struct k_sigaction { void (*restorer)(void); unsigned mask[2]; }; +#endif \ No newline at end of file diff --git a/ulib/axlibc/include/langinfo.h b/ulib/ruxlibc/include/langinfo.h similarity index 97% rename from ulib/axlibc/include/langinfo.h rename to ulib/ruxlibc/include/langinfo.h index 3ea38a6cb..f0dc7e77e 100644 --- a/ulib/axlibc/include/langinfo.h +++ b/ulib/ruxlibc/include/langinfo.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/libgen.h b/ulib/ruxlibc/include/libgen.h similarity index 93% rename from ulib/axlibc/include/libgen.h rename to ulib/ruxlibc/include/libgen.h index 567aacc49..335255d54 100644 --- a/ulib/axlibc/include/libgen.h +++ b/ulib/ruxlibc/include/libgen.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/limits.h b/ulib/ruxlibc/include/limits.h similarity index 96% rename from ulib/axlibc/include/limits.h rename to ulib/ruxlibc/include/limits.h index 4046031fe..1675074ba 100644 --- a/ulib/axlibc/include/limits.h +++ b/ulib/ruxlibc/include/limits.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/locale.h b/ulib/ruxlibc/include/locale.h similarity index 97% rename from ulib/axlibc/include/locale.h rename to ulib/ruxlibc/include/locale.h index e68ff0ce6..2bcf92bab 100644 --- a/ulib/axlibc/include/locale.h +++ b/ulib/ruxlibc/include/locale.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/ruxlibc/include/malloc.h b/ulib/ruxlibc/include/malloc.h new file mode 100644 index 000000000..b7583d922 --- /dev/null +++ b/ulib/ruxlibc/include/malloc.h @@ -0,0 +1,20 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#ifndef _MALLOC_H +#define _MALLOC_H + +#include + +void *valloc(size_t); +void *memalign(size_t, size_t); +size_t malloc_usable_size(void *); + +#endif diff --git a/ulib/axlibc/include/math.h b/ulib/ruxlibc/include/math.h similarity index 98% rename from ulib/axlibc/include/math.h rename to ulib/ruxlibc/include/math.h index 35fb85b1c..9c27b0050 100644 --- a/ulib/axlibc/include/math.h +++ b/ulib/ruxlibc/include/math.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,7 +10,7 @@ #ifndef _MATH_H #define _MATH_H -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD typedef double double_t; @@ -325,6 +325,6 @@ double trunc(double); float truncf(float); long double truncl(long double); -#endif // AX_CONFIG_FP_SIMD +#endif // RUX_CONFIG_FP_SIMD #endif // _MATH_H diff --git a/ulib/axlibc/include/memory.h b/ulib/ruxlibc/include/memory.h similarity index 92% rename from ulib/axlibc/include/memory.h rename to ulib/ruxlibc/include/memory.h index 31c4a81f6..83571eb50 100644 --- a/ulib/axlibc/include/memory.h +++ b/ulib/ruxlibc/include/memory.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/netdb.h b/ulib/ruxlibc/include/netdb.h similarity index 78% rename from ulib/axlibc/include/netdb.h rename to ulib/ruxlibc/include/netdb.h index 315c59f6c..ad275e003 100644 --- a/ulib/axlibc/include/netdb.h +++ b/ulib/ruxlibc/include/netdb.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -83,12 +83,46 @@ const char *hstrerror(int ecode); #define MAXSERVS 2 #define MAXADDRS 48 -#ifdef AX_CONFIG_NET +#ifdef RUX_CONFIG_NET int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **); void freeaddrinfo(struct addrinfo *); const char *gai_strerror(int __ecode); -#endif // AX_CONFIG_NET +/* Legacy functions follow (marked OBsolete in SUS) */ + +struct netent { + char *n_name; + char **n_aliases; + int n_addrtype; + uint32_t n_net; +}; + +struct hostent { + char *h_name; + char **h_aliases; + int h_addrtype; + int h_length; + char **h_addr_list; +}; +#define h_addr h_addr_list[0] + +struct servent { + char *s_name; + char **s_aliases; + int s_port; + char *s_proto; +}; + +struct protoent { + char *p_name; + char **p_aliases; + int p_proto; +}; + +struct hostent *gethostbyname (const char *); + + +#endif // RUX_CONFIG_NET #endif // _NETDB_H diff --git a/ulib/axlibc/include/netinet/in.h b/ulib/ruxlibc/include/netinet/in.h similarity index 94% rename from ulib/axlibc/include/netinet/in.h rename to ulib/ruxlibc/include/netinet/in.h index 48684aafb..e67e9750a 100644 --- a/ulib/axlibc/include/netinet/in.h +++ b/ulib/ruxlibc/include/netinet/in.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -15,6 +15,11 @@ #define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46 +#define INADDR_ANY ((in_addr_t) 0x00000000) +#define INADDR_BROADCAST ((in_addr_t) 0xffffffff) +#define INADDR_NONE ((in_addr_t) 0xffffffff) +#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) + uint32_t htonl(uint32_t); uint16_t htons(uint16_t); uint32_t ntohl(uint32_t); diff --git a/ulib/axlibc/include/netinet/tcp.h b/ulib/ruxlibc/include/netinet/tcp.h similarity index 97% rename from ulib/axlibc/include/netinet/tcp.h rename to ulib/ruxlibc/include/netinet/tcp.h index 2b4c9dec3..fd39a81d4 100644 --- a/ulib/axlibc/include/netinet/tcp.h +++ b/ulib/ruxlibc/include/netinet/tcp.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/ruxlibc/include/nscd.h b/ulib/ruxlibc/include/nscd.h new file mode 100644 index 000000000..32dbea024 --- /dev/null +++ b/ulib/ruxlibc/include/nscd.h @@ -0,0 +1,46 @@ +#ifndef NSCD_H +#define NSCD_H + +#include +#include +#include + +#define NSCDVERSION 2 +#define GETPWBYNAME 0 +#define GETPWBYUID 1 +#define GETGRBYNAME 2 +#define GETGRBYGID 3 +#define GETINITGR 15 + +#define REQVERSION 0 +#define REQTYPE 1 +#define REQKEYLEN 2 +#define REQ_LEN 3 + +#define PWVERSION 0 +#define PWFOUND 1 +#define PWNAMELEN 2 +#define PWPASSWDLEN 3 +#define PWUID 4 +#define PWGID 5 +#define PWGECOSLEN 6 +#define PWDIRLEN 7 +#define PWSHELLLEN 8 +#define PW_LEN 9 + +#define GRVERSION 0 +#define GRFOUND 1 +#define GRNAMELEN 2 +#define GRPASSWDLEN 3 +#define GRGID 4 +#define GRMEMCNT 5 +#define GR_LEN 6 + +#define INITGRVERSION 0 +#define INITGRFOUND 1 +#define INITGRNGRPS 2 +#define INITGR_LEN 3 + +FILE *__nscd_query(int32_t req, const char *key, int32_t *buf, size_t len, int *swap); + +#endif diff --git a/ulib/axlibc/include/poll.h b/ulib/ruxlibc/include/poll.h similarity index 94% rename from ulib/axlibc/include/poll.h rename to ulib/ruxlibc/include/poll.h index 49000b89d..bbac591d7 100644 --- a/ulib/axlibc/include/poll.h +++ b/ulib/ruxlibc/include/poll.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/pthread.h b/ulib/ruxlibc/include/pthread.h similarity index 97% rename from ulib/axlibc/include/pthread.h rename to ulib/ruxlibc/include/pthread.h index c7c6b9861..73189eaf6 100644 --- a/ulib/axlibc/include/pthread.h +++ b/ulib/ruxlibc/include/pthread.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,6 +12,8 @@ #define _PTHREAD_H #include + +typedef void *pthread_t; #include #define PTHREAD_CANCEL_ENABLE 0 @@ -42,7 +44,6 @@ typedef struct { #define _a_guardsize __u.__s[1] #define _a_stackaddr __u.__s[2] -typedef void *pthread_t; #define PTHREAD_CANCELED ((void *)-1) #define SIGCANCEL 33 @@ -50,7 +51,7 @@ typedef void *pthread_t; /* Keys for thread-specific data */ typedef unsigned int pthread_key_t; -#ifdef AX_CONFIG_MULTITASK +#ifdef RUX_CONFIG_MULTITASK _Noreturn void pthread_exit(void *); pthread_t pthread_self(void); @@ -104,6 +105,6 @@ void *pthread_getspecific(pthread_key_t __key); /* Store POINTER in the thread-specific data slot identified by KEY. */ int pthread_setspecific(pthread_key_t __key, const void *__pointer); -#endif // AX_CONFIG_MULTITASK +#endif // RUX_CONFIG_MULTITASK #endif // _PTHREAD_H diff --git a/ulib/axlibc/include/pwd.h b/ulib/ruxlibc/include/pwd.h similarity index 85% rename from ulib/axlibc/include/pwd.h rename to ulib/ruxlibc/include/pwd.h index 6d6c647ef..5c76a13b4 100644 --- a/ulib/axlibc/include/pwd.h +++ b/ulib/ruxlibc/include/pwd.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -38,6 +38,12 @@ #define REQKEYLEN 2 #define REQ_LEN 3 +#define RUX_DEFAULT_USER "root" +#define RUX_DEFAULT_GROUP "root" +#define RUX_DEFAULT_PASS "" +#define RUX_DEFAULT_UID 0 +#define RUX_DEFAULT_GID 0 + struct passwd { char *pw_name; char *pw_passwd; @@ -51,4 +57,6 @@ struct passwd { int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **); int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); +struct passwd *getpwnam (const char *); + #endif // _PWD_H diff --git a/ulib/axlibc/include/regex.h b/ulib/ruxlibc/include/regex.h similarity index 92% rename from ulib/axlibc/include/regex.h rename to ulib/ruxlibc/include/regex.h index dda592d56..8a24c9901 100644 --- a/ulib/axlibc/include/regex.h +++ b/ulib/ruxlibc/include/regex.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sched.h b/ulib/ruxlibc/include/sched.h similarity index 97% rename from ulib/axlibc/include/sched.h rename to ulib/ruxlibc/include/sched.h index b98ef7a30..34ace5316 100644 --- a/ulib/axlibc/include/sched.h +++ b/ulib/ruxlibc/include/sched.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -57,4 +57,6 @@ typedef struct cpu_set_t { int sched_setaffinity(pid_t, size_t, const cpu_set_t *); +int sched_yield(void); + #endif // _SCHED_H diff --git a/ulib/ruxlibc/include/semaphore.h b/ulib/ruxlibc/include/semaphore.h new file mode 100644 index 000000000..033cc8be1 --- /dev/null +++ b/ulib/ruxlibc/include/semaphore.h @@ -0,0 +1,26 @@ +#ifndef _SEMAPHORE_H +#define _SEMAPHORE_H + +#include +#include +#include +#include + +#define SEM_FAILED ((sem_t *)0) + +typedef struct { + volatile int __val[4 * sizeof(long) / sizeof(int)]; +} sem_t; + +int sem_close(sem_t *); +int sem_destroy(sem_t *); +int sem_getvalue(sem_t *__restrict, int *__restrict); +int sem_init(sem_t *, int, unsigned); +sem_t *sem_open(const char *, int, ...); +int sem_post(sem_t *); +int sem_timedwait(sem_t *__restrict, const struct timespec *__restrict); +int sem_trywait(sem_t *); +int sem_unlink(const char *); +int sem_wait(sem_t *); + +#endif diff --git a/ulib/axlibc/include/setjmp.h b/ulib/ruxlibc/include/setjmp.h similarity index 95% rename from ulib/axlibc/include/setjmp.h rename to ulib/ruxlibc/include/setjmp.h index c9583c05d..f6cbbebb0 100644 --- a/ulib/axlibc/include/setjmp.h +++ b/ulib/ruxlibc/include/setjmp.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/signal.h b/ulib/ruxlibc/include/signal.h similarity index 93% rename from ulib/axlibc/include/signal.h rename to ulib/ruxlibc/include/signal.h index cda590492..6026bd27f 100644 --- a/ulib/axlibc/include/signal.h +++ b/ulib/ruxlibc/include/signal.h @@ -1,18 +1,24 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ #ifndef _SIGNAL_H #define _SIGNAL_H +typedef struct __sigset_t { + unsigned long __bits[128 / sizeof(long)]; +} sigset_t; + #include #include #include +#include typedef int sig_atomic_t; @@ -159,9 +165,6 @@ typedef void (*sighandler_t)(int); #define SIGDFL 0l #define SIGIGN 1l -typedef struct __sigset_t { - unsigned long __bits[128 / sizeof(long)]; -} sigset_t; struct sigaction { union { @@ -176,6 +179,8 @@ struct sigaction { #define sa_handler __sa_handler.sa_handler #define sa_sigaction __sa_handler.sa_sigaction +int sigprocmask(int, const sigset_t *__restrict, sigset_t *__restrict); +int sigsuspend(const sigset_t *); void (*signal(int, void (*)(int)))(int); int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict); int sigemptyset(sigset_t *); @@ -185,7 +190,7 @@ int pthread_sigmask(int, const sigset_t *__restrict, sigset_t *__restrict); int kill(pid_t, int); -#ifdef AX_CONFIG_MULTITASK +#ifdef RUX_CONFIG_MULTITASK int pthread_kill(pthread_t t, int sig); #endif diff --git a/ulib/axlibc/include/stdarg.h b/ulib/ruxlibc/include/stdarg.h similarity index 94% rename from ulib/axlibc/include/stdarg.h rename to ulib/ruxlibc/include/stdarg.h index aab5d0ad7..fc31dd9ec 100644 --- a/ulib/axlibc/include/stdarg.h +++ b/ulib/ruxlibc/include/stdarg.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/stdbool.h b/ulib/ruxlibc/include/stdbool.h similarity index 93% rename from ulib/axlibc/include/stdbool.h rename to ulib/ruxlibc/include/stdbool.h index 592345c47..c133c7011 100644 --- a/ulib/axlibc/include/stdbool.h +++ b/ulib/ruxlibc/include/stdbool.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/stddef.h b/ulib/ruxlibc/include/stddef.h similarity index 71% rename from ulib/axlibc/include/stddef.h rename to ulib/ruxlibc/include/stddef.h index e1657da62..b83fedbd3 100644 --- a/ulib/axlibc/include/stddef.h +++ b/ulib/ruxlibc/include/stddef.h @@ -1,25 +1,33 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ #ifndef __STDDEF_H__ #define __STDDEF_H__ #include +typedef long clock_t; +typedef int clockid_t; + +typedef uintptr_t size_t; #include /* size_t is used for memory object sizes */ -typedef uintptr_t size_t; typedef intptr_t ssize_t; typedef ssize_t ptrdiff_t; -typedef long clock_t; -typedef int clockid_t; + + +#define _Int64 long + +typedef unsigned _Int64 fsblkcnt_t; +typedef unsigned _Int64 fsfilcnt_t; #ifdef __cplusplus #define NULL 0L diff --git a/ulib/axlibc/include/stdint.h b/ulib/ruxlibc/include/stdint.h similarity index 97% rename from ulib/axlibc/include/stdint.h rename to ulib/ruxlibc/include/stdint.h index 712d17ad7..a3feb071e 100644 --- a/ulib/axlibc/include/stdint.h +++ b/ulib/ruxlibc/include/stdint.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/stdio.h b/ulib/ruxlibc/include/stdio.h similarity index 95% rename from ulib/axlibc/include/stdio.h rename to ulib/ruxlibc/include/stdio.h index d42ad46f3..9eda0c04a 100644 --- a/ulib/axlibc/include/stdio.h +++ b/ulib/ruxlibc/include/stdio.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -37,7 +37,7 @@ extern FILE *const stderr; #define EOF (-1) -#if defined(AX_LOG_WARN) || defined(AX_LOG_INFO) || defined(AX_LOG_DEBUG) || defined(AX_LOG_TRACE) +#if defined(RUX_LOG_WARN) || defined(RUX_LOG_INFO) || defined(RUX_LOG_DEBUG) || defined(RUX_LOG_TRACE) #define unimplemented(fmt, ...) \ printf("\x1b[33m%s%s:\x1b[0m " fmt "\n", "WARN: no ax_call implementation for ", __func__, \ diff --git a/ulib/axlibc/include/stdlib.h b/ulib/ruxlibc/include/stdlib.h similarity index 70% rename from ulib/axlibc/include/stdlib.h rename to ulib/ruxlibc/include/stdlib.h index 284863044..f66a01dd7 100644 --- a/ulib/axlibc/include/stdlib.h +++ b/ulib/ruxlibc/include/stdlib.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -23,6 +23,28 @@ #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 +#define SIZE_ALIGN (4*sizeof(size_t)) +#define SIZE_MASK (-SIZE_ALIGN) +#define OVERHEAD (2*sizeof(size_t)) +#define MMAP_THRESHOLD (0x1c00*SIZE_ALIGN) +#define DONTCARE 16 +#define RECLAIM 163840 + +#define CHUNK_SIZE(c) ((c)->csize & -2) +#define CHUNK_PSIZE(c) ((c)->psize & -2) +#define PREV_CHUNK(c) ((struct chunk *)((char *)(c) - CHUNK_PSIZE(c))) +#define NEXT_CHUNK(c) ((struct chunk *)((char *)(c) + CHUNK_SIZE(c))) +#define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD) +#define CHUNK_TO_MEM(c) (void *)((char *)(c) + OVERHEAD) +#define BIN_TO_CHUNK(i) (MEM_TO_CHUNK(&mal.bins[i].head)) + +#define C_INUSE ((size_t)1) + +#define IS_MMAPPED(c) !((c)->csize & (C_INUSE)) + +int posix_memalign (void **, size_t, size_t); +char *realpath (const char *__restrict, char *__restrict); + long long atoll(const char *nptr); float strtof(const char *__restrict, char **__restrict); @@ -38,7 +60,7 @@ void srand(unsigned); long random(void); void srandom(unsigned int); -#ifdef AX_CONFIG_FP_SIMD +#ifdef RUX_CONFIG_FP_SIMD float strtof(const char *__restrict, char **__restrict); double strtod(const char *__restrict, char **__restrict); long double strtold(const char *__restrict, char **__restrict); diff --git a/ulib/axlibc/include/string.h b/ulib/ruxlibc/include/string.h similarity index 97% rename from ulib/axlibc/include/string.h rename to ulib/ruxlibc/include/string.h index a77e8aa83..b8928cac5 100644 --- a/ulib/axlibc/include/string.h +++ b/ulib/ruxlibc/include/string.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/strings.h b/ulib/ruxlibc/include/strings.h similarity index 92% rename from ulib/axlibc/include/strings.h rename to ulib/ruxlibc/include/strings.h index b0e23a86e..8a8057039 100644 --- a/ulib/axlibc/include/strings.h +++ b/ulib/ruxlibc/include/strings.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sys/epoll.h b/ulib/ruxlibc/include/sys/epoll.h similarity index 93% rename from ulib/axlibc/include/sys/epoll.h rename to ulib/ruxlibc/include/sys/epoll.h index eb0fe8500..8b02baae9 100644 --- a/ulib/axlibc/include/sys/epoll.h +++ b/ulib/ruxlibc/include/sys/epoll.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,9 +10,6 @@ #ifndef _SYS_EPOLL_H #define _SYS_EPOLL_H -#ifdef __cplusplus -extern "C" { -#endif #include #include @@ -62,8 +59,5 @@ int epoll_create(int __size); int epoll_ctl(int, int, int, struct epoll_event *); int epoll_wait(int, struct epoll_event *, int, int); -#ifdef __cplusplus -} -#endif #endif //_SYS_EPOLL_H diff --git a/ulib/ruxlibc/include/sys/eventfd.h b/ulib/ruxlibc/include/sys/eventfd.h new file mode 100644 index 000000000..7d08d78a7 --- /dev/null +++ b/ulib/ruxlibc/include/sys/eventfd.h @@ -0,0 +1,23 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#ifndef _SYS_EVENTFD_H +#define _SYS_EVENTFD_H + +#include +#include + +typedef uint64_t eventfd_t; + +#define EFD_SEMAPHORE 1 +#define EFD_CLOEXEC O_CLOEXEC +#define EFD_NONBLOCK O_NONBLOCK + +#endif /* sys/eventfd.h */ diff --git a/ulib/axlibc/include/sys/file.h b/ulib/ruxlibc/include/sys/file.h similarity index 86% rename from ulib/axlibc/include/sys/file.h rename to ulib/ruxlibc/include/sys/file.h index 8f8829e1c..981f3f70f 100644 --- a/ulib/axlibc/include/sys/file.h +++ b/ulib/ruxlibc/include/sys/file.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,10 +10,6 @@ #ifndef _SYS_FILE_H #define _SYS_FILE_H -#ifdef __cplusplus -extern "C" { -#endif - #define LOCK_SH 1 #define LOCK_EX 2 #define LOCK_NB 4 @@ -25,8 +21,5 @@ extern "C" { int flock(int, int); -#ifdef __cplusplus -} -#endif #endif // _SYS_FILE_H diff --git a/ulib/axlibc/include/sys/ioctl.h b/ulib/ruxlibc/include/sys/ioctl.h similarity index 96% rename from ulib/axlibc/include/sys/ioctl.h rename to ulib/ruxlibc/include/sys/ioctl.h index 374b8215b..d46c66f3a 100644 --- a/ulib/axlibc/include/sys/ioctl.h +++ b/ulib/ruxlibc/include/sys/ioctl.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,6 +10,8 @@ #ifndef __SYS_IOCTL_H__ #define __SYS_IOCTL_H__ +#define FIOASYNC 0x5452 + #define TCGETS 0x5401 #define TCSETS 0x5402 #define TCSETSW 0x5403 diff --git a/ulib/axlibc/include/sys/mman.h b/ulib/ruxlibc/include/sys/mman.h similarity index 98% rename from ulib/axlibc/include/sys/mman.h rename to ulib/ruxlibc/include/sys/mman.h index 8c6e24be5..7517bf251 100644 --- a/ulib/axlibc/include/sys/mman.h +++ b/ulib/ruxlibc/include/sys/mman.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sys/param.h b/ulib/ruxlibc/include/sys/param.h similarity index 92% rename from ulib/axlibc/include/sys/param.h rename to ulib/ruxlibc/include/sys/param.h index 03968092c..3c2e539a4 100644 --- a/ulib/axlibc/include/sys/param.h +++ b/ulib/ruxlibc/include/sys/param.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sys/prctl.h b/ulib/ruxlibc/include/sys/prctl.h similarity index 85% rename from ulib/axlibc/include/sys/prctl.h rename to ulib/ruxlibc/include/sys/prctl.h index 98ad279aa..e89be5eec 100644 --- a/ulib/axlibc/include/sys/prctl.h +++ b/ulib/ruxlibc/include/sys/prctl.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -10,4 +10,8 @@ #ifndef _SYS_PRCTL_H #define _SYS_PRCTL_H +#define PR_SET_DUMPABLE 4 + +int prctl (int, ...); + #endif // _SYS_PRCTL_H diff --git a/ulib/axlibc/include/sys/resource.h b/ulib/ruxlibc/include/sys/resource.h similarity index 91% rename from ulib/axlibc/include/sys/resource.h rename to ulib/ruxlibc/include/sys/resource.h index f0709f98b..0b8e9eb95 100644 --- a/ulib/axlibc/include/sys/resource.h +++ b/ulib/ruxlibc/include/sys/resource.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,6 +11,7 @@ #define _SYS_RESOURCE_H #include +#include typedef unsigned long long rlim_t; @@ -19,6 +20,10 @@ struct rlimit { rlim_t rlim_max; }; +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + #define RLIMIT_CPU 0 #define RLIMIT_FSIZE 1 #define RLIMIT_DATA 2 @@ -69,4 +74,6 @@ int getrlimit(int __resource, struct rlimit *__rlimits); int getrusage(int __who, struct rusage *__usage); +int setpriority (int, id_t, int); + #endif diff --git a/ulib/axlibc/include/sys/select.h b/ulib/ruxlibc/include/sys/select.h similarity index 97% rename from ulib/axlibc/include/sys/select.h rename to ulib/ruxlibc/include/sys/select.h index 082eacb36..9431b8416 100644 --- a/ulib/axlibc/include/sys/select.h +++ b/ulib/ruxlibc/include/sys/select.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/ruxlibc/include/sys/sendfile.h b/ulib/ruxlibc/include/sys/sendfile.h new file mode 100644 index 000000000..1a82256da --- /dev/null +++ b/ulib/ruxlibc/include/sys/sendfile.h @@ -0,0 +1,24 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + +#ifndef _SYS_SENDFILE_H +#define _SYS_SENDFILE_H + +#include +#include + +ssize_t sendfile(int, int, off_t *, size_t); + +#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) +#define sendfile64 sendfile +#define off64_t off_t +#endif + +#endif diff --git a/ulib/axlibc/include/sys/socket.h b/ulib/ruxlibc/include/sys/socket.h similarity index 95% rename from ulib/axlibc/include/sys/socket.h rename to ulib/ruxlibc/include/sys/socket.h index e558c6307..c2304787a 100644 --- a/ulib/axlibc/include/sys/socket.h +++ b/ulib/ruxlibc/include/sys/socket.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -77,6 +77,7 @@ ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_ ssize_t recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict); ssize_t sendmsg(int, const struct msghdr *, int); +ssize_t recvmsg (int, struct msghdr *, int); int getsockopt(int, int, int, void *__restrict, socklen_t *__restrict); int setsockopt(int, int, int, const void *, socklen_t); @@ -84,6 +85,18 @@ int setsockopt(int, int, int, const void *, socklen_t); int getsockname(int sockfd, struct sockaddr *restrict addr, socklen_t *restrict addrlen); int getpeername(int sockfd, struct sockaddr *restrict addr, socklen_t *restrict addrlen); +int socketpair (int, int, int, int [2]); + +#define SCM_RIGHTS 0x01 +#define SCM_CREDENTIALS 0x02 + +#define MSG_OOB 0x0001 +#define MSG_PEEK 0x0002 +#define MSG_DONTROUTE 0x0004 +#define MSG_CTRUNC 0x0008 +#define MSG_PROXY 0x0010 +#define MSG_TRUNC 0x0020 + #define SO_BINDTODEVICE 25 #define SO_ATTACH_FILTER 26 #define SO_DETACH_FILTER 27 @@ -329,4 +342,9 @@ int getpeername(int sockfd, struct sockaddr *restrict addr, socklen_t *restrict #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1)) #define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr))) #define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len)) + +struct linger { + int l_onoff; + int l_linger; +}; #endif // __SOCKET_H__ diff --git a/ulib/axlibc/include/sys/stat.h b/ulib/ruxlibc/include/sys/stat.h similarity index 96% rename from ulib/axlibc/include/sys/stat.h rename to ulib/ruxlibc/include/sys/stat.h index f73d2a3fd..e99c190ac 100644 --- a/ulib/axlibc/include/sys/stat.h +++ b/ulib/ruxlibc/include/sys/stat.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -77,9 +77,9 @@ struct kstat { }; #endif -#define st_atime st_atim.tv_sec -#define st_mtime st_mtim.tv_sec -#define st_ctime st_ctim.tv_sec +#define st_atime st_atime.tv_sec +#define st_mtime st_mtime.tv_sec +#define st_ctime st_ctime.tv_sec #define S_IFMT 0170000 diff --git a/ulib/ruxlibc/include/sys/statfs.h b/ulib/ruxlibc/include/sys/statfs.h new file mode 100644 index 000000000..d6936b750 --- /dev/null +++ b/ulib/ruxlibc/include/sys/statfs.h @@ -0,0 +1,22 @@ +#ifndef _SYS_STATFS_H +#define _SYS_STATFS_H + +#include +#include + +typedef struct __fsid_t { + int __val[2]; +} fsid_t; + +struct statfs { + unsigned long f_type, f_bsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree; + fsid_t f_fsid; + unsigned long f_namelen, f_frsize, f_flags, f_spare[4]; +}; + +int statfs(const char *, struct statfs *); +int fstatfs(int, struct statfs *); + +#endif diff --git a/ulib/ruxlibc/include/sys/statvfs.h b/ulib/ruxlibc/include/sys/statvfs.h new file mode 100644 index 000000000..4d44a30e4 --- /dev/null +++ b/ulib/ruxlibc/include/sys/statvfs.h @@ -0,0 +1,25 @@ +#ifndef _SYS_STATVFS_H +#define _SYS_STATVFS_H + +#include +#include + +struct statvfs { + unsigned long f_bsize, f_frsize; + fsblkcnt_t f_blocks, f_bfree, f_bavail; + fsfilcnt_t f_files, f_ffree, f_favail; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned long f_fsid; + unsigned : 8 * (2 * sizeof(int) - sizeof(long)); +#else + unsigned : 8 * (2 * sizeof(int) - sizeof(long)); + unsigned long f_fsid; +#endif + unsigned long f_flag, f_namemax; + int __reserved[6]; +}; + +int statvfs(const char *__restrict, struct statvfs *__restrict); +int fstatvfs(int, struct statvfs *); + +#endif diff --git a/ulib/ruxlibc/include/sys/syscall.h b/ulib/ruxlibc/include/sys/syscall.h new file mode 100644 index 000000000..f9618c84d --- /dev/null +++ b/ulib/ruxlibc/include/sys/syscall.h @@ -0,0 +1,7 @@ +#ifndef _SYS_SYSCALL_H +#define _SYS_SYSCALL_H + +#include +#include + +#endif diff --git a/ulib/axlibc/include/sys/sysinfo.h b/ulib/ruxlibc/include/sys/sysinfo.h similarity index 97% rename from ulib/axlibc/include/sys/sysinfo.h rename to ulib/ruxlibc/include/sys/sysinfo.h index 7d60d83c7..1222fd67e 100644 --- a/ulib/axlibc/include/sys/sysinfo.h +++ b/ulib/ruxlibc/include/sys/sysinfo.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sys/time.h b/ulib/ruxlibc/include/sys/time.h similarity index 96% rename from ulib/axlibc/include/sys/time.h rename to ulib/ruxlibc/include/sys/time.h index a49cea430..f2fb8e4eb 100644 --- a/ulib/axlibc/include/sys/time.h +++ b/ulib/ruxlibc/include/sys/time.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sys/types.h b/ulib/ruxlibc/include/sys/types.h similarity index 62% rename from ulib/axlibc/include/sys/types.h rename to ulib/ruxlibc/include/sys/types.h index 1020f1cfe..bd9f0fda0 100644 --- a/ulib/axlibc/include/sys/types.h +++ b/ulib/ruxlibc/include/sys/types.h @@ -1,10 +1,11 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ #ifndef __SYS_TYPES_H__ @@ -12,7 +13,11 @@ #include +typedef char *caddr_t; typedef unsigned char u_char; +typedef unsigned short u_short, ushort; +typedef unsigned u_int, uint; +typedef unsigned long u_long, ulong; typedef unsigned mode_t; typedef uint32_t nlink_t; @@ -22,8 +27,11 @@ typedef uint64_t dev_t; typedef long blksize_t; typedef int64_t blkcnt_t; +typedef unsigned id_t; typedef int pid_t; typedef unsigned uid_t; typedef unsigned gid_t; +#include + #endif // __SYS_TYPES_H__ diff --git a/ulib/axlibc/include/sys/uio.h b/ulib/ruxlibc/include/sys/uio.h similarity index 88% rename from ulib/axlibc/include/sys/uio.h rename to ulib/ruxlibc/include/sys/uio.h index 27a0a0902..adc30f993 100644 --- a/ulib/axlibc/include/sys/uio.h +++ b/ulib/ruxlibc/include/sys/uio.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -18,5 +18,6 @@ struct iovec { }; ssize_t writev(int, const struct iovec *, int); +ssize_t readv (int, const struct iovec *, int); #endif diff --git a/ulib/axlibc/include/sys/un.h b/ulib/ruxlibc/include/sys/un.h similarity index 93% rename from ulib/axlibc/include/sys/un.h rename to ulib/ruxlibc/include/sys/un.h index db78971b4..113da907e 100644 --- a/ulib/axlibc/include/sys/un.h +++ b/ulib/ruxlibc/include/sys/un.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/sys/utsname.h b/ulib/ruxlibc/include/sys/utsname.h similarity index 95% rename from ulib/axlibc/include/sys/utsname.h rename to ulib/ruxlibc/include/sys/utsname.h index 2e20c6feb..80af2c238 100644 --- a/ulib/axlibc/include/sys/utsname.h +++ b/ulib/ruxlibc/include/sys/utsname.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/ruxlibc/include/sys/vfs.h b/ulib/ruxlibc/include/sys/vfs.h new file mode 100644 index 000000000..1d6d84885 --- /dev/null +++ b/ulib/ruxlibc/include/sys/vfs.h @@ -0,0 +1,4 @@ +#ifndef _SYS_VFS_H +#define _SYS_VFS_H +#include +#endif diff --git a/ulib/axlibc/include/sys/wait.h b/ulib/ruxlibc/include/sys/wait.h similarity index 94% rename from ulib/axlibc/include/sys/wait.h rename to ulib/ruxlibc/include/sys/wait.h index 135a4cfeb..d97493a40 100644 --- a/ulib/axlibc/include/sys/wait.h +++ b/ulib/ruxlibc/include/sys/wait.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/syslog.h b/ulib/ruxlibc/include/syslog.h similarity index 97% rename from ulib/axlibc/include/syslog.h rename to ulib/ruxlibc/include/syslog.h index 586d4e251..cad43167f 100644 --- a/ulib/axlibc/include/syslog.h +++ b/ulib/ruxlibc/include/syslog.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/termios.h b/ulib/ruxlibc/include/termios.h similarity index 93% rename from ulib/axlibc/include/termios.h rename to ulib/ruxlibc/include/termios.h index 5006dc113..89dcfb416 100644 --- a/ulib/axlibc/include/termios.h +++ b/ulib/ruxlibc/include/termios.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/include/time.h b/ulib/ruxlibc/include/time.h similarity index 96% rename from ulib/axlibc/include/time.h rename to ulib/ruxlibc/include/time.h index 3103f3893..04d74f601 100644 --- a/ulib/axlibc/include/time.h +++ b/ulib/ruxlibc/include/time.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -18,6 +18,8 @@ #define CLOCK_MONOTONIC 1 #define CLOCKS_PER_SEC 1000000L +#define __tm_gmtoff tm_gmtoff + struct tm { int tm_sec; /* seconds of minute */ int tm_min; /* minutes of hour */ diff --git a/ulib/axlibc/include/unistd.h b/ulib/ruxlibc/include/unistd.h similarity index 98% rename from ulib/axlibc/include/unistd.h rename to ulib/ruxlibc/include/unistd.h index 288f4a91b..7b6bb3ff7 100644 --- a/ulib/axlibc/include/unistd.h +++ b/ulib/ruxlibc/include/unistd.h @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -24,6 +24,9 @@ #define SEEK_DATA 3 #define SEEK_HOLE 4 +int getpagesize(void); +int gethostname(char *, size_t); + int pipe(int[2]); int pipe2(int[2], int); int close(int); diff --git a/ulib/axlibc/src/env.rs b/ulib/ruxlibc/src/env.rs similarity index 82% rename from ulib/axlibc/src/env.rs rename to ulib/ruxlibc/src/env.rs index 052520c28..eb0ca4668 100644 --- a/ulib/axlibc/src/env.rs +++ b/ulib/ruxlibc/src/env.rs @@ -1,13 +1,13 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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. */ -use arceos_posix_api::{environ, environ_iter, RX_ENVIRON}; use core::ffi::{c_char, c_int, c_void}; +use ruxos_posix_api::{environ, environ_iter, RUX_ENVIRON}; use crate::malloc::{free, malloc}; use crate::string::strlen; @@ -40,17 +40,17 @@ unsafe fn find_env(search: *const c_char) -> Option<(usize, *mut c_char)> { unsafe fn put_new_env(insert: *mut c_char) { // XXX: Another problem is that `environ` can be set to any pointer, which means there is a // chance of a memory leak. But we can check if it was the same as before, like musl does. - if environ == RX_ENVIRON.as_mut_ptr() { - *RX_ENVIRON.last_mut().unwrap() = insert; - RX_ENVIRON.push(core::ptr::null_mut()); + if environ == RUX_ENVIRON.as_mut_ptr() { + *RUX_ENVIRON.last_mut().unwrap() = insert; + RUX_ENVIRON.push(core::ptr::null_mut()); // Likely a no-op but is needed due to Stacked Borrows. - environ = RX_ENVIRON.as_mut_ptr(); + environ = RUX_ENVIRON.as_mut_ptr(); } else { - RX_ENVIRON.clear(); - RX_ENVIRON.extend(environ_iter()); - RX_ENVIRON.push(insert); - RX_ENVIRON.push(core::ptr::null_mut()); - environ = RX_ENVIRON.as_mut_ptr(); + RUX_ENVIRON.clear(); + RUX_ENVIRON.extend(environ_iter()); + RUX_ENVIRON.push(insert); + RUX_ENVIRON.push(core::ptr::null_mut()); + environ = RUX_ENVIRON.as_mut_ptr(); } } @@ -105,27 +105,27 @@ pub unsafe extern "C" fn setenv( #[no_mangle] pub unsafe extern "C" fn unsetenv(key: *const c_char) -> c_int { if let Some((i, _)) = find_env(key) { - if environ == RX_ENVIRON.as_mut_ptr() { + if environ == RUX_ENVIRON.as_mut_ptr() { // No need to worry about updating the pointer, this does not // reallocate in any way. And the final null is already shifted back. - let rm = RX_ENVIRON.remove(i); + let rm = RUX_ENVIRON.remove(i); free(rm as *mut c_void); // My UB paranoia. - environ = RX_ENVIRON.as_mut_ptr(); + environ = RUX_ENVIRON.as_mut_ptr(); } else { - let len = RX_ENVIRON.len(); + let len = RUX_ENVIRON.len(); for _ in 0..len { - let rm = RX_ENVIRON.pop().unwrap(); + let rm = RUX_ENVIRON.pop().unwrap(); free(rm as *mut c_void); } - RX_ENVIRON.extend( + RUX_ENVIRON.extend( environ_iter() .enumerate() .filter(|&(j, _)| j != i) .map(|(_, v)| v), ); - RX_ENVIRON.push(core::ptr::null_mut()); - environ = RX_ENVIRON.as_mut_ptr(); + RUX_ENVIRON.push(core::ptr::null_mut()); + environ = RUX_ENVIRON.as_mut_ptr(); } } 0 diff --git a/ulib/axlibc/src/errno.rs b/ulib/ruxlibc/src/errno.rs similarity index 97% rename from ulib/axlibc/src/errno.rs rename to ulib/ruxlibc/src/errno.rs index bedf32815..6bfd13677 100644 --- a/ulib/axlibc/src/errno.rs +++ b/ulib/ruxlibc/src/errno.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/src/fd_ops.rs b/ulib/ruxlibc/src/fd_ops.rs similarity index 94% rename from ulib/axlibc/src/fd_ops.rs rename to ulib/ruxlibc/src/fd_ops.rs index d73f5f04a..21518e5e6 100644 --- a/ulib/axlibc/src/fd_ops.rs +++ b/ulib/ruxlibc/src/fd_ops.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,9 +8,9 @@ */ use crate::{ctypes, utils::e}; -use arceos_posix_api::{sys_close, sys_dup, sys_dup2, sys_fcntl}; use axerrno::LinuxError; use core::ffi::c_int; +use ruxos_posix_api::{sys_close, sys_dup, sys_dup2, sys_fcntl}; /// Close a file by `fd`. #[no_mangle] diff --git a/ulib/axlibc/src/fs.rs b/ulib/ruxlibc/src/fs.rs similarity index 97% rename from ulib/axlibc/src/fs.rs rename to ulib/ruxlibc/src/fs.rs index 60f96b18c..c9b40e6e6 100644 --- a/ulib/axlibc/src/fs.rs +++ b/ulib/ruxlibc/src/fs.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,7 +9,7 @@ use core::ffi::{c_char, c_int}; -use arceos_posix_api::{ +use ruxos_posix_api::{ sys_fstat, sys_getcwd, sys_lseek, sys_lstat, sys_mkdir, sys_open, sys_rename, sys_rmdir, sys_stat, sys_unlink, }; diff --git a/ulib/axlibc/src/io.rs b/ulib/ruxlibc/src/io.rs similarity index 75% rename from ulib/axlibc/src/io.rs rename to ulib/ruxlibc/src/io.rs index f3bdfd7cf..d40a7016b 100644 --- a/ulib/axlibc/src/io.rs +++ b/ulib/ruxlibc/src/io.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,8 +8,10 @@ */ use core::ffi::{c_int, c_void}; +#[cfg(feature = "fd")] +use ruxos_posix_api::sys_ioctl; -use arceos_posix_api::{sys_read, sys_write, sys_writev}; +use ruxos_posix_api::{sys_read, sys_write, sys_writev}; use crate::{ctypes, utils::e}; @@ -39,3 +41,12 @@ pub unsafe extern "C" fn writev( ) -> ctypes::ssize_t { e(sys_writev(fd, iov, iocnt) as _) as _ } + +/// Manipulate file descriptor. +/// +/// TODO: `SET/GET` command is ignored +#[cfg(feature = "fd")] +#[no_mangle] +pub unsafe extern "C" fn rux_ioctl(fd: c_int, req: c_int, arg: usize) -> c_int { + e(sys_ioctl(fd, req.try_into().unwrap(), arg)) +} diff --git a/ulib/axlibc/src/io_mpx.rs b/ulib/ruxlibc/src/io_mpx.rs similarity index 92% rename from ulib/axlibc/src/io_mpx.rs rename to ulib/ruxlibc/src/io_mpx.rs index 2565196b3..15cb297b2 100644 --- a/ulib/axlibc/src/io_mpx.rs +++ b/ulib/ruxlibc/src/io_mpx.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -12,11 +12,11 @@ use crate::{ctypes, utils::e}; use core::ffi::c_int; #[cfg(feature = "poll")] -use arceos_posix_api::sys_poll; +use ruxos_posix_api::sys_poll; #[cfg(feature = "select")] -use arceos_posix_api::sys_select; +use ruxos_posix_api::sys_select; #[cfg(feature = "epoll")] -use arceos_posix_api::{sys_epoll_create, sys_epoll_ctl, sys_epoll_wait}; +use ruxos_posix_api::{sys_epoll_create, sys_epoll_ctl, sys_epoll_wait}; /// Creates a new epoll instance. /// diff --git a/ulib/axlibc/src/lib.rs b/ulib/ruxlibc/src/lib.rs similarity index 95% rename from ulib/axlibc/src/lib.rs rename to ulib/ruxlibc/src/lib.rs index 66056ca3c..bed472d52 100644 --- a/ulib/axlibc/src/lib.rs +++ b/ulib/ruxlibc/src/lib.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,7 +7,7 @@ * See the Mulan PSL v2 for more details. */ -//! [ArceOS] user program library for C apps. +//! [Ruxos] user program library for C apps. //! //! ## Cargo Features //! @@ -31,7 +31,7 @@ //! - `select`: Enable synchronous I/O multiplexing ([select]) support. //! - `epoll`: Enable event polling ([epoll]) support. //! -//! [ArceOS]: https://github.com/rcore-os/arceos +//! [Ruxos]: https://github.com/syswonder/ruxos //! [select]: https://man7.org/linux/man-pages/man2/select.2.html //! [epoll]: https://man7.org/linux/man-pages/man7/epoll.7.html @@ -53,8 +53,8 @@ mod ctypes { #[allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals, clippy::upper_case_acronyms)] mod libctypes; - pub use arceos_posix_api::ctypes::*; pub use libctypes::*; + pub use ruxos_posix_api::ctypes::*; } #[macro_use] @@ -103,30 +103,31 @@ pub use self::setjmp::{longjmp, setjmp}; pub use self::string::{strlen, strnlen}; pub use self::sys::sysconf; pub use self::time::{clock_gettime, nanosleep}; -#[cfg(feature = "signal")] -pub use self::time::{getitimer, setitimer}; pub use self::unistd::{abort, exit, getpid}; -#[cfg(feature = "signal")] -pub use self::unistd::{alarm, ualarm}; #[cfg(feature = "alloc")] pub use self::env::{getenv, setenv, unsetenv}; #[cfg(feature = "fd")] pub use self::fd_ops::{ax_fcntl, close, dup, dup2, dup3}; -#[cfg(feature = "alloc")] -pub use self::malloc::{free, malloc}; -#[cfg(feature = "alloc")] -pub use self::strftime::strftime; - #[cfg(feature = "fs")] pub use self::fs::{ax_open, fstat, getcwd, lseek, lstat, mkdir, rename, rmdir, stat, unlink}; - +#[cfg(feature = "fd")] +pub use self::io::rux_ioctl; +#[cfg(feature = "poll")] +pub use self::io_mpx::poll; +#[cfg(feature = "select")] +pub use self::io_mpx::select; +#[cfg(feature = "epoll")] +pub use self::io_mpx::{epoll_create, epoll_ctl, epoll_wait}; +#[cfg(feature = "alloc")] +pub use self::malloc::{free, malloc}; #[cfg(feature = "net")] pub use self::net::{ accept, ax_sendmsg, bind, connect, freeaddrinfo, getaddrinfo, getpeername, getsockname, listen, recv, recvfrom, send, sendto, shutdown, socket, }; - +#[cfg(feature = "pipe")] +pub use self::pipe::pipe; #[cfg(feature = "multitask")] pub use self::pthread::{ pthread_cond_broadcast, pthread_cond_init, pthread_cond_signal, pthread_cond_wait, @@ -137,16 +138,11 @@ pub use self::pthread::{pthread_create, pthread_exit, pthread_join, pthread_self pub use self::pthread::{ pthread_mutex_init, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock, }; - -#[cfg(feature = "pipe")] -pub use self::pipe::pipe; - -#[cfg(feature = "poll")] -pub use self::io_mpx::poll; -#[cfg(feature = "select")] -pub use self::io_mpx::select; -#[cfg(feature = "epoll")] -pub use self::io_mpx::{epoll_create, epoll_ctl, epoll_wait}; - +#[cfg(feature = "alloc")] +pub use self::strftime::strftime; #[cfg(feature = "fp_simd")] pub use self::strtod::{strtod, strtof}; +#[cfg(feature = "signal")] +pub use self::time::{getitimer, setitimer}; +#[cfg(feature = "signal")] +pub use self::unistd::{alarm, ualarm}; diff --git a/ulib/axlibc/src/malloc.rs b/ulib/ruxlibc/src/malloc.rs similarity index 95% rename from ulib/axlibc/src/malloc.rs rename to ulib/ruxlibc/src/malloc.rs index 7a4693d03..4b2cb25c5 100644 --- a/ulib/axlibc/src/malloc.rs +++ b/ulib/ruxlibc/src/malloc.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -11,7 +11,7 @@ //! //! The normal malloc(size_t) and free(size_t) are provided by the library malloc.h, and //! sys_brk is used internally to apply for memory from the kernel. But in a unikernel like -//! `ArceOS`, we noticed that the heap of the Rust user program is shared with the kernel. In +//! `Ruxos`, we noticed that the heap of the Rust user program is shared with the kernel. In //! order to maintain consistency, C user programs also choose to share the kernel heap, //! skipping the sys_brk step. diff --git a/ulib/axlibc/src/mktime.rs b/ulib/ruxlibc/src/mktime.rs similarity index 97% rename from ulib/axlibc/src/mktime.rs rename to ulib/ruxlibc/src/mktime.rs index f614f6dbb..fadc1cfb5 100644 --- a/ulib/axlibc/src/mktime.rs +++ b/ulib/ruxlibc/src/mktime.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/src/net.rs b/ulib/ruxlibc/src/net.rs similarity index 79% rename from ulib/axlibc/src/net.rs rename to ulib/ruxlibc/src/net.rs index 4541d963c..6ae7d237c 100644 --- a/ulib/axlibc/src/net.rs +++ b/ulib/ruxlibc/src/net.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,12 +7,8 @@ * See the Mulan PSL v2 for more details. */ -use arceos_posix_api::{ - sys_accept, sys_bind, sys_connect, sys_freeaddrinfo, sys_getaddrinfo, sys_getpeername, - sys_getsockname, sys_listen, sys_recv, sys_recvfrom, sys_send, sys_sendmsg, sys_sendto, - sys_shutdown, sys_socket, -}; use core::ffi::{c_char, c_int, c_void}; +use ruxos_posix_api as api; use crate::{ctypes, utils::e}; @@ -21,7 +17,7 @@ use crate::{ctypes, utils::e}; /// Return the socket file descriptor. #[no_mangle] pub unsafe extern "C" fn socket(domain: c_int, socktype: c_int, protocol: c_int) -> c_int { - e(sys_socket(domain, socktype, protocol)) + e(api::sys_socket(domain, socktype, protocol)) } /// Bind a address to a socket. @@ -33,7 +29,7 @@ pub unsafe extern "C" fn bind( socket_addr: *const ctypes::sockaddr, addrlen: ctypes::socklen_t, ) -> c_int { - e(sys_bind(socket_fd, socket_addr, addrlen)) + e(api::sys_bind(socket_fd, socket_addr, addrlen)) } /// Connects the socket to the address specified. @@ -45,7 +41,7 @@ pub unsafe extern "C" fn connect( socket_addr: *const ctypes::sockaddr, addrlen: ctypes::socklen_t, ) -> c_int { - e(sys_connect(socket_fd, socket_addr, addrlen)) + e(api::sys_connect(socket_fd, socket_addr, addrlen)) } /// Send a message on a socket to the address specified. @@ -61,9 +57,9 @@ pub unsafe extern "C" fn sendto( addrlen: ctypes::socklen_t, ) -> ctypes::ssize_t { if socket_addr.is_null() && addrlen == 0 { - return e(sys_send(socket_fd, buf_ptr, len, flag) as _) as _; + return e(api::sys_send(socket_fd, buf_ptr, len, flag) as _) as _; } - e(sys_sendto(socket_fd, buf_ptr, len, flag, socket_addr, addrlen) as _) as _ + e(api::sys_sendto(socket_fd, buf_ptr, len, flag, socket_addr, addrlen) as _) as _ } /// Send a message on a socket to the address connected. @@ -76,7 +72,7 @@ pub unsafe extern "C" fn send( len: ctypes::size_t, flag: c_int, // currently not used ) -> ctypes::ssize_t { - e(sys_send(socket_fd, buf_ptr, len, flag) as _) as _ + e(api::sys_send(socket_fd, buf_ptr, len, flag) as _) as _ } /// Receive a message on a socket and get its source address. @@ -92,9 +88,9 @@ pub unsafe extern "C" fn recvfrom( addrlen: *mut ctypes::socklen_t, ) -> ctypes::ssize_t { if socket_addr.is_null() { - return e(sys_recv(socket_fd, buf_ptr, len, flag) as _) as _; + return e(api::sys_recv(socket_fd, buf_ptr, len, flag) as _) as _; } - e(sys_recvfrom(socket_fd, buf_ptr, len, flag, socket_addr, addrlen) as _) as _ + e(api::sys_recvfrom(socket_fd, buf_ptr, len, flag, socket_addr, addrlen) as _) as _ } /// Receive a message on a socket. @@ -107,7 +103,7 @@ pub unsafe extern "C" fn recv( len: ctypes::size_t, flag: c_int, // currently not used ) -> ctypes::ssize_t { - e(sys_recv(socket_fd, buf_ptr, len, flag) as _) as _ + e(api::sys_recv(socket_fd, buf_ptr, len, flag) as _) as _ } /// Listen for connections on a socket @@ -118,7 +114,7 @@ pub unsafe extern "C" fn listen( socket_fd: c_int, backlog: c_int, // currently not used ) -> c_int { - e(sys_listen(socket_fd, backlog)) + e(api::sys_listen(socket_fd, backlog)) } /// Accept for connections on a socket @@ -130,7 +126,7 @@ pub unsafe extern "C" fn accept( socket_addr: *mut ctypes::sockaddr, socket_len: *mut ctypes::socklen_t, ) -> c_int { - e(sys_accept(socket_fd, socket_addr, socket_len)) + e(api::sys_accept(socket_fd, socket_addr, socket_len)) } /// Shut down a full-duplex connection. @@ -141,7 +137,7 @@ pub unsafe extern "C" fn shutdown( socket_fd: c_int, flag: c_int, // currently not used ) -> c_int { - e(sys_shutdown(socket_fd, flag)) + e(api::sys_shutdown(socket_fd, flag)) } /// Query addresses for a domain name. @@ -154,7 +150,7 @@ pub unsafe extern "C" fn getaddrinfo( hints: *const ctypes::addrinfo, res: *mut *mut ctypes::addrinfo, ) -> c_int { - let ret = e(sys_getaddrinfo(nodename, servname, hints, res)); + let ret = e(api::sys_getaddrinfo(nodename, servname, hints, res)); match ret { r if r < 0 => ctypes::EAI_FAIL, 0 => ctypes::EAI_NONAME, @@ -165,7 +161,7 @@ pub unsafe extern "C" fn getaddrinfo( /// Free queried `addrinfo` struct #[no_mangle] pub unsafe extern "C" fn freeaddrinfo(res: *mut ctypes::addrinfo) { - sys_freeaddrinfo(res); + api::sys_freeaddrinfo(res); } /// Get current address to which the socket sockfd is bound. @@ -175,7 +171,7 @@ pub unsafe extern "C" fn getsockname( addr: *mut ctypes::sockaddr, addrlen: *mut ctypes::socklen_t, ) -> c_int { - e(sys_getsockname(sock_fd, addr, addrlen)) + e(api::sys_getsockname(sock_fd, addr, addrlen)) } /// Get peer address to which the socket sockfd is connected. @@ -185,7 +181,7 @@ pub unsafe extern "C" fn getpeername( addr: *mut ctypes::sockaddr, addrlen: *mut ctypes::socklen_t, ) -> c_int { - e(sys_getpeername(sock_fd, addr, addrlen)) + e(api::sys_getpeername(sock_fd, addr, addrlen)) } /// Send a message on a socket to the address connected. @@ -198,5 +194,5 @@ pub unsafe extern "C" fn ax_sendmsg( msg: *const ctypes::msghdr, flags: c_int, ) -> ctypes::ssize_t { - e(sys_sendmsg(socket_fd, msg, flags) as _) as _ + e(api::sys_sendmsg(socket_fd, msg, flags) as _) as _ } diff --git a/ulib/axlibc/src/pipe.rs b/ulib/ruxlibc/src/pipe.rs similarity index 90% rename from ulib/axlibc/src/pipe.rs rename to ulib/ruxlibc/src/pipe.rs index 34f66b379..d4d853ca6 100644 --- a/ulib/axlibc/src/pipe.rs +++ b/ulib/ruxlibc/src/pipe.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,7 +9,7 @@ use core::ffi::c_int; -use arceos_posix_api::sys_pipe; +use ruxos_posix_api::sys_pipe; use crate::utils::e; diff --git a/ulib/axlibc/src/pthread.rs b/ulib/ruxlibc/src/pthread.rs similarity index 98% rename from ulib/axlibc/src/pthread.rs rename to ulib/ruxlibc/src/pthread.rs index 251cc0b31..8df293acc 100644 --- a/ulib/axlibc/src/pthread.rs +++ b/ulib/ruxlibc/src/pthread.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,8 +8,8 @@ */ use crate::{ctypes, utils::e}; -use arceos_posix_api as api; use core::ffi::{c_int, c_void}; +use ruxos_posix_api as api; /// Returns the `pthread` struct of current thread. #[no_mangle] diff --git a/ulib/axlibc/src/rand.rs b/ulib/ruxlibc/src/rand.rs similarity index 99% rename from ulib/axlibc/src/rand.rs rename to ulib/ruxlibc/src/rand.rs index 61f478479..a1cca9c6a 100644 --- a/ulib/axlibc/src/rand.rs +++ b/ulib/ruxlibc/src/rand.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/src/resource.rs b/ulib/ruxlibc/src/resource.rs similarity index 90% rename from ulib/axlibc/src/resource.rs rename to ulib/ruxlibc/src/resource.rs index d83675b90..2f55ea5e9 100644 --- a/ulib/axlibc/src/resource.rs +++ b/ulib/ruxlibc/src/resource.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -9,7 +9,7 @@ use core::ffi::c_int; -use arceos_posix_api::{sys_getrlimit, sys_setrlimit}; +use ruxos_posix_api::{sys_getrlimit, sys_setrlimit}; use crate::utils::e; diff --git a/ulib/axlibc/src/setjmp.rs b/ulib/ruxlibc/src/setjmp.rs similarity index 99% rename from ulib/axlibc/src/setjmp.rs rename to ulib/ruxlibc/src/setjmp.rs index 76dde2785..bf310415c 100644 --- a/ulib/axlibc/src/setjmp.rs +++ b/ulib/ruxlibc/src/setjmp.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/src/signal.rs b/ulib/ruxlibc/src/signal.rs similarity index 96% rename from ulib/axlibc/src/signal.rs rename to ulib/ruxlibc/src/signal.rs index b747e3951..1fc19d958 100644 --- a/ulib/axlibc/src/signal.rs +++ b/ulib/ruxlibc/src/signal.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -13,7 +13,7 @@ use core::ffi::c_int; use crate::ctypes::k_sigaction; use crate::ctypes::{sigaction, EINVAL, SIGKILL, SIGSTOP}; #[cfg(feature = "signal")] -use arceos_posix_api::sys_sigaction; +use ruxos_posix_api::sys_sigaction; #[cfg(feature = "signal")] unsafe extern "C" fn ignore_handler(_: c_int) {} diff --git a/ulib/axlibc/src/strftime.rs b/ulib/ruxlibc/src/strftime.rs similarity index 99% rename from ulib/axlibc/src/strftime.rs rename to ulib/ruxlibc/src/strftime.rs index 3d24daae7..c839b5edf 100644 --- a/ulib/axlibc/src/strftime.rs +++ b/ulib/ruxlibc/src/strftime.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/src/string.rs b/ulib/ruxlibc/src/string.rs similarity index 50% rename from ulib/axlibc/src/string.rs rename to ulib/ruxlibc/src/string.rs index 28d479736..5cbbc7740 100644 --- a/ulib/axlibc/src/string.rs +++ b/ulib/ruxlibc/src/string.rs @@ -1,3 +1,12 @@ +/* Copyright (c) [2023] [Syswonder Community] + * [Ruxos] is licensed under Mulan PSL v2. + * 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. + */ + use crate::ctypes; use core::ffi::c_char; /// calculate the length of a string, excluding the terminating null byte diff --git a/ulib/axlibc/src/strtod.rs b/ulib/ruxlibc/src/strtod.rs similarity index 98% rename from ulib/axlibc/src/strtod.rs rename to ulib/ruxlibc/src/strtod.rs index 7d8bc4adc..2e1c3db41 100644 --- a/ulib/axlibc/src/strtod.rs +++ b/ulib/ruxlibc/src/strtod.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axlibc/src/sys.rs b/ulib/ruxlibc/src/sys.rs similarity index 93% rename from ulib/axlibc/src/sys.rs rename to ulib/ruxlibc/src/sys.rs index 5f50428b3..1ec89e423 100644 --- a/ulib/axlibc/src/sys.rs +++ b/ulib/ruxlibc/src/sys.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -8,8 +8,8 @@ */ use crate::ctypes; -use arceos_posix_api::{config, sys_getrlimit}; use core::ffi::{c_int, c_long}; +use ruxos_posix_api::{config, sys_getrlimit}; /// Return system configuration infomation /// @@ -32,7 +32,7 @@ pub unsafe extern "C" fn sysconf(name: c_int) -> c_long { // Avaliable physical pages ctypes::_SC_AVPHYS_PAGES => { let mut info: ctypes::sysinfo = core::mem::zeroed(); - arceos_posix_api::sys_sysinfo(&mut info); + ruxos_posix_api::sys_sysinfo(&mut info); (info.freeram / config::PAGE_SIZE_4K as u64) as c_long } // Maximum number of files per process diff --git a/ulib/axlibc/src/time.rs b/ulib/ruxlibc/src/time.rs similarity index 91% rename from ulib/axlibc/src/time.rs rename to ulib/ruxlibc/src/time.rs index f1a54b502..d124a1c32 100644 --- a/ulib/axlibc/src/time.rs +++ b/ulib/ruxlibc/src/time.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,10 +7,10 @@ * See the Mulan PSL v2 for more details. */ -use arceos_posix_api::{sys_clock_gettime, sys_clock_settime, sys_nanosleep}; -#[cfg(feature = "signal")] -use arceos_posix_api::{sys_getitimer, sys_setitimer}; use core::ffi::c_int; +use ruxos_posix_api::{sys_clock_gettime, sys_clock_settime, sys_nanosleep}; +#[cfg(feature = "signal")] +use ruxos_posix_api::{sys_getitimer, sys_setitimer}; use crate::{ctypes, utils::e}; diff --git a/ulib/axlibc/src/unistd.rs b/ulib/ruxlibc/src/unistd.rs similarity index 94% rename from ulib/axlibc/src/unistd.rs rename to ulib/ruxlibc/src/unistd.rs index bc2f1352e..deaf75bbe 100644 --- a/ulib/axlibc/src/unistd.rs +++ b/ulib/ruxlibc/src/unistd.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 @@ -7,14 +7,14 @@ * See the Mulan PSL v2 for more details. */ -use arceos_posix_api::{sys_exit, sys_getpid}; use core::ffi::c_int; +use ruxos_posix_api::{sys_exit, sys_getpid}; #[cfg(feature = "signal")] use { crate::getitimer, crate::{ctypes, utils::e}, - arceos_posix_api::sys_setitimer, core::ffi::c_uint, + ruxos_posix_api::sys_setitimer, }; /// Get current thread ID. diff --git a/ulib/axlibc/src/utils.rs b/ulib/ruxlibc/src/utils.rs similarity index 93% rename from ulib/axlibc/src/utils.rs rename to ulib/ruxlibc/src/utils.rs index 89dc56568..14d05e5cf 100644 --- a/ulib/axlibc/src/utils.rs +++ b/ulib/ruxlibc/src/utils.rs @@ -1,5 +1,5 @@ /* Copyright (c) [2023] [Syswonder Community] - * [Rukos] is licensed under Mulan PSL v2. + * [Ruxos] is licensed under Mulan PSL v2. * 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 diff --git a/ulib/axmusl/.gitignore b/ulib/ruxmusl/.gitignore similarity index 100% rename from ulib/axmusl/.gitignore rename to ulib/ruxmusl/.gitignore diff --git a/ulib/ruxmusl/Cargo.toml b/ulib/ruxmusl/Cargo.toml new file mode 100644 index 000000000..0406f4386 --- /dev/null +++ b/ulib/ruxmusl/Cargo.toml @@ -0,0 +1,58 @@ +[package] +name = "ruxmusl" +version = "0.1.0" +edition = "2021" +authors = ["yanjuguang "] +description = "Ruxos compatible layer for Musl libc" +license = "GPL-3.0-or-later OR Apache-2.0 OR MulanPSL2" +homepage = "https://github.com/syswonder/ruxos" +repository = "https://github.com/syswonder/ruxos/tree/main/ulib/ruxmusl" + +[lib] +crate-type = ["staticlib"] + +[features] +default = [] + +# Multicore +smp = ["ruxos_posix_api/smp"] + +# Floating point/SIMD +fp_simd = ["ruxfeat/fp_simd"] + +# Memory +alloc = ["ruxos_posix_api/alloc"] +tls = ["alloc", "ruxfeat/tls"] + +# Multi-task +multitask = ["ruxos_posix_api/multitask"] + +# File system +fs = ["ruxos_posix_api/fs", "fd"] + +# Networking +net = ["ruxos_posix_api/net", "fd"] + +# Libc features +fd = ["ruxos_posix_api/fd"] +pipe = ["ruxos_posix_api/pipe"] +select = ["ruxos_posix_api/select"] +epoll = ["ruxos_posix_api/epoll"] +poll = ["ruxos_posix_api/poll"] +rtc = ["ruxfeat/rtc"] + +musl = ["ruxos_posix_api/musl", "tls"] + +# Interrupts +irq = ["ruxos_posix_api/irq", "ruxfeat/irq"] + +sched_rr = ["irq", "ruxfeat/sched_rr"] + +[dependencies] +ruxfeat = { path = "../../api/ruxfeat" } +ruxos_posix_api = { path = "../../api/ruxos_posix_api" } +num_enum = { version = "0.5.11", default-features = false } +ruxhal = { path = "../../modules/ruxhal" } +axlog = { path = "../../modules/axlog" } +kernel_guard = { path = "../../crates/kernel_guard" } +crate_interface = { path = "../../crates/crate_interface" } diff --git a/ulib/ruxmusl/src/lib.rs b/ulib/ruxmusl/src/lib.rs new file mode 100644 index 000000000..cd124c69f --- /dev/null +++ b/ulib/ruxmusl/src/lib.rs @@ -0,0 +1,16 @@ +//! Syscall dispatch crate +//! +//! Dispatch musl syscall instruction to Ruxos posix-api +//! +//! Only support AARCH64 right now + +#![cfg_attr(all(not(test), not(doc)), no_std)] + +#[macro_use] +extern crate axlog; + +#[cfg(feature = "alloc")] +extern crate alloc; + +mod syscall; +mod trap; diff --git a/ulib/axmusl/src/syscall/mod.rs b/ulib/ruxmusl/src/syscall/mod.rs similarity index 61% rename from ulib/axmusl/src/syscall/mod.rs rename to ulib/ruxmusl/src/syscall/mod.rs index ef90245a4..4b3748ce2 100644 --- a/ulib/axmusl/src/syscall/mod.rs +++ b/ulib/ruxmusl/src/syscall/mod.rs @@ -1,7 +1,7 @@ pub mod syscall_id; -use arceos_posix_api::ctypes; use core::ffi::c_int; +use ruxos_posix_api::ctypes; use syscall_id::SyscallId; pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { @@ -9,22 +9,22 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { unsafe { match syscall_id { - SyscallId::INVALID => arceos_posix_api::sys_invalid(syscall_id as usize as c_int) as _, + SyscallId::INVALID => ruxos_posix_api::sys_invalid(syscall_id as usize as c_int) as _, #[cfg(feature = "fs")] SyscallId::GETCWD => { - arceos_posix_api::sys_getcwd(args[0] as *mut core::ffi::c_char, args[1]) as _ + ruxos_posix_api::sys_getcwd(args[0] as *mut core::ffi::c_char, args[1]) as _ } #[cfg(feature = "epoll")] - SyscallId::EPOLL_CREATE1 => arceos_posix_api::sys_epoll_create(args[0] as c_int) as _, + SyscallId::EPOLL_CREATE1 => ruxos_posix_api::sys_epoll_create(args[0] as c_int) as _, #[cfg(feature = "epoll")] - SyscallId::EPOLL_CTL => arceos_posix_api::sys_epoll_ctl( + SyscallId::EPOLL_CTL => ruxos_posix_api::sys_epoll_ctl( args[0] as c_int, args[1] as c_int, args[2] as c_int, args[3] as *mut ctypes::epoll_event, ) as _, #[cfg(feature = "epoll")] - SyscallId::EPOLL_PWAIT => arceos_posix_api::sys_epoll_pwait( + SyscallId::EPOLL_PWAIT => ruxos_posix_api::sys_epoll_pwait( args[0] as c_int, args[1] as *mut ctypes::epoll_event, args[2] as c_int, @@ -33,70 +33,88 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[5] as *const ctypes::size_t, ) as _, #[cfg(feature = "fd")] - SyscallId::DUP => arceos_posix_api::sys_dup(args[0] as c_int) as _, + SyscallId::DUP => ruxos_posix_api::sys_dup(args[0] as c_int) as _, #[cfg(feature = "fd")] SyscallId::DUP3 => { - arceos_posix_api::sys_dup3(args[0] as c_int, args[1] as c_int, args[2] as c_int) - as _ + ruxos_posix_api::sys_dup3(args[0] as c_int, args[1] as c_int, args[2] as c_int) as _ } #[cfg(feature = "fd")] SyscallId::FCNTL => { - arceos_posix_api::sys_fcntl(args[0] as c_int, args[1] as c_int, args[2]) as _ + ruxos_posix_api::sys_fcntl(args[0] as c_int, args[1] as c_int, args[2]) as _ } #[cfg(feature = "fd")] - SyscallId::IOCTL => { - arceos_posix_api::sys_ioctl(args[0] as c_int, args[1], args[2]) as _ - } + SyscallId::IOCTL => ruxos_posix_api::sys_ioctl(args[0] as c_int, args[1], args[2]) as _, #[cfg(feature = "fs")] - SyscallId::MKDIRAT => arceos_posix_api::sys_mkdirat( + SyscallId::MKDIRAT => ruxos_posix_api::sys_mkdirat( args[0] as c_int, args[1] as *const core::ffi::c_char, args[2] as ctypes::mode_t, ) as _, #[cfg(feature = "fs")] - SyscallId::UNLINKAT => arceos_posix_api::sys_unlinkat( + SyscallId::UNLINKAT => ruxos_posix_api::sys_unlinkat( + args[0] as c_int, + args[1] as *const core::ffi::c_char, + args[2] as c_int, + ) as _, + #[cfg(feature = "fs")] + SyscallId::FCHOWNAT => ruxos_posix_api::sys_fchownat( + args[0] as c_int, + args[1] as *const core::ffi::c_char, + args[2] as ctypes::uid_t, + args[3] as ctypes::gid_t, + args[4] as c_int, + ) as _, + #[cfg(feature = "fs")] + SyscallId::RENAMEAT => ruxos_posix_api::sys_renameat( args[0] as c_int, args[1] as *const core::ffi::c_char, args[2] as c_int, + args[3] as *const core::ffi::c_char, ) as _, #[cfg(feature = "fs")] - SyscallId::OPENAT => arceos_posix_api::sys_openat( + SyscallId::OPENAT => ruxos_posix_api::sys_openat( args[0], args[1] as *const core::ffi::c_char, args[2] as c_int, args[3] as ctypes::mode_t, ) as _, #[cfg(feature = "fd")] - SyscallId::CLOSE => arceos_posix_api::sys_close(args[0] as c_int) as _, + SyscallId::CLOSE => ruxos_posix_api::sys_close(args[0] as c_int) as _, #[cfg(feature = "pipe")] - SyscallId::PIPE2 => arceos_posix_api::sys_pipe2( + SyscallId::PIPE2 => ruxos_posix_api::sys_pipe2( core::slice::from_raw_parts_mut(args[0] as *mut c_int, 2), args[1] as c_int, ) as _, #[cfg(feature = "fs")] - SyscallId::LSEEK => arceos_posix_api::sys_lseek( + SyscallId::LSEEK => ruxos_posix_api::sys_lseek( args[0] as c_int, args[1] as ctypes::off_t, args[2] as c_int, ) as _, - SyscallId::READ => arceos_posix_api::sys_read( + SyscallId::READ => ruxos_posix_api::sys_read( args[0] as c_int, args[1] as *mut core::ffi::c_void, args[2], ) as _, - SyscallId::WRITE => arceos_posix_api::sys_write( + SyscallId::WRITE => ruxos_posix_api::sys_write( args[0] as c_int, args[1] as *mut core::ffi::c_void, args[2], ) as _, #[cfg(feature = "fd")] - SyscallId::WRITEV => arceos_posix_api::sys_writev( + SyscallId::READV => ruxos_posix_api::sys_readv( + args[0] as c_int, + args[1] as *const ctypes::iovec, + args[2] as c_int, + ) as _, + #[cfg(feature = "fd")] + SyscallId::WRITEV => ruxos_posix_api::sys_writev( args[0] as c_int, args[1] as *const ctypes::iovec, args[2] as c_int, ) as _, #[cfg(feature = "select")] - SyscallId::PSELECT6 => arceos_posix_api::sys_pselect6( + SyscallId::PSELECT6 => ruxos_posix_api::sys_pselect6( args[0] as c_int, args[1] as *mut ctypes::fd_set, args[2] as *mut ctypes::fd_set, @@ -105,7 +123,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[5] as *const core::ffi::c_void, ) as _, #[cfg(feature = "poll")] - SyscallId::PPOLL => arceos_posix_api::sys_ppoll( + SyscallId::PPOLL => ruxos_posix_api::sys_ppoll( args[0] as *mut ctypes::pollfd, args[1] as ctypes::nfds_t, args[2] as *const ctypes::timespec, @@ -113,7 +131,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[4] as ctypes::size_t, ) as _, #[cfg(feature = "fs")] - SyscallId::NEWFSTATAT => arceos_posix_api::sys_newfstatat( + SyscallId::NEWFSTATAT => ruxos_posix_api::sys_newfstatat( args[0] as c_int, args[1] as *const core::ffi::c_char, args[2] as *mut ctypes::kstat, @@ -121,23 +139,24 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { ) as _, #[cfg(feature = "fs")] SyscallId::FSTAT => { - arceos_posix_api::sys_fstat(args[0] as c_int, args[1] as *mut core::ffi::c_void) - as _ + ruxos_posix_api::sys_fstat(args[0] as c_int, args[1] as *mut core::ffi::c_void) as _ } #[cfg(feature = "fs")] - SyscallId::FSYNC => arceos_posix_api::sys_fsync(args[0] as c_int) as _, + SyscallId::FSYNC => ruxos_posix_api::sys_fsync(args[0] as c_int) as _, + #[cfg(feature = "fs")] + SyscallId::FDATASYNC => ruxos_posix_api::sys_fdatasync(args[0] as c_int) as _, #[allow(unreachable_code)] #[cfg(not(feature = "multitask"))] - SyscallId::EXIT => arceos_posix_api::sys_exit(args[0] as c_int) as _, + SyscallId::EXIT => ruxos_posix_api::sys_exit(args[0] as c_int) as _, #[allow(unreachable_code)] #[cfg(feature = "multitask")] SyscallId::EXIT => { - arceos_posix_api::sys_pthread_exit(args[0] as *mut core::ffi::c_void) as _ + ruxos_posix_api::sys_pthread_exit(args[0] as *mut core::ffi::c_void) as _ } #[cfg(feature = "multitask")] - SyscallId::SET_TID_ADDRESS => arceos_posix_api::sys_set_tid_address(args[0]) as _, + SyscallId::SET_TID_ADDRESS => ruxos_posix_api::sys_set_tid_address(args[0]) as _, #[cfg(feature = "multitask")] - SyscallId::FUTEX => arceos_posix_api::sys_futex( + SyscallId::FUTEX => ruxos_posix_api::sys_futex( args[0], args[1] as c_int, args[2] as c_int, @@ -145,87 +164,88 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[4] as c_int, args[5] as c_int, ) as _, - SyscallId::NANO_SLEEP => arceos_posix_api::sys_nanosleep( + SyscallId::NANO_SLEEP => ruxos_posix_api::sys_nanosleep( args[0] as *const ctypes::timespec, args[1] as *mut ctypes::timespec, ) as _, - SyscallId::CLOCK_SETTIME => arceos_posix_api::sys_clock_settime( + SyscallId::CLOCK_SETTIME => ruxos_posix_api::sys_clock_settime( args[0] as ctypes::clockid_t, args[1] as *mut ctypes::timespec, ) as _, - SyscallId::CLOCK_GETTIME => arceos_posix_api::sys_clock_gettime( + SyscallId::CLOCK_GETTIME => ruxos_posix_api::sys_clock_gettime( args[0] as ctypes::clockid_t, args[1] as *mut ctypes::timespec, ) as _, - SyscallId::SCHED_YIELD => arceos_posix_api::sys_sched_yield() as _, - SyscallId::RT_SIGACTION => arceos_posix_api::sys_rt_sigaction( + SyscallId::SCHED_YIELD => ruxos_posix_api::sys_sched_yield() as _, + SyscallId::RT_SIGACTION => ruxos_posix_api::sys_rt_sigaction( args[0] as c_int, args[1] as *const ctypes::sigaction, args[2] as *mut ctypes::sigaction, args[3] as ctypes::size_t, ) as _, - SyscallId::RT_SIGPROCMASK => arceos_posix_api::sys_rt_sigprocmask( + SyscallId::RT_SIGPROCMASK => ruxos_posix_api::sys_rt_sigprocmask( args[0] as c_int, args[1] as *const usize, args[2] as *mut usize, args[3], ) as _, + SyscallId::UNAME => ruxos_posix_api::sys_uname(args[0] as *mut core::ffi::c_void) as _, SyscallId::GETRLIMIT => { - arceos_posix_api::sys_getrlimit(args[0] as c_int, args[1] as *mut ctypes::rlimit) + ruxos_posix_api::sys_getrlimit(args[0] as c_int, args[1] as *mut ctypes::rlimit) as _ } SyscallId::SETRLIMIT => { - arceos_posix_api::sys_setrlimit(args[0] as c_int, args[1] as *const ctypes::rlimit) + ruxos_posix_api::sys_setrlimit(args[0] as c_int, args[1] as *const ctypes::rlimit) as _ } - SyscallId::UMASK => arceos_posix_api::sys_umask(args[0] as ctypes::mode_t) as _, + SyscallId::UMASK => ruxos_posix_api::sys_umask(args[0] as ctypes::mode_t) as _, #[cfg(feature = "multitask")] - SyscallId::GETPID => arceos_posix_api::sys_getpid() as _, - + SyscallId::GETPID => ruxos_posix_api::sys_getpid() as _, + SyscallId::GETEUID => ruxos_posix_api::sys_geteuid() as _, SyscallId::SYSINFO => { - arceos_posix_api::sys_sysinfo(args[0] as *mut ctypes::sysinfo) as _ + ruxos_posix_api::sys_sysinfo(args[0] as *mut ctypes::sysinfo) as _ } #[cfg(feature = "net")] SyscallId::SOCKET => { - arceos_posix_api::sys_socket(args[0] as c_int, args[1] as c_int, args[2] as c_int) + ruxos_posix_api::sys_socket(args[0] as c_int, args[1] as c_int, args[2] as c_int) as _ } #[cfg(feature = "net")] - SyscallId::BIND => arceos_posix_api::sys_bind( + SyscallId::BIND => ruxos_posix_api::sys_bind( args[0] as c_int, args[1] as *const ctypes::sockaddr, args[2] as ctypes::socklen_t, ) as _, #[cfg(feature = "net")] SyscallId::LISTEN => { - arceos_posix_api::sys_listen(args[0] as c_int, args[1] as c_int) as _ + ruxos_posix_api::sys_listen(args[0] as c_int, args[1] as c_int) as _ } #[cfg(feature = "net")] - SyscallId::ACCEPT => arceos_posix_api::sys_accept( + SyscallId::ACCEPT => ruxos_posix_api::sys_accept( args[0] as c_int, args[1] as *mut ctypes::sockaddr, args[2] as *mut ctypes::socklen_t, ) as _, #[cfg(feature = "net")] - SyscallId::CONNECT => arceos_posix_api::sys_connect( + SyscallId::CONNECT => ruxos_posix_api::sys_connect( args[0] as c_int, args[1] as *const ctypes::sockaddr, args[2] as ctypes::socklen_t, ) as _, #[cfg(feature = "net")] - SyscallId::GETSOCKNAME => arceos_posix_api::sys_getsockname( + SyscallId::GETSOCKNAME => ruxos_posix_api::sys_getsockname( args[0] as c_int, args[1] as *mut ctypes::sockaddr, args[2] as *mut ctypes::socklen_t, ) as _, #[cfg(feature = "net")] - SyscallId::GETPEERNAME => arceos_posix_api::sys_getpeername( + SyscallId::GETPEERNAME => ruxos_posix_api::sys_getpeername( args[0] as c_int, args[1] as *mut ctypes::sockaddr, args[2] as *mut ctypes::socklen_t, ) as _, #[cfg(feature = "net")] - SyscallId::SENDTO => arceos_posix_api::sys_sendto( + SyscallId::SENDTO => ruxos_posix_api::sys_sendto( args[0] as c_int, args[1] as *const core::ffi::c_void, args[2] as ctypes::size_t, @@ -234,7 +254,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[5] as ctypes::socklen_t, ) as _, #[cfg(feature = "net")] - SyscallId::RECVFROM => arceos_posix_api::sys_recvfrom( + SyscallId::RECVFROM => ruxos_posix_api::sys_recvfrom( args[0] as c_int, args[1] as *mut core::ffi::c_void, args[2] as ctypes::size_t, @@ -243,7 +263,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[5] as *mut ctypes::socklen_t, ) as _, #[cfg(feature = "net")] - SyscallId::SETSOCKOPT => arceos_posix_api::sys_setsockopt( + SyscallId::SETSOCKOPT => ruxos_posix_api::sys_setsockopt( args[0] as c_int, args[1] as c_int, args[2] as c_int, @@ -252,21 +272,21 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { ) as _, #[cfg(feature = "net")] SyscallId::SHUTDOWN => { - arceos_posix_api::sys_shutdown(args[0] as c_int, args[1] as c_int) as _ + ruxos_posix_api::sys_shutdown(args[0] as c_int, args[1] as c_int) as _ } #[cfg(feature = "net")] - SyscallId::SENDMSG => arceos_posix_api::sys_sendmsg( + SyscallId::SENDMSG => ruxos_posix_api::sys_sendmsg( args[0] as c_int, args[1] as *const ctypes::msghdr, args[2] as c_int, ) as _, #[cfg(feature = "alloc")] - SyscallId::MUNMAP => arceos_posix_api::sys_munmap( + SyscallId::MUNMAP => ruxos_posix_api::sys_munmap( args[0] as *mut core::ffi::c_void, args[1] as ctypes::size_t, ) as _, #[cfg(feature = "multitask")] - SyscallId::CLONE => arceos_posix_api::sys_clone( + SyscallId::CLONE => ruxos_posix_api::sys_clone( args[0] as c_int, args[1] as *mut core::ffi::c_void, args[2] as *mut ctypes::pid_t, @@ -274,7 +294,7 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[4] as *mut ctypes::pid_t, ) as _, #[cfg(feature = "alloc")] - SyscallId::MMAP => arceos_posix_api::sys_mmap( + SyscallId::MMAP => ruxos_posix_api::sys_mmap( args[0] as *mut core::ffi::c_void, args[1] as ctypes::size_t, args[2] as c_int, @@ -283,12 +303,12 @@ pub fn syscall(syscall_id: SyscallId, args: [usize; 6]) -> isize { args[5] as ctypes::off_t, ) as _, #[cfg(feature = "alloc")] - SyscallId::MPROTECT => arceos_posix_api::sys_mprotect( + SyscallId::MPROTECT => ruxos_posix_api::sys_mprotect( args[0] as *mut core::ffi::c_void, args[1] as ctypes::size_t, args[2] as c_int, ) as _, - SyscallId::PRLIMIT64 => arceos_posix_api::sys_prlimit64( + SyscallId::PRLIMIT64 => ruxos_posix_api::sys_prlimit64( args[0] as ctypes::pid_t, args[1] as c_int, args[2] as *const ctypes::rlimit, diff --git a/ulib/axmusl/src/syscall/syscall_id.rs b/ulib/ruxmusl/src/syscall/syscall_id.rs similarity index 91% rename from ulib/axmusl/src/syscall/syscall_id.rs rename to ulib/ruxmusl/src/syscall/syscall_id.rs index 0dd9214e5..0a739df5a 100644 --- a/ulib/axmusl/src/syscall/syscall_id.rs +++ b/ulib/ruxmusl/src/syscall/syscall_id.rs @@ -28,6 +28,10 @@ pub enum SyscallId { #[cfg(feature = "fs")] UNLINKAT = 35, #[cfg(feature = "fs")] + RENAMEAT = 38, + #[cfg(feature = "fs")] + FCHOWNAT = 54, + #[cfg(feature = "fs")] OPENAT = 56, #[cfg(feature = "fd")] CLOSE = 57, @@ -38,6 +42,8 @@ pub enum SyscallId { READ = 63, WRITE = 64, #[cfg(feature = "fd")] + READV = 65, + #[cfg(feature = "fd")] WRITEV = 66, #[cfg(feature = "select")] PSELECT6 = 72, @@ -49,6 +55,8 @@ pub enum SyscallId { FSTAT = 80, #[cfg(feature = "fs")] FSYNC = 82, + #[cfg(feature = "fs")] + FDATASYNC = 83, EXIT = 93, #[cfg(feature = "multitask")] SET_TID_ADDRESS = 96, @@ -60,11 +68,13 @@ pub enum SyscallId { SCHED_YIELD = 124, RT_SIGACTION = 134, RT_SIGPROCMASK = 135, + UNAME = 160, GETRLIMIT = 163, SETRLIMIT = 164, UMASK = 166, #[cfg(feature = "multitask")] GETPID = 172, + GETEUID = 175, SYSINFO = 179, #[cfg(feature = "net")] SOCKET = 198, diff --git a/ulib/axmusl/src/trap.rs b/ulib/ruxmusl/src/trap.rs similarity index 78% rename from ulib/axmusl/src/trap.rs rename to ulib/ruxmusl/src/trap.rs index a8326156e..00867a68c 100644 --- a/ulib/axmusl/src/trap.rs +++ b/ulib/ruxmusl/src/trap.rs @@ -4,16 +4,16 @@ use crate::syscall::syscall_id::SyscallId; -/// Traphandler used by musl libc, overwrite handler in axruntime +/// Traphandler used by musl libc, overwrite handler in ruxruntime struct TrapHandlerImpl; #[crate_interface::impl_interface] -impl axhal::trap::TrapHandler for TrapHandlerImpl { +impl ruxhal::trap::TrapHandler for TrapHandlerImpl { fn handle_irq(_irq_num: usize) { #[cfg(feature = "irq")] { let guard = kernel_guard::NoPreempt::new(); - axhal::irq::dispatch_irq(_irq_num); + ruxhal::irq::dispatch_irq(_irq_num); drop(guard); // rescheduling may occur when preemption is re-enabled. } }