1
0
Fork 0
forked from AbleOS/ableos
ableOS_v1Change/ableos/src/kernel_state.rs

34 lines
752 B
Rust
Raw Normal View History

2022-01-27 01:37:12 -06:00
use alloc::string::{String, ToString};
2022-01-13 08:54:33 -06:00
use lazy_static::lazy_static;
lazy_static! {
pub static ref KERNEL_STATE: spin::Mutex<KernelInternalState> =
spin::Mutex::new(KernelInternalState::new());
}
pub struct KernelInternalState {
2022-01-27 01:37:12 -06:00
hostname: String,
2022-01-13 08:54:33 -06:00
should_shutdown: bool,
}
impl KernelInternalState {
pub fn new() -> Self {
Self {
should_shutdown: false,
2022-01-27 01:37:12 -06:00
hostname: "".to_string(),
2022-01-13 08:54:33 -06:00
}
}
2022-01-27 01:37:12 -06:00
pub fn set_hostname(&mut self, hostname: String) {
self.hostname = hostname;
}
2022-01-13 08:54:33 -06:00
pub fn shutdown(&mut self) {
self.should_shutdown = true;
}
pub fn update_state(&mut self) {
if self.should_shutdown {
crate::arch::shutdown();
}
}
}