base on An experimental modular OS written in Rust. # ArceOS [![CI](https://github.com/arceos-org/arceos/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/arceos-org/arceos/actions/workflows/build.yml) [![CI](https://github.com/arceos-org/arceos/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/arceos-org/arceos/actions/workflows/test.yml) [![Docs](https://img.shields.io/badge/docs-pages-green)](https://arceos-org.github.io/arceos/) An experimental modular operating system (or unikernel) written in Rust. ArceOS was inspired a lot by [Unikraft](https://github.com/unikraft/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](https://github.com/smoltcp-rs/smoltcp) * [x] Synchronization/Mutex * [x] SMP scheduling with [per-cpu run queue](https://github.com/arceos-org/arceos/discussions/181) * [x] File system * [ ] Compatible with Linux apps * [ ] Interrupt driven device I/O * [ ] Async I/O ## Quick Start ### Build and Run through Docker Install [Docker](https://www.docker.com/) in your system. Then build all dependencies through provided dockerfile: ```bash docker build -t arceos -f Dockerfile . ``` Create a container and build/run app: ```bash 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](https://github.com/rust-embedded/cargo-binutils) to use `rust-objcopy` and `rust-objdump` tools, and [axconfig-gen](https://github.com/arceos-org/axconfig-gen) for kernel configuration: ```bash cargo install cargo-binutils axconfig-gen ``` ##### Dependencies for running apps ```bash # for Debian/Ubuntu sudo apt-get install qemu-system # for macos brew install qemu ``` ##### Dependencies for building C apps (optional) Install `libclang-dev`: ```bash sudo apt install libclang-dev ``` Download & install [musl](https://musl.cc) toolchains: ```bash # 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](https://www.qemu.org/download/#linux) #### 2. Build & Run ```bash # 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](examples/) directory or the [arceos-apps](https://github.com/arceos-org/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](Makefile). For example, to run the [httpserver](examples/httpserver/) on `qemu-system-aarch64` with 4 cores and log level `info`: ```bash 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](https://github.com/arceos-org/app-helloworld) and [arceos-apps](https://github.com/arceos-org/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](https://doc.rust-lang.org/std/) library. Remember to annotate the `main` function with `#[unsafe(no_mangle)]` (see this [example](examples/helloworld/src/main.rs)). 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=<arch> run # more args: LOG=<log> SMP=<smp> NET=[y|n] ... ``` 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](examples/httpserver-c/)): ```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=<arch> run # more args: LOG=<log> SMP=<smp> NET=[y|n] ... ``` ## How to build ArceOS for specific platforms and devices Set the `PLATFORM` variable when run `make`: ```bash # Build helloworld for raspi4 make PLATFORM=aarch64-raspi4 SMP=4 A=examples/helloworld ``` You may also need to select the corrsponding device drivers by setting the `FEATURES` variable: ```bash # Build the shell app for raspi4, and use the SD card driver make PLATFORM=aarch64-raspi4 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 PLATFORM=x86_64-pc-oslab A=examples/httpserver FEATURES=page-alloc-4g,driver-ixgbe,driver-ramdisk SMP=4 ``` ## How to reuse ArceOS modules in your own project ```toml # In Cargo.toml [dependencies] axalloc = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.1.0" } # modules/axalloc axhal = { git = "https://github.com/arceos-org/arceos.git", tag = "v0.1.0" } # modules/axhal ``` ## Design ![](doc/figures/ArceOS.svg) ", Assign "at most 3 tags" to the expected json: {"id":"8134","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"