forked from AbleOS/ableos
34 lines
752 B
Rust
34 lines
752 B
Rust
use alloc::string::{String, ToString};
|
|
use lazy_static::lazy_static;
|
|
|
|
lazy_static! {
|
|
pub static ref KERNEL_STATE: spin::Mutex<KernelInternalState> =
|
|
spin::Mutex::new(KernelInternalState::new());
|
|
}
|
|
|
|
pub struct KernelInternalState {
|
|
hostname: String,
|
|
should_shutdown: bool,
|
|
}
|
|
|
|
impl KernelInternalState {
|
|
pub fn new() -> Self {
|
|
Self {
|
|
should_shutdown: false,
|
|
hostname: "".to_string(),
|
|
}
|
|
}
|
|
|
|
pub fn set_hostname(&mut self, hostname: String) {
|
|
self.hostname = hostname;
|
|
}
|
|
pub fn shutdown(&mut self) {
|
|
self.should_shutdown = true;
|
|
}
|
|
pub fn update_state(&mut self) {
|
|
if self.should_shutdown {
|
|
crate::arch::shutdown();
|
|
}
|
|
}
|
|
}
|