MCPcopy Index your code
hub / github.com/arceos-org/arceos

github.com/arceos-org/arceos @v0.2.2-hv.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.2-hv.4 ↗ · + Follow
2,023 symbols 4,383 edges 316 files 732 documented · 36%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ArceOS

CI CI Docs

An experimental modular operating system (or unikernel) written in Rust.

ArceOS was inspired a lot by Unikraft.

🚧 Working In Progress.

Features & TODOs

  • [x] Architecture: x86_64, riscv64, aarch64, loongarch64
  • [x] Platform: QEMU pc-q35 (x86_64), virt (riscv64/aarch64/loongarch64)
  • [x] Multi-thread
  • [x] FIFO/RR/CFS scheduler
  • [x] VirtIO net/blk/gpu drivers
  • [x] TCP/UDP net stack using smoltcp
  • [x] Synchronization/Mutex
  • [x] SMP scheduling with per-cpu run queue
  • [x] File system
  • [ ] Compatible with Linux apps
  • [ ] Interrupt driven device I/O
  • [ ] Async I/O

Quick Start

Build and Run through Docker

Install Docker in your system.

Then build all dependencies through provided dockerfile:

docker build -t arceos -f Dockerfile .

Create a container and build/run app:

docker run -it -v $(pwd):/arceos -w /arceos arceos bash

# Now build/run app in the container
make A=examples/helloworld ARCH=aarch64 run

Manually Build and Run

1. Install Build Dependencies

Install cargo-binutils to use rust-objcopy and rust-objdump tools, and axconfig-gen for kernel configuration, and cargo-axplat for platform configuration:

cargo install cargo-binutils axconfig-gen cargo-axplat
Dependencies for running apps
# for Debian/Ubuntu
sudo apt-get install qemu-system
# for macos
brew install qemu
Dependencies for building C apps (optional)

Install libclang-dev:

sudo apt install libclang-dev

Download & install musl toolchains:

# download
wget https://musl.cc/aarch64-linux-musl-cross.tgz
wget https://musl.cc/riscv64-linux-musl-cross.tgz
wget https://musl.cc/x86_64-linux-musl-cross.tgz
wget https://github.com/LoongsonLab/oscomp-toolchains-for-oskernel/releases/download/loongarch64-linux-musl-cross-gcc-13.2.0/loongarch64-linux-musl-cross.tgz
# install
tar zxf aarch64-linux-musl-cross.tgz
tar zxf riscv64-linux-musl-cross.tgz
tar zxf x86_64-linux-musl-cross.tgz
tar zxf loongarch64-linux-musl-cross.tgz
# exec below command in bash OR add below info in ~/.bashrc
export PATH=`pwd`/x86_64-linux-musl-cross/bin:`pwd`/aarch64-linux-musl-cross/bin:`pwd`/riscv64-linux-musl-cross/bin:`pwd`/loongarch64-linux-musl-cross/bin:$PATH

Other systems and arch please refer to Qemu Download

2. Build & Run

# build app in arceos directory
make A=path/to/app ARCH=<arch> LOG=<log>

Where path/to/app is the relative path to the application. Examples applications can be found in the examples directory or the arceos-apps repository.

<arch> should be one of riscv64, aarch64, x86_64, loongarch64.

<log> should be one of off, error, warn, info, debug, trace.

More arguments and targets can be found in Makefile.

For example, to run the httpserver on qemu-system-aarch64 with 4 cores and log level info:

make A=examples/httpserver ARCH=aarch64 LOG=info SMP=4 run NET=y

Note that the NET=y argument is required to enable the network device in QEMU. These arguments (BLK, GRAPHIC, etc.) only take effect at runtime not build time.

How to write ArceOS apps

You can write and build your custom applications outside the ArceOS source tree. Examples are given below and in the app-helloworld and arceos-apps repositories.

Rust

  1. Create a new rust package with no_std and no_main environment.
  2. Add axstd dependency and features to enable to Cargo.toml:

    ```toml [dependencies] axstd = { path = "/path/to/arceos/ulib/axstd", features = ["..."] }

    or use git repository:

    axstd = { git = "https://github.com/arceos-org/arceos.git", features = ["..."] }

    ```

  3. Call library functions from axstd in your code, just like the Rust std library.

    Remember to annotate the main function with #[unsafe(no_mangle)] (see this example).

  4. Build your application with ArceOS, by running the make command in the application directory:

    ```bash

    in app directory

    make -C /path/to/arceos A=$(pwd) ARCH= run

    more args: LOG=

    ```

    All arguments and targets are the same as above.

C

  1. Create axbuild.mk and features.txt in your project:

    bash app/ ├── foo.c ├── bar.c ├── axbuild.mk # optional, if there is only one `main.c` └── features.txt # optional, if only use default features

  2. Add build targets to axbuild.mk, add features to enable to features.txt (see this example):

    ```bash

    in axbuild.mk

    app-objs := foo.o bar.o ```

    ```bash

    in features.txt

    alloc paging net ```

  3. Build your application with ArceOS, by running the make command in the application directory:

    ```bash

    in app directory

    make -C /path/to/arceos A=$(pwd) ARCH= run

    more args: LOG=

    ```

How to build ArceOS for specific platforms and devices

You need to manually link your application with the appropriate platform packages:

// Add this line to your application (for raspi4 platform)
extern crate axplat_aarch64_raspi;

Then set the MYPLAT variable when run make:

# Build helloworld for raspi4
make MYPLAT=axplat-aarch64-raspi SMP=4 A=examples/helloworld

You may also need to select the corrsponding device drivers by setting the FEATURES variable:

# Build the shell app for raspi4, and use the SD card driver
make MYPLAT=axplat-aarch64-raspi SMP=4 A=examples/shell FEATURES=page-alloc-4g,driver-bcm2835-sdhci BUS=mmio
# Build httpserver for the bare-metal x86_64 platform, and use the ixgbe and ramdisk driver
make PLAT_CONFIG=$(pwd)/configs/custom/x86_64-pc-oslab.toml A=examples/httpserver FEATURES=page-alloc-4g,driver-ixgbe,driver-ramdisk SMP=4

How to reuse ArceOS modules in your own project

# In Cargo.toml
[dependencies]
axalloc = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.2.0" } # modules/axalloc
axhal = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.2.0" } # modules/axhal

Design

Extension points exported contracts — how you extend this code

Write (Interface)
Console write functions. [20 implementers]
tools/raspi4/chainloader/src/console.rs
ToSocketAddrs (Interface)
A trait for objects which can be converted or resolved to one or more [`SocketAddr`] values. This trait is used for gen [14 …
ulib/axstd/src/net/socket_addr.rs
FileLike (Interface)
(no doc) [6 implementers]
api/arceos_posix_api/src/imp/fd_ops.rs
VirtIoDevMeta (Interface)
A trait for VirtIO device meta information.
modules/axdriver/src/virtio.rs
WriteByte (Interface)
(no doc) [2 implementers]
ulib/axlibc/src/strftime.rs
LogIf (Interface)
(no doc) [1 implementers]
modules/axlog/src/lib.rs
TaskExt (Interface)
(no doc)
modules/axtask/src/task.rs
Read (Interface)
Console read functions. [14 implementers]
tools/raspi4/chainloader/src/console.rs

Core symbols most depended-on inside this repo

lock
called by 185
modules/axfs/src/monofs/fat/fs.rs
len
called by 55
modules/axfs/src/api/file.rs
map
called by 52
modules/axmm/src/backend/mod.rs
get
called by 46
modules/axalloc/src/lib.rs
clone
called by 45
modules/axfs/src/highlevel/file.rs
e
called by 45
ulib/axlibc/src/utils.rs
is_empty
called by 40
modules/axipi/src/queue.rs
lock
called by 38
api/arceos_posix_api/src/imp/pthread/mutex.rs

Shape

Method 908
Function 822
Class 263
Enum 16
Interface 14

Languages

Rust78%
C17%
C++3%
Ruby2%

Modules by API surface

modules/axfs/src/highlevel/file.rs65 symbols
modules/axtask/src/task.rs58 symbols
ulib/axlibc/c/stdio.c44 symbols
ulib/axlibc/c/printf.c37 symbols
api/arceos_posix_api/src/imp/net.rs37 symbols
ulib/axlibc/c/math.c35 symbols
modules/axfs/src/fops.rs35 symbols
modules/axnet/src/smoltcp_impl/tcp.rs33 symbols
modules/axfs/src/root.rs32 symbols
modules/axhal/src/dummy.rs31 symbols
ulib/axlibc/c/string.c30 symbols
modules/axnet/src/smoltcp_impl/mod.rs30 symbols

For agents

$ claude mcp add arceos \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page