os_test_framework/
platform.rs1use core::fmt::Write;
2
3use alloc::boxed::Box;
4use spin::{Mutex, Once};
5
6static PLATFORM: Once<Mutex<Box<dyn Platform>>> = Once::new();
7
8pub fn init_platform(platform: impl Platform + 'static) {
9 PLATFORM.call_once(|| Mutex::new(Box::new(platform)));
10}
11
12pub fn platform() -> &'static Mutex<Box<dyn Platform>> {
13 PLATFORM.get().unwrap()
14}
15
16pub enum ExitState {
17 Success,
18 Failed,
19}
20pub trait Platform: Send + Sync + Write {
21 fn exit(&self, state: ExitState) -> !;
22}