Skip to content

Commit

Permalink
Refactor feature passing
Browse files Browse the repository at this point in the history
- introduce crate `axfeat` to select features.
- introduce FEATURES variable to select features of ArceOS modules,
  APP_FEATURES is used for app features only.
  • Loading branch information
equation314 committed Aug 4, 2023
1 parent a6e34ef commit c66cbee
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 138 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,16 @@ jobs:
- 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 APP_FEATURES=axstd/driver-ixgbe
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 APP_FEATURES=axstd/driver-ixgbe,axstd/driver-ramdisk
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 APP_FEATURES=axstd/driver-ixgbe,axstd/driver-ramdisk SMP=4
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 APP_FEATURES=axstd/driver-bcm2835-sdhci
run: make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci

build-apps-for-std:
runs-on: ${{ matrix.os }}
Expand Down
52 changes: 39 additions & 13 deletions Cargo.lock

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

32 changes: 17 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
resolver = "2"

members = [
"apps/display",
"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",

"crates/allocator",
"crates/arm_gic",
"crates/arm_pl011",
Expand Down Expand Up @@ -62,8 +47,25 @@ members = [
"modules/axsync",
"modules/axtask",

"api/axfeat",

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

"apps/display",
"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",
]

[profile.release]
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
# - `V`: Verbose level: (empty), 1, 2
# * App options:
# - `A` or `APP`: Path to the application
# - `FEATURES`: Features to be enabled. Each feature need to start with one
# of the prefix `ax/`, `lib/` or `app/`. See "scripts/make/features.mk"
# for more details.
# - `FEATURES`: Features os ArceOS modules to be enabled.
# - `APP_FEATURES`: Features of (rust) apps to be enabled.
# * QEMU options:
# - `BLK`: Enable storage devices (virtio-blk)
# - `NET`: Enable network devices (virtio-net)
Expand All @@ -36,6 +35,7 @@ V ?=
# App options
A ?= apps/helloworld
APP ?= $(A)
FEATURES ?=
APP_FEATURES ?=

# QEMU options
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ Set the `PLATFORM` variable when run `make`:
make PLATFORM=aarch64-raspi4 A=apps/helloworld
```

You may also need to select the corrsponding device drivers by setting the `APP_FEATURES` variable:
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 A=apps/fs/shell APP_FEATURES=axstd/driver-bcm2835-sdhci
make PLATFORM=aarch64-raspi4 A=apps/fs/shell FEATURES=driver-bcm2835-sdhci
# Build Redis for the bare-metal x86_64 platform, and use the ixgbe and ramdisk driver
make PLATFORM=x86_64-pc-oslab A=apps/c/redis APP_FEATURES=axstd/driver-ixgbe,axstd/driver-ramdisk SMP=4
make PLATFORM=x86_64-pc-oslab A=apps/c/redis FEATURES=driver-ixgbe,driver-ramdisk SMP=4
```

## Design
Expand Down
73 changes: 73 additions & 0 deletions api/axfeat/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[package]
name = "axfeat"
version = "0.1.0"
edition = "2021"
authors = ["Yuekai Jia <[email protected]>"]
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"]

# Memory
alloc = ["dep:axalloc", "axruntime/alloc"]
alloc-tlsf = ["axalloc/tlsf"]
alloc-slab = ["axalloc/slab"]
alloc-buddy = ["axalloc/buddy"]
paging = ["alloc", "axhal/paging", "axruntime/paging"]

# 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", "axdriver/virtio-blk", "dep:axfs", "axruntime/fs"] # TODO: try to remove "paging"
myfs = ["axfs?/myfs"]

# Networking
net = ["alloc", "paging", "axdriver/virtio-net", "dep:axnet", "axruntime/net"]

# Display
display = ["alloc", "paging", "axdriver/virtio-gpu", "dep:axdisplay", "axruntime/display"]

# 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"]

[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 }
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 }
39 changes: 39 additions & 0 deletions api/axfeat/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Top-level feature selection for [ArceOS].
//!
//! # Cargo Features
//!
//! - CPU
//! - `smp`: Enable SMP (symmetric multiprocessing) support.
//! - `fp_simd`: Enable floating point and SIMD support.
//! - Interrupts:
//! - `irq`: Enable interrupt handling support.
//! - Memory
//! - `alloc`: Enable dynamic memory allocation.
//! - `alloc-tlsf`: Use the TLSF allocator.
//! - `alloc-slab`: Use the slab allocator.
//! - `alloc-buddy`: Use the buddy system allocator.
//! - `paging`: Enable page table manipulation.
//! - Task management
//! - `multitask`: Enable multi-threading support.
//! - `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)
//! - `fs`: Enable file system support.
//! - `myfs`: Allow users to define their custom filesystems to override the default.
//! - `net`: Enable networking support.
//! - `display`: Enable graphics support.
//! - Device drivers
//! - `bus-mmio`: Use device tree to probe all MMIO devices.
//! - `bus-pci`: Use PCI bus to probe all PCI devices.
//! - `driver-ramdisk`: Use the RAM disk to emulate the block device.
//! - `driver-ixgbe`: Enable the Intel 82599 10Gbit NIC driver.
//! - `driver-bcm2835-sdhci`: Enable the BCM2835 SDHCI driver (Raspberry Pi SD card).
//! - Logging
//! - `log-level-off`: Disable all logging.
//! - `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
#![no_std]
2 changes: 1 addition & 1 deletion apps/c/pthread/parallel/test_cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test_one "SMP=4 LOG=info" "expect_info_smp4_fifo.out"
test_one "SMP=4 LOG=info APP_FEATURES=axstd/sched_rr" "expect_info_smp4_rr.out"
test_one "SMP=4 LOG=info FEATURES=sched_rr" "expect_info_smp4_rr.out"
rm -f $APP/*.o
Loading

0 comments on commit c66cbee

Please sign in to comment.