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.
- divide features into 3 categories: ArceOS modules (axfeat), user library (axstd/axlibc), and app itself (app)
  • Loading branch information
equation314 committed Aug 3, 2023
1 parent ef35f47 commit a23315e
Show file tree
Hide file tree
Showing 39 changed files with 373 additions and 182 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=ax/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=ax/driver-ixgbe,ax/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=ax/driver-ixgbe,ax/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=ax/driver-bcm2835-sdhci

build-apps-for-std:
runs-on: ${{ matrix.os }}
Expand Down
51 changes: 38 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ V ?=
# App options
A ?= apps/helloworld
APP ?= $(A)
APP_FEATURES ?=
FEATURES ?=

# QEMU options
BLK ?= n
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ Note that the `NET=y` argument is required to enable the network device in QEMU.

```bash
# in features.txt
alloc
paging
net
ax/paging # enable `paing` feature for ArceOS modules
lib/alloc # enable `alloc` feature for the libc
lib/net # enable `net` feature for the libc
```

3. Build your application with ArceOS, by running the `make` command in the application directory:
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 }
40 changes: 40 additions & 0 deletions api/axfeat/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! 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.
//! - `dns`: Enable DNS lookup 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]
6 changes: 3 additions & 3 deletions apps/c/httpclient/features.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
alloc
paging
net
ax/paging
lib/alloc
lib/net
6 changes: 3 additions & 3 deletions apps/c/httpserver/features.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
alloc
paging
net
ax/paging
lib/alloc
lib/net
12 changes: 6 additions & 6 deletions apps/c/iperf/features.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
alloc
paging
net
fs
select
fp_simd
ax/paging
lib/fp_simd
lib/alloc
lib/fs
lib/net
lib/select
4 changes: 2 additions & 2 deletions apps/c/memtest/features.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
alloc
paging
ax/paging
lib/alloc
6 changes: 3 additions & 3 deletions apps/c/pthread/basic/features.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
alloc
paging
multitask
ax/paging
lib/alloc
lib/multitask
6 changes: 3 additions & 3 deletions apps/c/pthread/parallel/features.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
alloc
paging
multitask
ax/paging
lib/alloc
lib/multitask
Loading

0 comments on commit a23315e

Please sign in to comment.