Skip to content

Commit 73ce902

Browse files
authored
Implement get_bootarg interface (arceos-org#289)
1 parent ba1fd72 commit 73ce902

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

modules/axhal/src/lib.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub mod context {
103103
}
104104

105105
pub use axcpu::asm;
106-
pub use axplat::init::{init_early, init_later};
106+
pub use axplat::init::init_later;
107107

108108
#[cfg(feature = "smp")]
109109
pub use axplat::init::{init_early_secondary, init_later_secondary};
@@ -124,3 +124,20 @@ pub fn init_percpu(cpu_id: usize) {
124124
pub fn init_percpu_secondary(cpu_id: usize) {
125125
self::percpu::init_secondary(cpu_id);
126126
}
127+
128+
use lazyinit::LazyInit;
129+
130+
static BOOT_ARG: LazyInit<usize> = LazyInit::new();
131+
132+
/// Initializes the platform and boot argument.
133+
/// This function should be called as early as possible.
134+
pub fn init_early(cpu_id: usize, arg: usize) {
135+
BOOT_ARG.init_once(arg);
136+
axplat::init::init_early(cpu_id, arg);
137+
}
138+
139+
/// Returns the boot argument.
140+
/// This is typically the device tree blob address passed from the bootloader.
141+
pub fn get_bootarg() -> usize {
142+
*BOOT_ARG
143+
}

0 commit comments

Comments
 (0)