Skip to content

Commit a632f9a

Browse files
authored
Add cpu_num method to allow get cpu count dynamically, bump axplat and plat crates to 0.3.0 (#33)
1 parent a2a7e2e commit a632f9a

File tree

31 files changed

+101
-43
lines changed

31 files changed

+101
-43
lines changed

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ repository = "https://github.com/arceos-org/axplat_crates"
3636

3737
[workspace.dependencies]
3838
axcpu = "0.2"
39-
axplat = { version = "0.2.0", path = "./axplat" }
39+
axplat = { version = "0.3.0", path = "./axplat" }
4040
axplat-macros = { version = "0.1.0", path = "./axplat-macros" }
41+
axplat-aarch64-peripherals = { version = "0.3.0", path = "platforms/axplat-aarch64-peripherals" }

axplat/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "axplat"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "This crate provides a unified abstraction layer for diverse hardware platforms."
55
documentation = "https://docs.rs/axplat"
66
keywords = ["arceos", "os", "hal", "embedded"]

axplat/src/power.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@ pub trait PowerIf {
1313

1414
/// Shutdown the whole system.
1515
fn system_off() -> !;
16+
17+
/// Get the number of CPU cores available on this platform.
18+
///
19+
/// The platform should either get this value statically from its
20+
/// configuration or dynamically by platform-specific methods.
21+
///
22+
/// For statically configured platforms, by convention, this value should be
23+
/// the same as `MAX_CPU_NUM` defined in the platform configuration.
24+
fn cpu_num() -> usize;
1625
}

cargo-axplat/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-axplat"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
description = "Manages hardware platform packages using `axplat`"
55
keywords = ["arceos", "hal", "hardware", "cargo-subcommand"]
66
categories = ["development-tools", "development-tools::cargo-plugins", "embedded", "hardware-support", "os"]

cargo-axplat/template/_Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ smp = ["axplat/smp"]
99

1010
[dependencies]
1111
axconfig-macros = "0.2"
12-
axplat = "0.2"
12+
axplat = "0.3"

cargo-axplat/template/axconfig.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ package = "<PACKAGE>" # str
99
# Platform configs
1010
#
1111
[plat]
12-
# Number of CPUs.
13-
cpu-num = 1 # uint
12+
# Maximum number of CPUs. For platforms that do not support runtime CPU number
13+
# detection, it's also the number of CPUs to boot.
14+
max-cpu-num = 1 # uint
1415
# Base address of the whole physical memory.
1516
phys-memory-base = 0 # uint
1617
# Size of the whole physical memory. (128M)

cargo-axplat/template/src/power.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ impl PowerIf for PowerImpl {
1818
fn system_off() -> ! {
1919
todo!()
2020
}
21+
22+
/// Get the number of CPU cores available on this platform.
23+
fn cpu_num() -> usize {
24+
todo!()
25+
}
2126
}

examples/smp-kernel/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use core::sync::atomic::Ordering::Release;
2727

2828
const CPU_NUM: usize = match option_env!("AX_CPU_NUM") {
2929
Some(val) => const_str::parse!(val, usize),
30-
None => axplat_crate::config::plat::CPU_NUM,
30+
None => axplat_crate::config::plat::MAX_CPU_NUM,
3131
};
3232

3333
#[axplat::main]

platforms/axplat-aarch64-bsta1000b/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "axplat-aarch64-bsta1000b"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "Implementation of `axplat` hardware abstraction layer for Black Sesame Technology A1000b SoC."
55
documentation = "https://docs.rs/axplat-aarch64-bsta1000b"
66
keywords = ["arceos", "os", "hal", "embedded", "aarch64"]
@@ -24,7 +24,7 @@ page_table_entry = "0.5"
2424
dw_apb_uart = "0.1"
2525

2626
axconfig-macros = "0.2"
27-
axplat-aarch64-peripherals = { version = "0.2", path = "../axplat-aarch64-peripherals" }
27+
axplat-aarch64-peripherals = { workspace = true }
2828
axcpu = { workspace = true }
2929
axplat = { workspace = true }
3030

0 commit comments

Comments
 (0)