From 1f97a03b4d302499e91eea5537e30bdd8891d125 Mon Sep 17 00:00:00 2001 From: Yuekai Jia Date: Tue, 30 Jul 2024 21:42:19 +0800 Subject: [PATCH] [api] Re-export ArceOS modules in arceos_api, update app test --- .github/workflows/test.yml | 2 +- Cargo.lock | 4 +++- api/arceos_api/Cargo.toml | 12 ++++++++---- api/arceos_api/src/lib.rs | 28 +++++++++++++++++++++++++++- modules/axhal/Cargo.toml | 1 - modules/axhal/src/irq.rs | 4 ++-- modules/axhal/src/trap.rs | 2 +- ulib/axstd/src/os.rs | 2 ++ 8 files changed, 44 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index baae1f9d86..6cc4d61536 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: [push, pull_request] env: qemu-version: 8.2.0 rust-toolchain: nightly-2024-05-02 - arceos-apps: b36b9d5 + arceos-apps: c01cd92 jobs: unit-test: diff --git a/Cargo.lock b/Cargo.lock index ef538ea6a9..f37a7859cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,14 +84,17 @@ dependencies = [ "axalloc", "axconfig", "axdisplay", + "axdriver", "axerrno", "axfeat", "axfs", "axhal", "axio", "axlog", + "axmm", "axnet", "axruntime", + "axsync", "axtask", ] @@ -352,7 +355,6 @@ dependencies = [ "axlog", "bitflags 2.6.0", "cfg-if", - "crate_interface", "dw_apb_uart", "handler_table", "int_ratio", diff --git a/api/arceos_api/Cargo.toml b/api/arceos_api/Cargo.toml index 979e3f6691..85ae095308 100644 --- a/api/arceos_api/Cargo.toml +++ b/api/arceos_api/Cargo.toml @@ -14,10 +14,11 @@ default = [] irq = ["axfeat/irq"] 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"] +paging = ["dep:axmm", "axfeat/paging"] +multitask = ["axtask/multitask", "axsync/multitask", "axfeat/multitask"] +fs = ["dep:axfs", "dep:axdriver", "axfeat/fs"] +net = ["dep:axnet", "dep:axdriver", "axfeat/net"] +display = ["dep:axdisplay", "dep:axdriver", "axfeat/display"] myfs = ["axfeat/myfs"] @@ -32,8 +33,11 @@ axruntime = { workspace = true } axconfig = { workspace = true } axlog = { workspace = true } axhal = { workspace = true } +axsync = { workspace = true } axalloc = { workspace = true, optional = true } +axmm = { workspace = true, optional = true } axtask = { workspace = true, optional = true } +axdriver = { workspace = true, optional = true } axfs = { workspace = true, optional = true } axnet = { workspace = true, optional = true } axdisplay = { workspace = true, optional = true } diff --git a/api/arceos_api/src/lib.rs b/api/arceos_api/src/lib.rs index cb15564930..a9ed39eef8 100644 --- a/api/arceos_api/src/lib.rs +++ b/api/arceos_api/src/lib.rs @@ -15,7 +15,6 @@ feature = "dummy-if-not-enabled" ))] extern crate alloc; -extern crate axruntime; #[macro_use] mod macros; @@ -339,3 +338,30 @@ pub mod io { pub type AxPollState; } } + +/// Re-exports of ArceOS modules. +/// +/// You should prefer to use other APIs rather than these modules. The modules +/// here should only be used if other APIs do not meet your requirements. +pub mod modules { + pub use axconfig; + pub use axhal; + pub use axlog; + pub use axruntime; + pub use axsync; + + #[cfg(feature = "alloc")] + pub use axalloc; + #[cfg(feature = "display")] + pub use axdisplay; + #[cfg(any(feature = "fs", feature = "net", feature = "display"))] + pub use axdriver; + #[cfg(feature = "fs")] + pub use axfs; + #[cfg(feature = "paging")] + pub use axmm; + #[cfg(feature = "net")] + pub use axnet; + #[cfg(feature = "multitask")] + pub use axtask; +} diff --git a/modules/axhal/Cargo.toml b/modules/axhal/Cargo.toml index 94256710f8..d58b8e7b3d 100644 --- a/modules/axhal/Cargo.toml +++ b/modules/axhal/Cargo.toml @@ -32,7 +32,6 @@ lazyinit = "0.2" percpu = "0.1" memory_addr = "0.2" handler_table = "0.1" -crate_interface = "0.1" page_table_entry = "0.3" page_table_multiarch = { version = "0.3", optional = true } axlog = { workspace = true } diff --git a/modules/axhal/src/irq.rs b/modules/axhal/src/irq.rs index 5ba84661f6..fdaa788462 100644 --- a/modules/axhal/src/irq.rs +++ b/modules/axhal/src/irq.rs @@ -3,7 +3,7 @@ use handler_table::HandlerTable; use crate::platform::irq::{dispatch_irq, MAX_IRQ_COUNT}; -use crate::trap::{reg_trap_handler, IRQ}; +use crate::trap::{register_trap_handler, IRQ}; pub use crate::platform::irq::{register_handler, set_enable}; @@ -35,7 +35,7 @@ pub(crate) fn register_handler_common(irq_num: usize, handler: IrqHandler) -> bo false } -#[reg_trap_handler(IRQ)] +#[register_trap_handler(IRQ)] fn handler_irq(irq_num: usize) -> bool { let guard = kernel_guard::NoPreempt::new(); dispatch_irq(irq_num); diff --git a/modules/axhal/src/trap.rs b/modules/axhal/src/trap.rs index df23d1e64e..fcf9074d96 100644 --- a/modules/axhal/src/trap.rs +++ b/modules/axhal/src/trap.rs @@ -4,7 +4,7 @@ use linkme::distributed_slice as def_trap_handler; use memory_addr::VirtAddr; use page_table_entry::MappingFlags; -pub use linkme::distributed_slice as reg_trap_handler; +pub use linkme::distributed_slice as register_trap_handler; /// A slice of IRQ handler functions. #[def_trap_handler] diff --git a/ulib/axstd/src/os.rs b/ulib/axstd/src/os.rs index d1bdf8258e..4ea01aeb00 100644 --- a/ulib/axstd/src/os.rs +++ b/ulib/axstd/src/os.rs @@ -3,4 +3,6 @@ /// ArceOS-specific definitions. pub mod arceos { pub use arceos_api as api; + #[doc(no_inline)] + pub use arceos_api::modules; }